Skip to content

Commit fc40a91

Browse files
authored
Merge pull request #1123 from giuseppe/nix-cleanups
few cleanups for the nix builder
2 parents b7b43e3 + 188e0ce commit fc40a91

File tree

5 files changed

+147
-16
lines changed

5 files changed

+147
-16
lines changed

.github/workflows/release.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/cache@v3
1212
with:
1313
path: .cache
14-
key: nix-v1-${{ hashFiles('nix/nixpkgs.json') }}
14+
key: nix-v1-2.12.0-${{ hashFiles('nix/nixpkgs.json') }}
1515

1616
- run: sudo apt-get update
1717

@@ -21,7 +21,7 @@ jobs:
2121
set -ex
2222
sudo mkdir -p .cache
2323
sudo mv .cache /nix
24-
if [[ -z $(ls -A /nix) ]]; then sudo docker run --rm --privileged -v /:/mnt nixos/nix:2.3.12 cp -rfT /nix /mnt/nix; fi
24+
if [[ -z $(ls -A /nix) ]]; then sudo docker run --rm --privileged -v /:/mnt nixos/nix:2.12.0 cp -rfT /nix /mnt/nix; fi
2525
sudo RUNTIME=docker SKIP_CHECKS=1 SKIP_GPG=1 build-aux/release.sh
2626
sudo mv /nix .cache
2727
sudo chown -Rf $(whoami) .cache
@@ -32,6 +32,8 @@ jobs:
3232
sudo mv /tmp/artifact/crun-*-linux-amd64-disable-systemd /tmp/artifact/crun-linux-amd64-disable-systemd
3333
sudo mv /tmp/artifact/crun-*-linux-arm64 /tmp/artifact/crun-linux-arm64
3434
sudo mv /tmp/artifact/crun-*-linux-arm64-disable-systemd /tmp/artifact/crun-linux-arm64-disable-systemd
35+
sudo mv /tmp/artifact/crun-*-linux-ppc64le /tmp/artifact/crun-linux-ppc64le
36+
sudo mv /tmp/artifact/crun-*-linux-ppc64le-disable-systemd /tmp/artifact/crun-linux-ppc64le-disable-systemd
3537
sudo mv /tmp/artifact/*.tar.gz /tmp/artifact/crun.tar.gz
3638
sudo mv /tmp/artifact/*.tar.xz /tmp/artifact/crun.tar.xz
3739
(cd /tmp/artifact; sha256sum * | sudo tee CHECKSUMS)
@@ -57,6 +59,16 @@ jobs:
5759
path: /tmp/artifact/crun-linux-arm64-disable-systemd
5860

5961
- uses: actions/upload-artifact@v3
62+
with:
63+
name: crun-linux-ppc64le
64+
path: /tmp/artifact/crun-linux-ppc64le
65+
66+
- uses: actions/upload-artifact@v2
67+
with:
68+
name: crun-linux-ppc64le-disable-systemd
69+
path: /tmp/artifact/crun-linux-ppc64le-disable-systemd
70+
71+
- uses: actions/upload-artifact@v2
6072
with:
6173
name: crun.tar.gz
6274
path: /tmp/artifact/crun.tar.gz

build-aux/release.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -xeuo pipefail
55
SKIP_GPG=${SKIP_GPG:-}
66
SKIP_CHECKS=${SKIP_CHECKS:-}
77

8+
NIX_IMAGE=${NIX_IMAGE:-nixos/nix:2.12.0}
9+
810
test -e Makefile && make distclean
911

1012
./autogen.sh
@@ -41,30 +43,44 @@ RUNTIME_EXTRA_ARGS=${RUNTIME_EXTRA_ARGS:-}
4143

4244
mkdir -p /nix
4345

44-
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} nixos/nix:2.3.12 \
45-
nix --print-build-logs --option cores 8 --option max-jobs 8 build --file nix/
46+
NIX_ARGS="--extra-experimental-features nix-command --print-build-logs --option cores $(nproc) --option max-jobs $(nproc)"
47+
48+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
49+
nix $NIX_ARGS build --file nix/
4650
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-amd64
4751

4852
rm -rf result
4953

50-
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} nixos/nix:2.3.12 \
51-
nix --print-build-logs --option cores 8 --option max-jobs 8 build --file nix/ --arg enableSystemd false
54+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
55+
nix $NIX_ARGS build --file nix/ --arg enableSystemd false
5256
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-amd64-disable-systemd
5357

5458
rm -rf result
5559

56-
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} nixos/nix:2.3.12 \
57-
nix --print-build-logs --option cores 8 --option max-jobs 8 build --file nix/default-arm64.nix
60+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
61+
nix $NIX_ARGS build --file nix/default-arm64.nix
5862
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-arm64
5963

6064
rm -rf result
6165

62-
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} nixos/nix:2.3.12 \
63-
nix --print-build-logs --option cores 8 --option max-jobs 8 build --file nix/default-arm64.nix --arg enableSystemd false
66+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
67+
nix $NIX_ARGS build --file nix/default-arm64.nix --arg enableSystemd false
6468
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-arm64-disable-systemd
6569

6670
rm -rf result
6771

72+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
73+
nix $NIX_ARGS build --file nix/default-ppc64le.nix
74+
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-ppc64le
75+
76+
rm -rf result
77+
78+
$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
79+
nix $NIX_ARGS build --file nix/default-ppc64le.nix --arg enableSystemd false
80+
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-ppc64le-disable-systemd
81+
82+
rm -rf result
83+
6884
if test x$SKIP_GPG = x; then
6985
for i in $OUTDIR/*; do
7086
gpg2 -b --armour $i

nix/default-arm64.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ let
77
};
88
config = {
99
packageOverrides = pkg: {
10+
gcrypt = (static pkg.libgcrypt);
1011
gpgme = (static pkg.gpgme);
1112
libassuan = (static pkg.libassuan);
1213
libgpgerror = (static pkg.libgpgerror);
1314
libseccomp = (static pkg.libseccomp);
14-
protobufc = (static pkg.protobufc);
1515
glib = (static pkg.glib).overrideAttrs (x: {
1616
outputs = [ "bin" "out" "dev" ];
1717
mesonFlags = [
@@ -72,11 +72,11 @@ let
7272
which
7373
];
7474
buildInputs = [
75+
gcrypt
7576
glibc
7677
glibc.static
7778
libcap
7879
libseccomp
79-
protobufc
8080
systemd
8181
yajl
8282
];
@@ -87,7 +87,7 @@ let
8787
export LDFLAGS='-s -w -static-libgcc -static'
8888
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
8989
export CRUN_LDFLAGS='-all-static'
90-
export LIBS='${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 ${protobufc}/lib/libprotobuf-c.a ${lib.getLib systemd}/lib/libsystemd.a ${yajl}/lib/libyajl_s.a'
90+
export LIBS='${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'
9191
'';
9292
buildPhase = ''
9393
patchShebangs .

nix/default-ppc64le.nix

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{ enableSystemd ? true }:
2+
let
3+
static = import ./static.nix;
4+
pkgs = (import ./nixpkgs.nix {
5+
crossSystem = {
6+
config = "powerpc64le-unknown-linux-gnu";
7+
};
8+
config = {
9+
packageOverrides = pkg: {
10+
gcrypt = (static pkg.libgcrypt);
11+
gpgme = (static pkg.gpgme);
12+
libassuan = (static pkg.libassuan);
13+
libgpgerror = (static pkg.libgpgerror);
14+
libseccomp = (static pkg.libseccomp);
15+
glib = (static pkg.glib).overrideAttrs (x: {
16+
outputs = [ "bin" "out" "dev" ];
17+
mesonFlags = [
18+
"-Ddefault_library=static"
19+
"-Ddevbindir=${placeholder ''dev''}/bin"
20+
"-Dgtk_doc=false"
21+
"-Dnls=disabled"
22+
];
23+
postInstall = ''
24+
moveToOutput "share/glib-2.0" "$dev"
25+
substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev"
26+
sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|"
27+
sed '1i#line 1 "${x.pname}-${x.version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
28+
-i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
29+
'';
30+
});
31+
libcap = (static pkg.libcap).overrideAttrs (x: {
32+
postInstall = ''
33+
mkdir -p "$doc/share/doc/${x.pname}-${x.version}"
34+
cp License "$doc/share/doc/${x.pname}-${x.version}/"
35+
mkdir -p "$pam/lib/security"
36+
mv "$lib"/lib/security "$pam/lib"
37+
'';
38+
});
39+
systemd = (static pkg.systemd).overrideAttrs (x: {
40+
outputs = [ "out" "dev" ];
41+
mesonFlags = x.mesonFlags ++ [
42+
"-Dglib=false"
43+
"-Dbpf-compiler=gcc"
44+
"-Dbpf-framework=false"
45+
"-Dstatic-libsystemd=true"
46+
];
47+
});
48+
yajl = (static pkg.yajl).overrideAttrs (x: {
49+
preConfigure = ''
50+
export CMAKE_STATIC_LINKER_FLAGS="-static"
51+
'';
52+
});
53+
zstd = pkg.zstd.overrideAttrs (x: {
54+
cmakeFlags = x.cmakeFlags ++ [ "-DZSTD_BUILD_CONTRIB:BOOL=OFF" ];
55+
preInstall = "";
56+
});
57+
};
58+
};
59+
});
60+
61+
self = with pkgs; stdenv.mkDerivation rec {
62+
name = "crun";
63+
src = ./..;
64+
vendorSha256 = null;
65+
doCheck = false;
66+
enableParallelBuilding = true;
67+
outputs = [ "out" ];
68+
nativeBuildInputs = with buildPackages; [
69+
autoreconfHook
70+
bash
71+
gitMinimal
72+
pkg-config
73+
python3
74+
which
75+
];
76+
buildInputs = [
77+
gcrypt
78+
glibc
79+
glibc.static
80+
libcap
81+
libseccomp
82+
systemd
83+
yajl
84+
];
85+
configureFlags = [ "--enable-static" ]
86+
++ lib.optional (!enableSystemd) [ "--disable-systemd" ];
87+
prePatch = ''
88+
export CFLAGS='-static -pthread'
89+
export LDFLAGS='-s -w -static-libgcc -static'
90+
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
91+
export CRUN_LDFLAGS='-all-static'
92+
export LIBS='${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'
93+
'';
94+
buildPhase = ''
95+
patchShebangs .
96+
make
97+
'';
98+
installPhase = ''
99+
install -Dm755 crun $out/bin/crun
100+
'';
101+
};
102+
in
103+
self

nix/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ let
44
pkgs = (import ./nixpkgs.nix {
55
config = {
66
packageOverrides = pkg: {
7+
gcrypt = (static pkg.libgcrypt);
78
criu = (static pkg.criu);
89
gpgme = (static pkg.gpgme);
910
libassuan = (static pkg.libassuan);
1011
libgpgerror = (static pkg.libgpgerror);
1112
libseccomp = (static pkg.libseccomp);
12-
protobufc = (static pkg.protobufc);
1313
glib = (static pkg.glib).overrideAttrs (x: {
1414
outputs = [ "bin" "out" "dev" ];
1515
mesonFlags = [
@@ -59,12 +59,12 @@ let
5959
which
6060
];
6161
buildInputs = [
62+
gcrypt
6263
criu
6364
glibc
6465
glibc.static
6566
libcap
6667
libseccomp
67-
protobufc
6868
systemd
6969
yajl
7070
];
@@ -75,7 +75,7 @@ let
7575
export LDFLAGS='-s -w -static-libgcc -static'
7676
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
7777
export CRUN_LDFLAGS='-all-static'
78-
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 ${protobufc}/lib/libprotobuf-c.a ${lib.getLib systemd}/lib/libsystemd.a ${yajl}/lib/libyajl_s.a'
78+
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'
7979
'';
8080
buildPhase = ''
8181
patchShebangs .

0 commit comments

Comments
 (0)