summary refs log tree commit diff
path: root/flake.nix
blob: b759c81e3be780614b58dfcb24a9b60ebe9b9414 (plain)
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
{
  description = "19 PDH Puszcza low-tech site";
  inputs.nur.url = github:nix-community/NUR;
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, nur, flake-utils }:
  flake-utils.lib.eachDefaultSystem (system:
  let
    pkgs = import nixpkgs { inherit system; overlays = [ nur.overlay ]; };
    kronika = let
      kronika_json = pkgs.lib.importJSON ./kronika.json;
    in pkgs.fetchFromGitHub {
      repo = "kronika";
      owner = "19pdh";
      rev = kronika_json.rev;
      sha256 = kronika_json.sha256;
    };


    low-puszcza = pkgs.stdenv.mkDerivation {
      name = "low-puszcza";
      src = self;
      nativeBuildInputs = [
        pkgs.zip
        pkgs.pandoc
        pkgs.nur.repos.pn.saait
      ];

      buildPhase = ''
        sed -i 's:yq:${pkgs.yq}/bin/yq:g' ./md2saait/frontmatter2cfg
        sed -i 's:rev:${pkgs.busybox}/bin/rev:g' ./md2saait/getdate

        cp ${kronika}/wpisy wpisy -r
        mkdir pages
        for f in `find wpisy -name '*.md'`; do
          name=$(basename $f .md)
          d=$(./md2saait/getdate $f)

          ./md2saait/frontmatter2cfg $f > pages/$d-$name.cfg
          pandoc $f > pages/$d-$name.html
        done
        ls pages
        make
      '';

      installPhase = ''
        cp -r output $out
      '';
    };


  in {
    defaultPackage = low-puszcza;
    packages.low-puszcza = low-puszcza;
  });
}