blob: 688601c093dc72d0615141d7bd13d98a35357f0a (
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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# ldgallery - A static generator which turns a collection of tagged
# pictures into a searchable web gallery.
#
# Copyright (C) 2019-2022 Pacien TRAN-GIRARD
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
{
description = "A static web gallery generator with tags";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
ldgalleryVersion = "2.1";
in rec {
packages = rec {
compiler = pkgs.haskell.lib.compose.overrideCabal (super: {
pname = "ldgallery-compiler";
version = ldgalleryVersion;
buildTools = (super.buildTools or []) ++ [ pkgs.makeWrapper ];
postInstall = ''
${super.postInstall or ""}
# wrapper for runtime dependencies registration
wrapProgram "$out/bin/ldgallery" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.imagemagick ]}
# bash completion
mkdir -p "$out/share/bash-completion/completions"
"$out/bin/ldgallery" \
--help=bash \
> "$out/share/bash-completion/completions/ldgallery"
'';
}) (pkgs.haskellPackages.callCabal2nix "" ./compiler { });
viewer = pkgs.mkYarnPackage {
pname = "ldgallery-viewer";
version = ldgalleryVersion;
src = ./viewer;
buildPhase = ''
# Make the node_module directory writable because ESLint and Webpack
# want to write in it during the build…
mv deps/ldgallery-viewer/node_modules{,links}
mkdir deps/ldgallery-viewer/node_modules
cp -r deps/ldgallery-viewer/node_modules{links/.bin,}
export HOME=/build
yarn --offline run lint
yarn --offline run build
'';
installPhase = ''
mkdir -p $out/share/ldgallery
mv deps/ldgallery-viewer/dist $out/share/ldgallery/viewer
'';
doDist = false; # no need to generate a source tarball
};
man = pkgs.stdenv.mkDerivation {
pname = "ldgallery-man";
version = ldgalleryVersion;
src = ./.;
nativeBuildInputs = with pkgs; [ pandoc ];
installPhase = ''
mkdir -p $out/share/man/man{1,7}
pandoc --standalone --to man \
"compiler/ldgallery.1.md" \
--output "$out/share/man/man1/ldgallery.1"
pandoc --standalone --to man \
"viewer/ldgallery-viewer.7.md" \
--output "$out/share/man/man7/ldgallery-viewer.7"
pandoc --standalone --to man \
"ldgallery-quickstart.7.md" \
--output "$out/share/man/man7/ldgallery-quickstart.7"
'';
};
# compiler + viewer + man pages bundle
ldgallery = pkgs.symlinkJoin {
name = "ldgallery";
version = ldgalleryVersion;
paths = [
man
(with pkgs.haskell.lib.compose; overrideCabal (super: {
prePatch = ''
# add viewer dist to compiler bundled resources
rm data/readme.md
ln -s "${viewer}/share/ldgallery/viewer" "data/"
${super.prePatch or ""}
'';
}) (justStaticExecutables compiler))
];
};
example = pkgs.stdenv.mkDerivation {
pname = "ldgallery-example";
version = ldgalleryVersion;
src = ./example;
nativeBuildInputs = [ ldgallery ];
buildPhase = ''
# Need UTF-8: https://github.com/ldgallery/ldgallery/issues/341
export LC_ALL=C.UTF-8
ldgallery --input-dir src --output-dir $out --with-viewer
'';
installPhase = ":";
};
default = ldgallery;
};
apps = rec {
ldgallery = flake-utils.lib.mkApp {
drv = packages.default;
};
default = ldgallery;
};
});
}
|