diff options
Diffstat (limited to '')
-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 + ''; +} |