summaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 7b53d400ccd215728b61f6c84f94a0374c41c4cd (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
{
  description = "NixOS flake for my website";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
  };

  outputs = {
    self,
    nixpkgs,
    treefmt-nix,
    ...
  }: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
    treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};

    build = pkgs.callPackage ./package.nix {};
    check = pkgs.stdenv.mkDerivation {
      # Add the source name, to force this to rerun (needed because it's a FOD).
      name = "zola-check-${./src}";
      src = ./src;

      # Allow network access for link checking
      outputHash = "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY=";
      outputHashMode = "recursive";

      # Run local
      preferLocalBuild = true;
      allowSubstitutes = false;

      nativeBuildInputs = [pkgs.zola pkgs.findutils];

      buildPhase = ''
        zola check
      '';

      installPhase = "touch $out";
    };
  in {
    packages."${system}" = {
      default = build;
    };

    checks."${system}" = {
      inherit build check;
      formatting = treefmtEval.config.build.check self;
    };

    formatter."${system}" = treefmtEval.config.build.wrapper;
  };
}
# vim: ts=2