forked from containers/crun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default-amd64.nix
89 lines (88 loc) · 2.63 KB
/
default-amd64.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
{ system ? builtins.currentSystem, enableSystemd ? true }:
let
static = import ./static.nix;
pkgs = (import ./nixpkgs.nix {
config = {
packageOverrides = pkg: {
gcrypt = (static pkg.libgcrypt);
criu = (static pkg.criu);
gpgme = (static pkg.gpgme);
libassuan = (static pkg.libassuan);
libgpgerror = (static pkg.libgpgerror);
libseccomp = (static pkg.libseccomp);
glib = (static pkg.glib).overrideAttrs (x: {
outputs = [ "bin" "out" "dev" ];
mesonFlags = [
"-Ddefault_library=static"
"-Ddevbindir=${placeholder ''dev''}/bin"
"-Dgtk_doc=false"
"-Dnls=disabled"
];
});
libcap = (static pkg.libcap).overrideAttrs (x: {
postInstall = ''
mkdir -p "$doc/share/doc/${x.pname}-${x.version}"
cp License "$doc/share/doc/${x.pname}-${x.version}/"
mkdir -p "$pam/lib/security"
mv "$lib"/lib/security "$pam/lib"
'';
});
systemd = (static pkg.systemd).overrideAttrs (x: {
outputs = [ "out" "dev" ];
mesonFlags = x.mesonFlags ++ [
"-Dglib=false"
"-Dstatic-libsystemd=true"
];
});
yajl = (static pkg.yajl).overrideAttrs (x: {
preConfigure = ''
export CMAKE_STATIC_LINKER_FLAGS="-static"
'';
});
};
};
});
self = with pkgs; stdenv.mkDerivation rec {
name = "crun";
src = ./..;
vendorSha256 = null;
doCheck = false;
enableParallelBuilding = true;
outputs = [ "out" ];
nativeBuildInputs = [
autoreconfHook
bash
gitMinimal
pkg-config
python3
which
];
buildInputs = [
gcrypt
criu
glibc
glibc.static
libcap
libseccomp
systemd
yajl
];
configureFlags = [ "--enable-static" ]
++ lib.optional (!enableSystemd) [ "--disable-systemd" ];
prePatch = ''
export CFLAGS='-static -pthread'
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export CRUN_LDFLAGS='-all-static'
export LIBS='${criu}/lib/libcriu.a ${glibc.static}/lib/libc.a ${glibc.static}/lib/libpthread.a ${glibc.static}/lib/librt.a ${lib.getLib libcap}/lib/libcap.a ${lib.getLib libseccomp}/lib/libseccomp.a ${lib.getLib systemd}/lib/libsystemd.a ${yajl}/lib/libyajl_s.a ${gcrypt}/lib/libgcrypt.a'
'';
buildPhase = ''
patchShebangs .
make
'';
installPhase = ''
install -Dm755 crun $out/bin/crun
'';
};
in
self