forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
120 lines (116 loc) · 4.62 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla";
};
outputs =
{ self, nixpkgs, flake-utils, flake-compat, nixpkgs-mozilla }:
flake-utils.lib.eachSystem [
"x86_64-darwin"
"x86_64-linux"
]
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
nixpkgs-mozilla.overlays.rust
];
config.permittedInsecurePackages = [
# It's OK to depend on libdwarf 20210528, because we did not call
# the particular vulnerable function in libdwarf
"libdwarf-20210528"
];
};
devShellForPackage = hhvm:
pkgs.mkShell.override
{ stdenv = hhvm.stdenv; }
{
inputsFrom = [
hhvm
];
packages = [
pkgs.rnix-lsp
pkgs.fpm
pkgs.rpm
];
inherit (hhvm)
NIX_CFLAGS_COMPILE
CMAKE_INIT_CACHE;
};
in
rec {
packages.hhvm = pkgs.callPackage ./hhvm.nix {
lastModifiedDate = self.lastModifiedDate;
};
packages.hhvm_clang = packages.hhvm.override {
stdenv = pkgs.llvmPackages_14.stdenv;
};
packages.default = packages.hhvm;
devShells.clang = devShellForPackage packages.hhvm_clang;
devShells.default = devShellForPackage packages.hhvm;
${if pkgs.hostPlatform.isLinux then "bundlers" else null} =
let
fpmScript =
outputType: pkg:
''
# Copy to a temporary directory as a workaround to https://github.com/jordansissel/fpm/issues/807
while read LINE
do
mkdir -p "$(dirname "./$LINE")"
cp -r "/$LINE" "./$LINE"
chmod --recursive u+w "./$LINE"
FPM_INPUTS+=("./$LINE")
done < ${pkgs.lib.strings.escapeShellArg (pkgs.referencesByPopularity pkg)}
${pkgs.lib.strings.escapeShellArg pkgs.fpm}/bin/fpm \
--verbose \
--package "$out" \
--input-type dir \
--output-type ${outputType} \
--name ${pkgs.lib.strings.escapeShellArg pkg.pname} \
--version ${
pkgs.lib.strings.escapeShellArg
(builtins.replaceStrings ["-"] ["~"] pkg.version)
} \
--description ${pkgs.lib.strings.escapeShellArg pkg.meta.description} \
--url ${pkgs.lib.strings.escapeShellArg pkg.meta.homepage} \
--maintainer ${pkgs.lib.strings.escapeShellArg (pkgs.lib.strings.concatStringsSep ", " (map ({name, email, ...}: "\"${name}\" <${email}>") pkg.meta.maintainers))} \
--license ${pkgs.lib.strings.escapeShellArg (pkgs.lib.strings.concatStringsSep " AND " (map ({spdxId, ...}: spdxId) (pkgs.lib.lists.toList pkg.meta.license)))} \
--after-install ${
pkgs.writeScript "after-install.sh" ''
for EXECUTABLE in ${pkgs.lib.strings.escapeShellArg pkg}/bin/*
do
NAME=$(basename "$EXECUTABLE")
update-alternatives --install "/usr/bin/$NAME" "$NAME" "$EXECUTABLE" 1
done
''
} \
--before-remove ${
pkgs.writeScript "before-remove.sh" ''
for EXECUTABLE in ${pkgs.lib.strings.escapeShellArg pkg}/bin/*
do
NAME=$(basename "$EXECUTABLE")
update-alternatives --remove "$NAME" "$EXECUTABLE"
done
''
} \
-- \
"''${FPM_INPUTS[@]}"
'';
in
{
rpm = pkg: pkgs.runCommand
"bundle.rpm"
{ nativeBuildInputs = [ pkgs.rpm ]; }
(fpmScript "rpm" pkg);
deb = pkg: pkgs.runCommand
"bundle.deb"
{ nativeBuildInputs = [ pkg.stdenv.cc ]; }
(fpmScript "deb" pkg);
};
}
);
}