vegan-prestwich/default.nix

58 lines
1.1 KiB
Nix
Raw Permalink Normal View History

2024-11-26 01:27:27 +00:00
{ pkgs ? import <nixpkgs> {} }:
2024-11-26 16:53:29 +00:00
let
# Input source files
2024-11-26 01:27:27 +00:00
src = ./.;
2024-11-26 16:53:29 +00:00
nodeDeps = import ./node-deps.nix { inherit pkgs; };
inherit (nodeDeps) packageJSON nodeModules;
in
pkgs.stdenv.mkDerivation {
name = "veganprestwich-co-uk";
2024-11-26 01:27:27 +00:00
2024-11-26 16:53:29 +00:00
src = builtins.filterSource
(path: type: !(builtins.elem (baseNameOf path) [
"_site"
"node_modules"
".git"
]))
src;
nativeBuildInputs = with pkgs; [
cacert
2024-12-03 21:15:46 +00:00
minify
2024-11-27 09:17:45 +00:00
lightningcss
sass
yarn
2024-11-26 01:27:27 +00:00
];
2024-11-26 16:53:29 +00:00
configurePhase = ''
export HOME=$TMPDIR
2024-11-26 01:27:27 +00:00
mkdir -p _site/style
2024-11-26 16:53:29 +00:00
cp -r ${nodeModules}/node_modules .
chmod -R +w node_modules
cp ${packageJSON} package.json
'';
buildPhase = ''
echo 'Compiling SCSS'
2024-11-26 01:27:27 +00:00
sass style/style.scss _site/style/style.css
2024-11-26 16:53:29 +00:00
echo 'Minifying CSS'
2024-11-26 01:27:27 +00:00
lightningcss --minify --targets '> 0.25%, not IE 11' _site/style/*.css -o _site/style/*.css
2024-11-26 16:53:29 +00:00
echo 'Building site'
2024-11-27 09:17:45 +00:00
yarn --offline eleventy
2024-11-26 01:27:27 +00:00
2024-11-26 16:53:29 +00:00
echo 'Minifying HTML'
2024-12-03 21:15:46 +00:00
minify --all --recursive --output . _site
2024-11-26 01:27:27 +00:00
'';
installPhase = ''
mkdir -p $out
cp -r _site/* $out/
2024-11-26 16:53:29 +00:00
rm -rf node_modules _site package.json
2024-11-26 01:27:27 +00:00
'';
}