diff options
author | stuebinm | 2021-05-28 18:38:51 +0200 |
---|---|---|
committer | stuebinm | 2021-05-28 18:38:51 +0200 |
commit | 818f7a68df4ca0221107b2d07eb502b16fa6d653 (patch) | |
tree | e8939bed4a329fc37dc06e466ea53e4c7d4626c5 /hakyll-nix/build.nix | |
parent | 855acf6b984855646119551b39bffb4cf169dc40 (diff) |
hakyll wrapped in a nix derivation
(see the Readme.org file for more information)
Diffstat (limited to 'hakyll-nix/build.nix')
-rw-r--r-- | hakyll-nix/build.nix | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/hakyll-nix/build.nix b/hakyll-nix/build.nix new file mode 100644 index 0000000..ba45ab8 --- /dev/null +++ b/hakyll-nix/build.nix @@ -0,0 +1,43 @@ +{ pkgs ? import <nixpkgs> {} +# source of the site's files +, src ? ./defaultsite +# source of the hakyll script; will default +# to the site's source if set to null (default). +, hakyllSrc ? null +# name for the site's derivation +, name ? "hakyll-site" +# plug some other compiler in here if you want +, compiler ? "default" +}: + +with pkgs; + +let + f = import ./default.nix + (if hakyllSrc == null then src else hakyllSrc); + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + hakyll = haskellPackages.callPackage f {}; + +in stdenv.mkDerivation { + inherit src name; + + # haskell reads in files with the character encoding + # declared in an environment file; nix does not set this + # by default, causing hakyll to fail on files containing + # unicode. + LC_ALL = "C.UTF-8"; + buildInputs = [ hakyll ]; + + buildPhase = '' + ${hakyll}/bin/site build + ''; + + installPhase = '' + mkdir $out + cp -r _site/* $out + ''; +} |