68 lines
1.5 KiB
Nix
68 lines
1.5 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
eleventy-src = {
|
|
url = "github:11ty/eleventy";
|
|
flake = false;
|
|
};
|
|
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
...
|
|
}@inputs:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
eleventy = import ./pkgs/11ty-eleventy.nix {
|
|
inherit pkgs;
|
|
src = inputs.eleventy-src;
|
|
};
|
|
|
|
# The static site
|
|
site = pkgs.stdenv.mkDerivation {
|
|
pname = "my-static-site";
|
|
version = "1.0.0";
|
|
src = ./.;
|
|
buildInputs = with pkgs; [
|
|
eleventy
|
|
fd
|
|
coreutils
|
|
];
|
|
buildPhase = "eleventy";
|
|
installPhase = ''
|
|
mkdir -p $out/
|
|
echo $out
|
|
cp -r _site/* $out/
|
|
|
|
# Generate .etag files for cache validation
|
|
for file in $(fd --type f . "$out"); do
|
|
hash=$(md5sum "$file" | cut -d" " -f1)
|
|
echo "\"$hash\"" > "$file.etag"
|
|
done;
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
packages.eleventy = eleventy;
|
|
packages.site = site;
|
|
packages.default = site;
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
just
|
|
eleventy
|
|
prefetch-npm-deps
|
|
jq
|
|
curlMinimal
|
|
];
|
|
shellHook = "";
|
|
};
|
|
}
|
|
);
|
|
}
|