diff --git a/.envrc b/.envrc
index 1d953f4..3550a30 100644
--- a/.envrc
+++ b/.envrc
@@ -1 +1 @@
-use nix
+use flake
diff --git a/.gitignore b/.gitignore
index 3b9d140..a0d0ea8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.DS_Store
.aider*
+.direnv
.env
.eleventy.js.swp
.sass-cache
diff --git a/_includes/head.html b/_includes/head.html
index dc5e145..b0bc90b 100644
--- a/_includes/head.html
+++ b/_includes/head.html
@@ -4,10 +4,7 @@
- {% capture styles %} {% include "../_site/style/style.css" %} {% endcapture %}
-
+
{%- if metaTitle %} {{ metaTitle | escape }} {%- elsif name %} {{ name |
escape }}, Prestwich {%- elsif title %} {{ title | escape }}, Prestwich {%-
diff --git a/_includes/layouts/default.liquid b/_includes/layouts/default.liquid
index 4a59927..79c6088 100644
--- a/_includes/layouts/default.liquid
+++ b/_includes/layouts/default.liquid
@@ -1,7 +1,6 @@
-
- {% include "head.html" %}
+{% include "head.html" %}
diff --git a/bin/build b/bin/build
new file mode 100644
index 0000000..7c77161
--- /dev/null
+++ b/bin/build
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+sass --update style:_site/style --style compressed
+yarn eleventy
diff --git a/bin/serve b/bin/serve
new file mode 100644
index 0000000..4845271
--- /dev/null
+++ b/bin/serve
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+yarn eleventy --serve &
+ELEVENTY_PID=$!
+sass --watch style:_site/style --style compressed &
+SASS_PID=$!
+cleanup_serve() {
+ echo "Cleaning up serve processes..."
+ kill $ELEVENTY_PID 2>/dev/null
+ wait $ELEVENTY_PID 2>/dev/null
+ kill $SASS_PID 2>/dev/null
+ wait $SASS_PID 2>/dev/null
+}
+trap cleanup_serve EXIT INT TERM
+wait -n
+cleanup_serve
+trap - EXIT INT TERM
diff --git a/default.nix b/default.nix
index 7640a53..f794277 100644
--- a/default.nix
+++ b/default.nix
@@ -1,26 +1,27 @@
-{ pkgs ? import {} }:
+{
+ 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) [
+ src = builtins.filterSource (
+ path: type:
+ !(builtins.elem (baseNameOf path) [
"_site"
"node_modules"
".git"
- ]))
- src;
+ ])
+ ) src;
nativeBuildInputs = with pkgs; [
cacert
- minify
lightningcss
sass
yarn
@@ -36,17 +37,11 @@ pkgs.stdenv.mkDerivation {
'';
buildPhase = ''
- echo 'Compiling SCSS'
- sass style/style.scss _site/style/style.css
-
- echo 'Minifying CSS'
- lightningcss --minify --targets '> 0.25%, not IE 11' _site/style/*.css -o _site/style/*.css
+ echo 'Building CSS'
+ sass --update style:_site/css --style compressed
echo 'Building site'
yarn --offline eleventy
-
- echo 'Minifying HTML'
- minify --all --recursive --output . _site
'';
installPhase = ''
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..e4379b6
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,57 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 0,
+ "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=",
+ "path": "/nix/store/0xbni69flk8380w0apw4h640n37wn1i9-source",
+ "type": "path"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..994c772
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,84 @@
+{
+ description = "renegade-solar.co.uk";
+ inputs = {
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+ outputs =
+ {
+ self,
+ nixpkgs,
+ flake-utils,
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ nodeDeps = import ./node-deps.nix { inherit pkgs; };
+ inherit (nodeDeps) packageJSON nodeModules;
+
+ pkgs = import nixpkgs {
+ inherit system;
+ };
+
+ # Common build inputs
+ commonBuildInputs = with pkgs; [
+ djlint
+ sass
+ vscode-langservers-extracted
+ yarn
+ yarn2nix
+ ];
+
+ # Helper function to create scripts
+ mkScript =
+ name:
+ (pkgs.writeScriptBin name (builtins.readFile ./bin/${name})).overrideAttrs (old: {
+ buildCommand = "${old.buildCommand}\n patchShebangs $out";
+ });
+
+ # Helper function to create packages
+ mkPackage =
+ name:
+ pkgs.symlinkJoin {
+ inherit name;
+ paths = [ (mkScript name) ] ++ commonBuildInputs;
+ buildInputs = [ pkgs.makeWrapper ];
+ postBuild = "wrapProgram $out/bin/${name} --prefix PATH : $out/bin";
+ };
+
+ # Script names
+ scripts = [
+ "build"
+ "serve"
+ ];
+
+ # Generate all packages
+ scriptPackages = builtins.listToAttrs (
+ map (name: {
+ inherit name;
+ value = mkPackage name;
+ }) scripts
+ );
+
+ in
+ rec {
+ defaultPackage = packages.serve;
+ packages = scriptPackages;
+
+ devShells = rec {
+ default = dev;
+ dev = pkgs.mkShell {
+ buildInputs = commonBuildInputs ++ (builtins.attrValues packages);
+ shellHook = ''
+ rm -rf node_modules
+ rm -rf package.json
+ ln -sf ${packageJSON} package.json
+ ln -sf ${nodeModules}/node_modules .
+ echo "Development environment ready!"
+ echo "Run 'serve' to start development server"
+ echo "Run 'build' to build the site in the _site directory"
+ '';
+ };
+ };
+ }
+ );
+}