diff --git a/.gitignore b/.gitignore index abdaef2..f3a63aa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ node_modules/ # Editor settings .vscode/ .idea/ + +# Environment +.env diff --git a/README.md b/README.md index e4eae72..095f4bc 100644 --- a/README.md +++ b/README.md @@ -1 +1,30 @@ # Angestöpselt Homepage + +This repository contains the next version of Angestöpselt's homepage, intended +to be hosted at . It is built with the +[Eleventy](https://www.11ty.dev/) static site generator, using SCSS for +stylesheets. + +## Local development environment + +To build the site locally, make sure you have Node installed (currently tested +with version 14). Then run: + +```shell +npm install +npm run build:styles +npm run dev:site +``` + +Go to , which will update live when content changes. +If you make style changes, make sure to recompile the CSS files with the second +command. Alternatively, run `npm run dev:styles` in a second terminal to watch +for changes. + +### Nix environment + +This repository also contains a [Nix flake](https://nixos.wiki/wiki/Flakes) +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. +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. diff --git a/flake.nix b/flake.nix index 7d9d1ec..22c2bbc 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ outputs = { self, nixpkgs }: let system = "x86_64-linux"; - + pkgs = import nixpkgs { inherit system; }; nodejs = pkgs.nodejs-16_x; @@ -17,12 +17,15 @@ dontNpmInstall = true; }; in { - packages.${system}.angestoepselt-site = pkgs.stdenv.mkDerivation { - name = "angestoepselt-site"; - src = self; + # 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. + packages.${system}.angestoepselt-site-dev = pkgs.runCommand "angestoepselt-site-dev" { + buildInputs = [ nodejs pkgs.makeWrapper ]; - buildInputs = [ nodejs ]; - shellHook = '' export NODE_PATH=${nodeDependencies}/lib/node_modules export PATH="${nodeDependencies}/bin:$PATH" @@ -38,7 +41,22 @@ echo " changes." echo "" ''; - }; + } '' + mkdir -p "$out" + + wrap() { + makeWrapper "${nodejs}/bin/$1" "$out/bin/$1" \ + --prefix PATH : "${nodejs}/bin" \ + --prefix PATH : "${nodeDependencies}/bin" \ + --set-default NODE_PATH "${nodeDependencies}/lib/node_modules" + } + + wrap node + wrap npm + wrap npx + + unset -f wrap + ''; defaultPackage.${system} = self.packages.${system}.angestoepselt-site; };