blob: de75f93a2f742eeebc18f6d7629cce314a650b28 (
plain) (
tree)
|
|
let
pkgsUnstable = import <nixpkgs> { };
pkgsPinned = import (pkgsUnstable.fetchzip {
url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip";
sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
}) { };
pkgs = pkgsUnstable;
rootSrc = pkgs.nix-gitignore.gitignoreSource [] ./.;
# Taken from:
# http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html
websiteBuilder = pkgs.stdenv.mkDerivation {
name = "website-builder";
src = ./hakyll;
phases = "unpackPhase buildPhase";
buildInputs =
[(pkgsPinned.haskellPackages.ghcWithPackages (p: with p; [hakyll]))];
buildPhase = ''
mkdir -p $out/bin
ghc -O2 -dynamic --make Main.hs -o $out/bin/build-site
'';
};
in rec {
utils = import ./utils.nix {
pkgs = pkgs;
src = rootSrc;
baseName = "website";
};
subtasks = rec {
perlPodCheck = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-perl-podcheck";
buildInputs = baseAttrs.buildInputs ++ [pkgs.perl];
buildPhase = ''
podchecker website pastebin/website-pastebin slides/website-slides
touch $out
'';
});
batsTest = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-bats-test";
buildInputs = baseAttrs.buildInputs ++ [pkgs.bats pkgs.perl];
buildPhase = ''
patchShebangs .
./t/website.bats
touch $out
'';
});
perlInternalTest = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-perl-test";
buildInputs = baseAttrs.buildInputs ++ [pkgs.perl];
buildPhase = ''
patchShebangs .
./website test
touch $out
'';
});
hunspellCheck = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-hunspell";
buildInputs = baseAttrs.buildInputs
++ [(pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [en-us]))];
buildPhase = ''
patchShebangs .
./spelling/check-spelling.sh "${subtasks.docs}"
touch $out
'';
});
docs = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-docs";
src = ./site;
buildInputs = [ websiteBuilder pkgs.pandoc ];
buildPhase = ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive";
export LANG=en_US.UTF-8
ls pastebin/*.org | awk -F. '{print $1}' | xargs -I{} pandoc -o {}.html {}.org --standalone
build-site build
mkdir $out
cp -r _site/* $out
'';
});
};
test = utils.test [
utils.formatNix
(utils.shellcheck null)
(utils.fixme ["pastebin/skeleton.org" "utils.nix"])
subtasks.perlPodCheck
subtasks.batsTest
subtasks.perlInternalTest
subtasks.hunspellCheck
];
shell = pkgs.mkShell rec {
name = "website-shell";
buildInputs = [
websiteBuilder
(pkgs.haskellPackages.ghcWithPackages (p: with p; [hakyll]))
(pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [en-us]))
];
};
publishScript = utils.publishScript subtasks.docs;
}
|