mirror of
https://codeberg.org/angestoepselt/homepage.git
synced 2025-05-24 14:46:16 +00:00
Update nix flake
This commit is contained in:
parent
ed95bc6967
commit
a0eb7d3443
3 changed files with 79 additions and 46 deletions
|
|
@ -27,6 +27,8 @@ terminal to watch for changes.
|
||||||
This repository also contains a [Nix flake](https://nixos.wiki/wiki/Flakes)
|
This repository also contains a [Nix flake](https://nixos.wiki/wiki/Flakes)
|
||||||
which contains the full development environment. `nix develop` will open a
|
which contains the full development environment. `nix develop` will open a
|
||||||
shell with all required tools – you don't need to run `npm install` anymore.
|
shell with all required tools – you don't need to run `npm install` anymore.
|
||||||
|
Run `nix build ".#angestoepseltSiteEnv" -o .dev` to get a running Node
|
||||||
|
environment in the *.dev* folder (for example to configure an IDE).
|
||||||
|
|
||||||
When Node dependencies are updated (this will change `package.json`), make sure
|
When Node dependencies are updated (this will change `package.json`), make sure
|
||||||
to run `./_nix/update.sh` to update the npm lockfile and the Nix environment.
|
to run `./_nix/update.sh` to update the npm lockfile and the Nix environment.
|
||||||
|
|
@ -34,7 +36,7 @@ to run `./_nix/update.sh` to update the npm lockfile and the Nix environment.
|
||||||
The flake also contains a second package for building the production output:
|
The flake also contains a second package for building the production output:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix build .#angestoepselt-site
|
nix build # Will create an output derivation in 'result'
|
||||||
```
|
```
|
||||||
|
|
||||||
The final derivation contains a `www` folder that can be served.
|
The final derivation contains a `www` folder that can be served.
|
||||||
|
|
|
||||||
22
flake.lock
generated
22
flake.lock
generated
|
|
@ -1,12 +1,27 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1631561581,
|
||||||
|
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1632660378,
|
"lastModified": 1633528625,
|
||||||
"narHash": "sha256-sjA8eQlnyDjDLyAyq3XlJmN0nqW0ftl/pb7VnMg86L0=",
|
"narHash": "sha256-AGj5q58eHACAe0RQGxObrGwMUsjMozTsiznhsLCYisQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "31ffc50c571e6683e9ecc9dbcbd4a8e9914b4497",
|
"rev": "5e2018f7b383aeca6824a30c0cd1978c9532a46a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -17,6 +32,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
99
flake.nix
99
flake.nix
|
|
@ -2,26 +2,24 @@
|
||||||
description = "Angestöpselt Homepage";
|
description = "Angestöpselt Homepage";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = {self, nixpkgs, flake-utils }:
|
||||||
let
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
system = "x86_64-linux";
|
let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
nodejs = pkgs.nodejs-16_x;
|
||||||
|
|
||||||
nodejs = pkgs.nodejs-16_x;
|
nodePackages = import ./nix/default.nix { inherit pkgs system nodejs; };
|
||||||
|
nodeDependencies = nodePackages.nodeDependencies.override {
|
||||||
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||||
|
buildInputs = with pkgs; [ vips ];
|
||||||
|
dontNpmInstall = true;
|
||||||
|
};
|
||||||
|
|
||||||
nodePackages = import ./nix/default.nix { inherit pkgs system nodejs; };
|
angestoepseltSite = pkgs.stdenv.mkDerivation {
|
||||||
nodeDependencies = nodePackages.nodeDependencies.override {
|
name = "angestoepseltSite";
|
||||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
|
||||||
buildInputs = with pkgs; [ vips ];
|
|
||||||
dontNpmInstall = true;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
packages.${system} = {
|
|
||||||
angestoepselt-site = pkgs.stdenv.mkDerivation {
|
|
||||||
name = "angestoepselt-site";
|
|
||||||
src = self;
|
src = self;
|
||||||
|
|
||||||
buildInputs = [ nodejs nodeDependencies ];
|
buildInputs = [ nodejs nodeDependencies ];
|
||||||
|
|
@ -35,35 +33,52 @@
|
||||||
cp -r _site "$out/www"
|
cp -r _site "$out/www"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
apps = { inherit angestoepseltSite; };
|
||||||
|
defaultApp = apps.angestoepseltSite;
|
||||||
|
|
||||||
# This package isn't actually the fully-built site, but rather a
|
packages = {
|
||||||
# derivation that contains the relevant programs (with correctly set up
|
inherit angestoepseltSite;
|
||||||
# environment) to develop and build the site. It can either be used with
|
|
||||||
# `nix develop` – see the repository's readme for details – or compiled
|
|
||||||
# with `nix build`. The latter will output a folder which contains node
|
|
||||||
# and npm binaries that can be used in an IDE.
|
|
||||||
angestoepselt-site-dev = pkgs.symlinkJoin {
|
|
||||||
name = "angestoepselt-site-dev";
|
|
||||||
paths = [ nodejs nodeDependencies ];
|
|
||||||
|
|
||||||
shellHook = ''
|
# This package isn't actually the fully-built site, but rather a
|
||||||
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
# derivation that contains the relevant programs (with correctly set up
|
||||||
export PATH="${nodeDependencies}/bin:$PATH"
|
# environment) to develop and build the site. It can either be used with
|
||||||
|
# `nix develop` – see the repository's readme for details – or compiled
|
||||||
|
# with `nix build`. The latter will output a folder which contains node
|
||||||
|
# and npm binaries that can be used in an IDE.
|
||||||
|
angestoepseltSiteEnv = pkgs.symlinkJoin {
|
||||||
|
name = "angestoepseltSiteEnv";
|
||||||
|
|
||||||
echo ""
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
echo " To start editing content, run:"
|
paths = [ nodejs nodeDependencies ];
|
||||||
echo ""
|
|
||||||
echo "npm run build:styles"
|
postBuild = ''
|
||||||
echo "npm run dev:site"
|
wrapProgram "$out/bin/node" \
|
||||||
echo ""
|
--prefix PATH : "$out/lib/node_modules/.bin" \
|
||||||
echo " The site will be available under http://localhost:8080/ for"
|
--prefix NODE_PATH : "$out/lib/node_modules"
|
||||||
echo " local development and rebuilds automatically when content"
|
'';
|
||||||
echo " changes."
|
|
||||||
echo ""
|
shellHook = ''
|
||||||
'';
|
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
||||||
|
export PATH="${nodeDependencies}/bin:${nodejs}/bin:$PATH"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo " To start editing content, run:"
|
||||||
|
echo ""
|
||||||
|
echo "npm run build:styles"
|
||||||
|
echo "npm run dev:site"
|
||||||
|
echo ""
|
||||||
|
echo " The site will be available under http://localhost:8080/ for"
|
||||||
|
echo " local development and rebuilds automatically when content"
|
||||||
|
echo " changes."
|
||||||
|
echo ""
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
defaultPackage = packages.angestoepseltSite;
|
||||||
|
|
||||||
defaultPackage.${system} = self.packages.${system}.angestoepselt-site-dev;
|
devShell = packages.angestoepseltSiteEnv;
|
||||||
};
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue