From 730f1e24338429e3df510decc7a26747aeb98ac7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 9 Jan 2025 23:36:04 +0000 Subject: [PATCH] Switch back to working default.nix --- default.nix | 63 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/default.nix b/default.nix index e4b28e1..e0ec175 100644 --- a/default.nix +++ b/default.nix @@ -1,15 +1,48 @@ -(import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - flake-compat = fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/refs/tags/v1.0.1.tar.gz"; - # sha256 = "sha256-8S58zrdpzGhax6tmn1iABR3AA0N9DJMu5FQI8JkA0NNU"; - }; - in - flake-compat - ) - { - src = ./.; - } -).defaultNix.packages.${builtins.currentSystem}.site +{ + pkgs ? import { }, +}: + +let + # Input source files + src = ./.; + nodeDeps = import ./node-deps.nix { inherit pkgs; }; + inherit (nodeDeps) packageJSON nodeModules; +in +pkgs.stdenv.mkDerivation { + name = "veganprestwich-co-uk"; + + src = builtins.filterSource ( + path: type: + !(builtins.elem (baseNameOf path) [ + "_site" + "node_modules" + ".git" + ]) + ) src; + + nativeBuildInputs = with pkgs; [ + cacert + lightningcss + sass + yarn + ]; + + configurePhase = '' + export HOME=$TMPDIR + mkdir -p _site/style + + cp -r ${nodeModules}/node_modules . + chmod -R +w node_modules + cp ${packageJSON} package.json + ''; + + buildPhase = '' + ${pkgs.bash}/bin/bash ${./bin/build} + ''; + + installPhase = '' + mkdir -p $out + cp -r _site/* $out/ + rm -rf node_modules _site package.json + ''; +}