aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorpacien2022-09-04 18:18:27 +0200
committerpacien2022-09-04 18:18:27 +0200
commit11bbbae2850b9c45da697a8ed9626495a50a38c0 (patch)
treeff2713118f8b45d36905bfea2933f08d8e70066d /flake.nix
parente93f7b1eb84c083d67567115284c0002a3a7d5fc (diff)
parent8349be992b46b77dee921f484cfbff8b758ff756 (diff)
downloadldgallery-11bbbae2850b9c45da697a8ed9626495a50a38c0.tar.gz
Merge branch 'develop': release v2.1v2.1
GitHub: related to #315
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix131
1 files changed, 131 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..99221c7
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,131 @@
1# ldgallery - A static generator which turns a collection of tagged
2# pictures into a searchable web gallery.
3#
4# Copyright (C) 2019-2022 Pacien TRAN-GIRARD
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19{
20 description = "A static web gallery generator with tags";
21
22 inputs = {
23 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
24 flake-utils.url = "github:numtide/flake-utils";
25 };
26
27 outputs = { self, nixpkgs, flake-utils }:
28 flake-utils.lib.eachDefaultSystem (system: let
29 pkgs = import nixpkgs { inherit system; };
30 ldgalleryVersion = "2.1";
31
32 in rec {
33 packages = rec {
34 compiler = pkgs.haskell.lib.compose.overrideCabal (super: {
35 pname = "ldgallery-compiler";
36 version = ldgalleryVersion;
37
38 buildTools = (super.buildTools or []) ++ [ pkgs.makeWrapper ];
39
40 postInstall = ''
41 ${super.postInstall or ""}
42
43 # wrapper for runtime dependencies registration
44 wrapProgram "$out/bin/ldgallery" \
45 --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.imagemagick ]}
46
47 # bash completion
48 mkdir -p "$out/share/bash-completion/completions"
49 "$out/bin/ldgallery" \
50 --help=bash \
51 > "$out/share/bash-completion/completions/ldgallery"
52 '';
53 }) (pkgs.haskellPackages.callCabal2nix "" ./compiler { });
54
55 viewer = pkgs.mkYarnPackage {
56 pname = "ldgallery-viewer";
57 version = ldgalleryVersion;
58 src = ./viewer;
59
60 buildPhase = ''
61 # Make the node_module directory writable because ESLint and Webpack
62 # want to write in it during the build…
63 mv deps/ldgallery-viewer/node_modules{,links}
64 mkdir deps/ldgallery-viewer/node_modules
65 cp -r deps/ldgallery-viewer/node_modules{links/.bin,}
66
67 export HOME=/build
68 yarn --offline run lint
69 yarn --offline run build
70 '';
71
72 installPhase = ''
73 mkdir -p $out/share/ldgallery
74 mv deps/ldgallery-viewer/dist $out/share/ldgallery/viewer
75 '';
76
77 doDist = false; # no need to generate a source tarball
78 };
79
80 man = pkgs.stdenv.mkDerivation {
81 pname = "ldgallery-man";
82 version = ldgalleryVersion;
83 src = ./.;
84
85 nativeBuildInputs = with pkgs; [ pandoc ];
86 installPhase = ''
87 mkdir -p $out/share/man/man{1,7}
88
89 pandoc --standalone --to man \
90 "compiler/ldgallery.1.md" \
91 --output "$out/share/man/man1/ldgallery.1"
92
93 pandoc --standalone --to man \
94 "viewer/ldgallery-viewer.7.md" \
95 --output "$out/share/man/man7/ldgallery-viewer.7"
96
97 pandoc --standalone --to man \
98 "ldgallery-quickstart.7.md" \
99 --output "$out/share/man/man7/ldgallery-quickstart.7"
100 '';
101 };
102
103 # compiler + viewer + man pages bundle
104 ldgallery = pkgs.symlinkJoin {
105 name = "ldgallery";
106 version = ldgalleryVersion;
107 paths = [
108 man
109 (with pkgs.haskell.lib.compose; overrideCabal (super: {
110 prePatch = ''
111 # add viewer dist to compiler bundled resources
112 rm data/readme.md
113 ln -s "${viewer}/share/ldgallery/viewer" "data/"
114 ${super.prePatch or ""}
115 '';
116 }) (justStaticExecutables compiler))
117 ];
118 };
119
120 default = ldgallery;
121 };
122
123 apps = rec {
124 ldgallery = flake-utils.lib.mkApp {
125 drv = packages.default;
126 };
127
128 default = ldgallery;
129 };
130 });
131}