Skip to content

Commit cba225c

Browse files
committed
Cleanup nix derivation for static builds
1 parent ca37d05 commit cba225c

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

nix/default.nix

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ let
33
pkgs = (import ./nixpkgs.nix {
44
config = {
55
packageOverrides = pkg: {
6+
libseccomp = (static pkg.libseccomp);
7+
protobufc = (static pkg.protobufc);
68
libcap = (static pkg.libcap).overrideAttrs(x: {
79
postInstall = ''
810
mkdir -p "$doc/share/doc/${x.pname}-${x.version}"
@@ -11,8 +13,11 @@ let
1113
mv "$lib"/lib/security "$pam/lib"
1214
'';
1315
});
14-
libseccomp = (static pkg.libseccomp);
15-
protobufc = (static pkg.protobufc);
16+
yajl = (static pkg.yajl).overrideAttrs(x: {
17+
preConfigure = ''
18+
export CMAKE_STATIC_LINKER_FLAGS="-static"
19+
'';
20+
});
1621
systemd = pkg.systemd.overrideAttrs(x: {
1722
mesonFlags = x.mesonFlags ++ [ "-Dstatic-libsystemd=true" ];
1823
postFixup = ''
@@ -25,7 +30,10 @@ let
2530
});
2631

2732
static = pkg: pkg.overrideAttrs(x: {
28-
configureFlags = (x.configureFlags or []) ++ [ "--disable-shared" ];
33+
configureFlags = (x.configureFlags or []) ++
34+
[ "--without-shared" "--disable-shared" ];
35+
dontDisableStatic = true;
36+
enableSharedExecutables = false;
2937
enableStatic = true;
3038
});
3139

@@ -34,8 +42,15 @@ let
3442
name = "crun-static";
3543
src = ./..;
3644
doCheck = false;
37-
nativeBuildInputs = [ autoreconfHook pkgconfig python3 ];
38-
buildInputs = x.buildInputs ++ [ criu glibc glibc.static ];
45+
buildInputs = [
46+
criu
47+
glibc
48+
glibc.static
49+
libcap
50+
libseccomp
51+
systemd
52+
yajl
53+
];
3954
configureFlags = [ "--enable-static-nss" ];
4055
prePatch = ''
4156
export LDFLAGS="-static-libgcc -static"
@@ -52,15 +67,7 @@ let
5267
${systemd.lib}/lib/libsystemd.a \
5368
${yajl}/lib/libyajl_s.a \
5469
"
55-
echo "Using static libs: $LIBS"
5670
'';
57-
})).override {
58-
yajl = yajl.overrideAttrs(x: {
59-
buildInputs = [ glibc glibc.static ];
60-
preConfigure = ''
61-
export CMAKE_STATIC_LINKER_FLAGS="-static"
62-
'';
63-
});
64-
};
71+
}));
6572
};
6673
in self

nix/nixpkgs.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

nix/nixpkgs.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
let
2-
json = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
32
nixpkgs = import (builtins.fetchTarball {
43
name = "nixos-unstable";
5-
url = "${json.url}/archive/${json.rev}.tar.gz";
6-
inherit (json) sha256;
4+
url = "https://github.com/NixOS/nixpkgs/archive/260b2af29281cfc1e5d2ea7ae8dbb1e38a16e896.tar.gz";
5+
sha256 = "0h70dn8sx60976gycifg5c0dd1pfgclw1vdhazbcniywb1bdsll3";
76
});
87
in nixpkgs

0 commit comments

Comments
 (0)