-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
91 lines (84 loc) · 2.55 KB
/
flake.nix
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
# SPDX-FileCopyrightText: 2022 localthomas
#
# SPDX-License-Identifier: MIT OR Apache-2.0
{
description = "Template for Pandoc Markdown development";
inputs = {
# for eachSystem function
flake-utils.url = "github:numtide/flake-utils";
# use flake-compat as side-effect for flake.lock file that is read by shell.nix
# fill the flake.lock file with `nix flake lock --update-input flake-compat`
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
pandoc-drawio = {
url = "github:localthomas/pandoc-drawio";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, pandoc-drawio, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
};
pandoc-drawio-bin = pandoc-drawio.defaultPackage.${system};
in
with pkgs;
{
devShell = mkShell {
nativeBuildInputs = [
nixpkgs-fmt
go
texlive.combined.scheme-full
pandoc-drawio-bin
pandoc
librsvg
haskellPackages.pandoc-crossref
];
};
packages.pdf = stdenv.mkDerivation {
name = "pdf";
src = self;
nativeBuildInputs = [ self.devShell.${system}.nativeBuildInputs ];
buildPhase = ''
ln -s ${bash}/bin/bash /bin/bash;
./build-pdf.sh;
'';
installPhase = ''
# copy PDF file(s)
mkdir -p $out/pdf
cp --verbose --recursive ./out/pdf $out;
'';
};
packages.html = stdenv.mkDerivation {
name = "html";
src = self;
nativeBuildInputs = [ self.devShell.${system}.nativeBuildInputs ];
buildPhase = ''
ln -s ${bash}/bin/bash /bin/bash;
./build-html.sh;
'';
installPhase = ''
# copy HTML file(s)
mkdir -p $out/html
cp --verbose --recursive ./out/html $out;
'';
};
# merge PDF and HTML outputs
defaultPackage = stdenv.mkDerivation {
name = "pdf-and-html";
src = self;
installPhase = ''
# copy HTML file(s)
mkdir -p $out/html
cp --verbose --recursive ${self.packages.${system}.html}/html $out;
# copy PDF file(s)
mkdir -p $out/pdf
cp --verbose --recursive ${self.packages.${system}.pdf}/pdf $out;
'';
};
}
);
}