Switch to Flake builds
This commit is contained in:
parent
26fc0424d3
commit
0570e86605
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.DS_Store
|
||||
.aider*
|
||||
.direnv
|
||||
.env
|
||||
.eleventy.js.swp
|
||||
.sass-cache
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="robots" content="max-image-preview:large" />
|
||||
<meta name="generator" content="Eleventy" />
|
||||
{% capture styles %} {% include "../_site/style/style.css" %} {% endcapture %}
|
||||
<style>
|
||||
{{ styles }}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/style/style.css">
|
||||
<title>
|
||||
{%- if metaTitle %} {{ metaTitle | escape }} {%- elsif name %} {{ name |
|
||||
escape }}, Prestwich {%- elsif title %} {{ title | escape }}, Prestwich {%-
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="{{ page.lang | default: site.lang | default: "en" }}">
|
||||
|
||||
{% include "head.html" %}
|
||||
|
||||
<body>
|
||||
|
|
4
bin/build
Normal file
4
bin/build
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sass --update style:_site/style --style compressed
|
||||
yarn eleventy
|
17
bin/serve
Normal file
17
bin/serve
Normal file
|
@ -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
|
25
default.nix
25
default.nix
|
@ -1,26 +1,27 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
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 = ''
|
||||
|
|
57
flake.lock
Normal file
57
flake.lock
Normal file
|
@ -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
|
||||
}
|
84
flake.nix
Normal file
84
flake.nix
Normal file
|
@ -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"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue