diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2021-08-08 07:57:45 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2021-08-08 08:43:17 -0600 |
commit | 6feffc568ae790a883b9e0509d755e7d9bd82ee1 (patch) | |
tree | f913ce47e9f8204e5cf882f382d10e178e02367f /static/default.nix | |
parent | 0197d9cd493b5785bca05f476856540ec64da64a (diff) |
refactor how nix derivations are organized and built
Diffstat (limited to 'static/default.nix')
-rw-r--r-- | static/default.nix | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/static/default.nix b/static/default.nix index 74bd3bf..7c50dfa 100644 --- a/static/default.nix +++ b/static/default.nix @@ -1,53 +1,39 @@ -let - utils = (import ../nix) {}; - pkgs = utils.pkgs; - system = utils.system; +{pkgs}: rec { - jekyll_env = pkgs.bundlerEnv { - name = "jekyll_env"; + depInputs = [ pkgs.imagemagick pkgs.exiftool pkgs.bundler pkgs.bundix ]; + + depShell = pkgs.stdenv.mkDerivation { + name = "mediocre-blog-static-dep-shell"; + buildInputs = depInputs; + }; + + jekyllEnv = pkgs.bundlerEnv { + name = "jekyllEnv"; ruby = pkgs.ruby; gemdir = ./.; }; - dep_inputs = [ pkgs.imagemagick pkgs.exiftool pkgs.bundler pkgs.bundix ]; - all_inputs = [ jekyll_env ] ++ dep_inputs; -in - { - build = derivation { - inherit jekyll_env system; - - name = "mediocre-blog-static"; - builder = "${pkgs.bash}/bin/bash"; - args = [ - (pkgs.writeTextFile { - name = "mediocre-blog-static-buildsh"; - text = '' - source ${pkgs.stdenv}/setup - set -e - - mkdir -p "$out" - $jekyll_env/bin/jekyll build -s "${./src}" -d "$out" - ''; - executable = true; - }) - ]; - }; - - dev = pkgs.stdenv.mkDerivation { - name = "mediocre-blog-static-dev"; - buildInputs = all_inputs; - shellHook = '' - exec ${jekyll_env}/bin/jekyll serve -s ./src -d ./_site -w -I -D -H 0.0.0.0 -P 4001 - ''; - }; - - depShell = pkgs.stdenv.mkDerivation { - name = "mediocre-blog-static-dep-shell"; - buildInputs = dep_inputs; - }; - - shell = pkgs.stdenv.mkDerivation { - name = "mediocre-blog-static-shell"; - buildInputs = all_inputs; - }; - } + + build = pkgs.stdenv.mkDerivation { + name = "mediocre-blog-static"; + src = ./src; + buildPhase = "${jekyllEnv}/bin/jekyll build"; + installPhase = "mv _site $out"; + }; + + serve = pkgs.writeScriptBin "static-serve" '' + #!/bin/sh + exec ${jekyllEnv}/bin/jekyll serve \ + -s ./src \ + -d ./_site \ + -w -I -D \ + -P 4001 + ''; + + allInputs = depInputs ++ [ jekyllEnv serve ]; + + shell = pkgs.stdenv.mkDerivation { + name = "mediocre-blog-static-shell"; + buildInputs = allInputs; + }; +} |