Add Nix flake

This commit is contained in:
Agatha Lovelace 2023-04-21 18:17:12 +02:00
parent 10768ce069
commit 0a24807933
Signed by: sorceress
GPG Key ID: 01D0B3AB10CED4F8
5 changed files with 141 additions and 26 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.jekyll-metadata .jekyll-metadata
_site _site
source/.jekyll-image-optim-cache source/.jekyll-image-optim-cache
.direnv

View File

@ -1,26 +0,0 @@
with import <nixpkgs> { };
let
jekyll_env = pkgs.bundlerEnv {
name = "jekyll_env";
ruby = pkgs.ruby;
gemdir = ./.;
};
in pkgs.stdenv.mkDerivation {
name = "vampysite";
buildInputs = with pkgs; [
jekyll_env
# nokogiri dependencies
zlib
libiconv
libxml2
libxslt
nodejs-slim
];
shellHook = ''
exec bundle exec jekyll serve --livereload
'';
}

61
flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1682092588,
"narHash": "sha256-NjKBPnScpbGiH/YOx74DIFOVkr5AKJOVZoy0l7J58gk=",
"owner": "AgathaSorceress",
"repo": "nixpkgs",
"rev": "bdd3dc5aa8435b66f14636550223a9b3a50e534d",
"type": "github"
},
"original": {
"owner": "AgathaSorceress",
"ref": "image-optim-pack-cleanup",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

78
flake.nix Normal file
View File

@ -0,0 +1,78 @@
{
inputs = {
nixpkgs.url = "github:AgathaSorceress/nixpkgs/image-optim-pack-cleanup";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = pkgs.lib;
jekyll_env = pkgs.bundlerEnv {
name = "jekyll_env";
inherit (pkgs) ruby;
gemdir = ./.;
};
deps = with pkgs; [
jekyll_env
# nokogiri dependencies
zlib
libiconv
libxml2
libxslt
# jekyll wants a JS runtime
nodejs-slim
];
image_optim_deps = with pkgs; [
pngout
advancecomp
optipng
pngquant
jhead
jpegoptim
jpeg-archive
libjpeg
];
path = ''
PATH="${
lib.escapeShellArg (lib.makeBinPath image_optim_deps)
}":$PATH'';
in {
packages.default = pkgs.stdenv.mkDerivation {
name = "vampysite";
src = ./.;
buildInputs = deps;
buildPhase = ''
export ${path}
bundle exec jekyll build
'';
installPhase = ''
mkdir -p $out
cp -r _site/* $out/
'';
};
devShells = with pkgs; {
default = mkShell {
buildInputs = deps;
shellHook = "export ${path}";
};
run = mkShell {
buildInputs = deps;
shellHook = ''
export ${path}
exec bundle exec jekyll serve --livereload
'';
};
};
});
}