mirror of
https://codeberg.org/angestoepselt/homepage.git
synced 2025-05-24 14:46:16 +00:00
Add production build
This commit is contained in:
parent
53242ef352
commit
70b351ef75
3 changed files with 69 additions and 40 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -10,3 +10,5 @@ node_modules/
|
||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
.env
|
.env
|
||||||
|
# `nix build` output
|
||||||
|
/result
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -26,5 +26,14 @@ 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.
|
||||||
When node dependencies get updated (which changes `package.json`), make sure to
|
|
||||||
run `./_nix/update.sh` to update the npm lockfile and the Nix environment.
|
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.
|
||||||
|
|
||||||
|
The flake also contains a second package for building the production output:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix build .#angestoepselt-site
|
||||||
|
```
|
||||||
|
|
||||||
|
The final derivation contains a `www` folder that can be served.
|
||||||
|
|
|
||||||
34
flake.nix
34
flake.nix
|
|
@ -17,13 +17,30 @@
|
||||||
dontNpmInstall = true;
|
dontNpmInstall = true;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
# This package isn't actually the fully-built site, but rather a derivation
|
packages.${system} = {
|
||||||
# that contains the relevant programs (with correctly set up environment)
|
angestoepselt-site = pkgs.stdenv.mkDerivation {
|
||||||
# to develop and build the site. It can either be used with `nix develop` –
|
name = "angestoepselt-site";
|
||||||
# see the repository's readme for details – or compiled with `nix build`.
|
src = self;
|
||||||
# The latter will output a folder which contains node and npm binaries that
|
|
||||||
# can be used in an IDE.
|
buildInputs = [ nodejs nodeDependencies ];
|
||||||
packages.${system}.angestoepselt-site-dev = pkgs.runCommand "angestoepselt-site-dev" {
|
|
||||||
|
buildPhase = ''
|
||||||
|
npm run build
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p "$out"
|
||||||
|
cp -r _site "$out/www"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# This package isn't actually the fully-built site, but rather a
|
||||||
|
# derivation that contains the relevant programs (with correctly set up
|
||||||
|
# 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.runCommand "angestoepselt-site-dev" {
|
||||||
buildInputs = [ nodejs pkgs.makeWrapper ];
|
buildInputs = [ nodejs pkgs.makeWrapper ];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
@ -57,7 +74,8 @@
|
||||||
|
|
||||||
unset -f wrap
|
unset -f wrap
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
defaultPackage.${system} = self.packages.${system}.angestoepselt-site;
|
defaultPackage.${system} = self.packages.${system}.angestoepselt-site-dev;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue