forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
132 lines (126 loc) · 4.94 KB
/
flake.nix
File metadata and controls
132 lines (126 loc) · 4.94 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
{
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"
];
};
in
rec {
packages.hhvm = pkgs.callPackage ./hhvm.nix {
lastModifiedDate = self.lastModifiedDate;
};
packages.default = packages.hhvm;
checks.quick = pkgs.runCommand
"hhvm-quick-test"
{
buildInputs = pkgs.lib.optionals pkgs.hostPlatform.isMacOS [
# `system_cmds` provides `sysctl`, which is used in hphp/test/run.php on macOS
pkgs.darwin.system_cmds
];
}
''
set -ex
cd ${./.}
HHVM_BIN="${packages.hhvm}/bin/hhvm" "${packages.hhvm}/bin/hhvm" hphp/test/run.php quick
mkdir $out
'';
devShells.default =
pkgs.mkShell
{
inputsFrom = [
packages.hhvm
];
packages = [
pkgs.rnix-lsp
pkgs.fpm
pkgs.rpm
];
inherit (packages.hhvm)
NIX_CFLAGS_COMPILE
CMAKE_INIT_CACHE;
};
${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)}
# Dangling symlink
rm ./nix/store/*-libgccjit-*/lib/lib
${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);
};
}
);
}