aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2022-09-04 14:29:57 +0200
committerpacien2022-09-04 14:29:57 +0200
commit0af7a59d2b49795bffe858c4ae71abf0c41ad150 (patch)
tree2be5ec4eb9a5f598c57df4b2fd8b7d48707cc2cc
parent0babb9a7e4fe29ecbf41655ade8b1c04c79dac27 (diff)
parent79fd9e8be8618d69ebb9e50d82aa0eccac05a4e7 (diff)
downloadldgallery-0af7a59d2b49795bffe858c4ae71abf0c41ad150.tar.gz
Merge branch 'nix-flake' into develop
-rw-r--r--.gitignore3
-rw-r--r--flake.lock43
-rw-r--r--flake.nix131
-rw-r--r--readme.md29
4 files changed, 202 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 2cdb78d..2f11fd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,6 @@
4 4
5# editor and IDE 5# editor and IDE
6.idea 6.idea
7
8# Nix output symlinks
9/result*
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..45b4c6d
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,43 @@
1{
2 "nodes": {
3 "flake-utils": {
4 "locked": {
5 "lastModified": 1659877975,
6 "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
7 "owner": "numtide",
8 "repo": "flake-utils",
9 "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
10 "type": "github"
11 },
12 "original": {
13 "owner": "numtide",
14 "repo": "flake-utils",
15 "type": "github"
16 }
17 },
18 "nixpkgs": {
19 "locked": {
20 "lastModified": 1662019588,
21 "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
22 "owner": "NixOS",
23 "repo": "nixpkgs",
24 "rev": "2da64a81275b68fdad38af669afeda43d401e94b",
25 "type": "github"
26 },
27 "original": {
28 "owner": "NixOS",
29 "ref": "nixos-unstable",
30 "repo": "nixpkgs",
31 "type": "github"
32 }
33 },
34 "root": {
35 "inputs": {
36 "flake-utils": "flake-utils",
37 "nixpkgs": "nixpkgs"
38 }
39 }
40 },
41 "root": "root",
42 "version": 7
43}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..36c1b4a
--- /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 = "3.0.0-SNAPSHOT";
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}
diff --git a/readme.md b/readme.md
index 955ebe6..b363490 100644
--- a/readme.md
+++ b/readme.md
@@ -1,13 +1,34 @@
1ldgallery 1ldgallery
2========= 2=========
3 3
4A static gallery generator which turns a collection of tagged pictures and media into a searchable web gallery. 4A static gallery generator which turns a collection of tagged pictures and
5media into a searchable web gallery.
5 6
6The complete list of features, the user manual, demo and download links can be found on the project's website: https://ldgallery.pacien.org. 7The complete list of features, the user manual, demo and download links can be
8found on the project's website: <https://ldgallery.pacien.org>.
7 9
8 10
9Build 11Usage and build (using the Nix Flake)
10----- 12-------------------------------------
13
14This program is available as a Nix Flake allowing to build both the viewer
15and compiler components and assemble those automatically.
16
17The following commands are available on NixOS, or a Linux or MacOS system
18having the Nix package manager installed:
19
20* Just running the program (compiler with bundled viewer):
21 * Using the latest release: `nix run github:ldgallery/ldgallery -- --help`
22 * Using a local source checkout: `nix run .# -- --help`
23
24* Building individual components locally:
25 `nix build .#{compiler,viewer,man} --print-build-logs`
26
27
28Manual build
29------------
30
31Without using the Nix Flake, the project can be built as follows:
11 32
12* Compile the web _viewer_ as detailed in `./viewer/readme.md`. 33* Compile the web _viewer_ as detailed in `./viewer/readme.md`.
13* Copy/link the compiled _viewer_ to the _ldgallery compiler_ data directory. 34* Copy/link the compiled _viewer_ to the _ldgallery compiler_ data directory.