aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--default.nix105
1 files changed, 73 insertions, 32 deletions
diff --git a/default.nix b/default.nix
index 00572eb..31feb5a 100644
--- a/default.nix
+++ b/default.nix
@@ -1,9 +1,6 @@
let
- pkgsOriginal = import <nixpkgs> {};
- pkgs = import (pkgsOriginal.fetchzip {
- url = "https://github.com/NixOS/nixpkgs/archive/dd6b4b7078d89decabefc6b1a698327db132fbfe.zip";
- sha256 = "1cs5vibi2gab8i9m317v1b1spvmm2ppad8pxpkkp64fp1s3q6zy9";
- }) {};
+ pkgs = import <nixpkgs> {};
+ rootSrc = pkgs.nix-gitignore.gitignoreSource [] ./.;
# Taken from:
# http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html
@@ -19,41 +16,85 @@ let
ghc -O2 -dynamic --make Main.hs -o $out/bin/build-site
'';
};
-in with pkgs; with pkgs.stdenv; rec {
- build = mkDerivation rec {
- name = "website";
- src = ./site;
+ baseTask = pkgs.stdenv.mkDerivation {
+ name = "website-task";
+ src = rootSrc;
+ buildInputs = [ pkgs.perl ];
phases = "unpackPhase buildPhase";
- buildInputs = [ websiteBuilder pandoc ];
buildPhase = ''
- export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive";
- export LANG=en_US.UTF-8
+ echo "ERROR: base task buildPhase not overriden."
+ exit 1
+ '';
+ };
+in with pkgs; with pkgs.stdenv; rec {
+ subtasks = rec {
+ fixme = baseTask.overrideAttrs(baseAttrs: {
+ name = "${baseAttrs.name}-fixme";
+ buildInputs = [ ag ];
+ buildPhase = ''
+ ag FIXME --ignore default.nix || {
+ touch $out
+ }
+ '';
+ });
+ perlPodCheck = baseTask.overrideAttrs(baseAttrs: {
+ name = "${baseAttrs.name}-perl-podcheck";
+ buildPhase = ''
+ podchecker website pastebin/website-pastebin slides/website-slides
+ touch $out
+ '';
+ });
+ batsTest = baseTask.overrideAttrs(baseAttrs: {
+ name = "${baseAttrs.name}-bats-test";
+ buildInputs = baseAttrs.buildInputs ++ [ bats ];
+ buildPhase = ''
+ patchShebangs .
+ ./t/website.bats
+ touch $out
+ '';
+ });
+ perlInternalTest = baseTask.overrideAttrs(baseAttrs: {
+ name = "${baseAttrs.name}-perl-test";
+ buildPhase = ''
+ patchShebangs .
+ ./website test
+ touch $out
+ '';
+ });
+ docs = baseTask.overrideAttrs(baseAttrs: {
+ name = "${baseAttrs.name}-docs";
+ buildInputs = [ websiteBuilder 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
+ ls pastebin/*.org | awk -F. '{print $1}' | xargs -I{} pandoc -o {}.html {}.org --standalone
- build-site build
+ build-site build
- mkdir $out
- cp -r _site/* $out
- '';
+ mkdir $out
+ cp -r _site/* $out
+ '';
+ });
};
- test = mkDerivation rec {
- name = "website-test";
- src = ./.;
- phases = "unpackPhase buildPhase";
- buildInputs = [perl bats];
+ test = baseTask.overrideAttrs(baseAttrs: rec {
+ name = "${baseAttrs.name}-test";
+ buildInputs = [
+ subtasks.fixme
+ subtasks.perlPodCheck
+ subtasks.batsTest
+ subtasks.perlInternalTest
+ ];
buildPhase = ''
- mkdir txt
- podchecker website pastebin/website-pastebin slides/website-slides 2>&1 | tee txt/podchecker.txt
- patchShebangs .
- ./t/website.bats
- ./website test
- mv txt/ $out/
+ echo "Ran tests for:"
+ for d in ${builtins.toString buildInputs}; do
+ echo " $d"
+ done
+ echo "All tests passed!"
+ touch $out
'';
- };
+ });
shell = mkShell rec {
- # See also the reference documentation:
- # https://nixos.org/nixpkgs/manual/#sec-pkgs-mkShell
name = "website-shell";
buildInputs = [
websiteBuilder
@@ -70,7 +111,7 @@ in with pkgs; with pkgs.stdenv; rec {
--update \
--recursive \
--rsh="ssh -o StrictHostKeyChecking=no" \
- ${build}/ \
+ ${subtasks.docs}/ \
"$SERVER_URL:$DOCS_SERVER_PATH"
'';
}