-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
90 lines (83 loc) · 2.58 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
pnpm2nix = {
url = "github:nzbr/pnpm2nix-nzbr";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, pnpm2nix, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
python = pkgs.python3.withPackages (pypi: with pypi; [
panflute
pylint
]);
in
{
packages = rec {
pandocode = pkgs.stdenv.mkDerivation rec {
name = "pandocode";
src = ./.;
buildInputs = [ python pkgs.zip pkgs.which ];
buildPhase = ''
make -j$NIX_BUILD_CORES PY=${python}/bin/python3
'';
installPhase = ''
mkdir -p $out/bin
install -m755 pandocode.pyz $out/bin/pandocode
'';
};
pandocode-live-frontend = pnpm2nix.packages.${system}.mkPnpmPackage {
src = ./live/www;
extraBuildInputs = [ pkgs.vips ];
installInPlace = true;
};
pandocode-live = pkgs.dockerTools.buildLayeredImage {
name = "pandocode-live";
tag = "latest";
contents = [
pkgs.lighttpd
pkgs.pandoc
pkgs.poppler_utils
(pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-basic algorithmicx xcolor standalone preview fancyvrb;
})
(pkgs.writeShellScriptBin "python-wrapper" ''
export PYTHONPATH=${./.}
export PATH=/bin:${pandocode}/bin
exec ${pkgs.python3.withPackages (pypi: with pypi; [
panflute
pdf2image
pillow
numpy
])}/bin/python3 "$@"
'')
(pkgs.runCommand "content" { } ''
mkdir -p $out/var/www
cp -vr ${pandocode-live-frontend}/. $out/var/www/
cp -vr ${./live/cgi-bin}/. $out/var/www/cgi-bin
cp -vr ${./live/etc}/. $out/etc
'')
];
enableFakechroot = true;
fakeRootCommands = ''
mkdir -p /root /etc /tmp
echo 'root:x:0:0::/root:/noshell' > /etc/passwd
'';
config = {
Cmd = [ "/bin/lighttpd" "-D" "-f" "/etc/lighttpd.conf" ];
Env = [ "" ];
ExposedPorts = {
"8080/tcp" = { };
};
};
};
};
}
);
}