-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
default.nix
88 lines (71 loc) · 2.24 KB
/
default.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
{ repo ? builtins.fetchGit ./.
, versionFile ? ./.version
, officialRelease ? false
, nixpkgs ? null
, config ? {}
, system ? builtins.currentSystem
}:
with builtins;
let
bootstrap = import ./nix/bootstrap.nix {
inherit nixpkgs config system;
inherit repo officialRelease versionFile;
};
in
with bootstrap.pkgs;
stdenv.mkDerivation rec {
pname = "eris";
inherit (bootstrap) version relname;
src = lib.cleanSource ./.;
buildInputs =
[ perl nix nix.perl-bindings glibcLocales
] ++ (with perlPackages;
[ Mojolicious MojoliciousPluginStatus IOSocketSSL
DBI DBDSQLite
]);
outputs = [ "out" "man" ];
unpackPhase = ":";
installPhase = with perlPackages; ''
mkdir -p \
$out/bin $out/libexec $out/lib/systemd/system \
$man/share/man/man8/
# Install the man page
substitute ${./eris.8.pod.in} ./eris.8.pod \
--subst-var-by VERSION "${version}"
pod2man \
--section=8 \
--name="ERIS" \
--center="Eris User Manual" \
./eris.8.pod > $man/share/man/man8/eris.8
# Install the systemd files
substitute ${./conf/eris.service.in} $out/lib/systemd/system/eris.service \
--subst-var-by NIXOUT "$out"
# Strip the nix-shell shebang lines out of the main script
grep -v '#!.*nix-shell' ${./eris.pl} > $out/libexec/eris.pl
# Set up accurate version information, xz utils
substituteInPlace $out/libexec/eris.pl \
--replace '"0xERISVERSION"' '"${version}"' \
--replace '"0xERISRELNAME"' '"${relname}"' \
--replace '"xz"' '"${xz.bin}/bin/xz"' \
--replace '"bzip2"' '"${bzip2.bin}/bin/bzip2"'
# Create the binary and set permissions
touch $out/bin/eris
chmod +x $out/bin/eris
# Wrapper that properly sets PERL5LIB
cat > $out/bin/eris <<EOF
#! ${stdenv.shell}
set -e
PERL5LIB=$PERL5LIB \
LOCALE_ARCHIVE=$LOCALE_ARCHIVE \
LIBEV_FLAGS="\''${LIBEV_FLAGS:-12}" \
exec ${Mojolicious}/bin/hypnotoad $out/libexec/eris.pl "\$@"
EOF
'';
meta = with lib; {
description = "A binary cache server for Nix";
homepage = https://github.com/thoughtpolice/eris;
license = licenses.gpl3Plus;
platforms = platforms.linux;
maintainers = [ maintainers.thoughtpolice ];
};
}