diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index a62cdf0..fee8e24 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .jekyll-metadata _site source/.jekyll-image-optim-cache +.direnv \ No newline at end of file diff --git a/default.nix b/default.nix deleted file mode 100644 index 3d8c896..0000000 --- a/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -with import { }; -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 - ''; -} - diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cbced1a --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..58d0da7 --- /dev/null +++ b/flake.nix @@ -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 + ''; + }; + }; + }); +}