aboutsummaryrefslogtreecommitdiff
path: root/default.nix
blob: 8df8ce05a64cc8f9d5456e5a4b26d3e817574849 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
let pkgs = import <nixpkgs> { };
in rec {
  utils = import ./utils.nix {
    pkgs = pkgs;
    src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
    baseName = "website";
  };
  jekyllEnv = pkgs.bundlerEnv {
    name = "jekyll-env";
    gemfile = ./Gemfile;
    lockfile = ./Gemfile.lock;
    gemset = ./gemset.nix;
  };
  subtasks = rec {
    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
      '';
    });
    assertContent = utils.baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-assert-content";
      buildInputs = baseAttrs.buildInputs ++ [ pkgs.jq ];
      buildPhase = ''
        patchShebangs .
        ./scripts/assert-content.sh "${subtasks.docs}/site.json"
        touch $out
      '';
    });
    docs = utils.baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-docs";
      buildInputs = [ jekyllEnv ];
      buildPhase = ''
        patchShebangs .
        jekyll build -d $out
      '';
    });
  };
  test = utils.test [
    utils.formatNix
    (utils.shellcheck null)
    (utils.fixme [
      "utils.nix"
      "TODOs.org"
      "_pastebins/"
      "_posts/"
      "_tils/"
      "drafts/"
      "templates/"
    ])
    subtasks.hunspellCheck
    subtasks.assertContent
    subtasks.docs
  ];
  shell = pkgs.mkShell rec {
    name = "website-shell";
    buildInputs = [
      jekyllEnv
      (pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ]))
    ];
  };
  publishScript = utils.overwritingPublishScript {
    docsDerivation = subtasks.docs;
    overwrite = true;
  };
  fastPublishScript = utils.overwritingPublishScript {
    docsDerivation = subtasks.docs;
    overwrite = false;
  };
}