ctucx.git: gallery

static-site-generator for image-galleries [used @ photos.ctu.cx]

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 
75 
76 
77 
78 
79 
80 
81 
82 
83 
{

  description = "static-site-generator for image-galleries";

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

  outputs = inputs: let
    forAllSystems = function:
      inputs.nixpkgs.lib.genAttrs [
        "x86_64-linux"
        "aarch64-linux"
        "aarch64-darwin"
      ] (system: function (import inputs.nixpkgs {
        system   = system;
        overlays = [ inputs.self.overlays.default ];
      }));

  in {

    packages = forAllSystems (pkgs: {
      default       = pkgs.ctucx-gallery;
      ctucx-gallery = pkgs.ctucx-gallery;
    });

    apps = forAllSystems (pkgs: {
      default.type    = "app";
      default.program = "${pkgs.ctucx-gallery}/bin/gallery";
    });

    overlays.default = final: prev: {
      ctucx-gallery = let
        nimexif = final.stdenv.mkDerivation {
          name = "nimexif";
          src  = final.fetchgit {
            url    = "https://cgit.ctu.cx/nimexif";
            rev    = "c01ab3532975370c3b35b1056f52d02c7df616e0";
            sha256 = "0h3pzpm1h3gmijmfak994y98xr2my7wv31xh3b2wv1p4w8lsv3s1";
          };

          libexif = final.libexif;

          patchPhase = ''
            substituteAllInPlace nimexif/libexif_prewrapped.nim
            cp nimexif/libexif_prewrapped.nim nimexif/libexif.nim;
          '';

          installPhase = ''
            mkdir -p $out
            cp -r nimexif $out
          '';
        };

        nimjpg = final.fetchgit {
          url    = "https://cgit.ctu.cx/nimjpg";
          rev    = "cf530668cf92d9d509744b54b93bd4101a5ae6c5";
          sha256 = "03mbbs6wk67llh3ln871jwyvyl2qrv1m5rivlgmg2jlj8462m0sg";
        };

        moustachu = final.fetchFromGitHub {
          owner  = "fenekku";
          repo   = "moustachu";
          rev    = "0.14.0";
          sha256 = "16ij1igddmily9g1kbkmhv6kvmnzyhdy10ifidf32frkraypkdm3";
        };

    	in final.buildNimPackage {
        name = "ctucx.gallery";
        src  = inputs.self;

        buildInputs = [ final.libexif ];

        nimRelease = true;
        nimFlags   = [
          "--path:${nimexif}"
          "--path:${nimjpg}"
          "--path:${moustachu}/src"
        ];
      };
    };

  };

}