-
Notifications
You must be signed in to change notification settings - Fork 408
Add nix derivation for static builds #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ m4/ltversion.m4 | |
| m4/lt~obsolete.m4 | ||
| Makefile | ||
| Makefile.in | ||
| result | ||
| rpm/crun.spec | ||
| stamp-h | ||
| stamp-h.in | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,6 @@ | ||
| FROM fedora AS base | ||
| RUN dnf install -y git dnf-utils gcc meson ninja-build libcap-static \ | ||
| make python git gcc automake autoconf libcap-devel systemd-devel yajl-devel libseccomp-devel cmake \ | ||
| go-md2man glibc-static python3-libmount libtool diffutils gperf | ||
|
|
||
| FROM base AS systemd | ||
| RUN mkdir /out && yum-builddep -y systemd && git clone --depth 1 https://github.com/systemd/systemd.git \ | ||
| && mkdir systemd/build; cd systemd/build; meson .. -Dselinux=false --buildtype minsize --strip; ninja version.h; ninja libsystemd.a; cp libsystemd.a /out | ||
|
|
||
| FROM base AS yajl | ||
| RUN mkdir /out && git clone --depth=1 https://github.com/lloyd/yajl.git; cd yajl; ./configure LDFLAGS=-static; cd build; make -j $(nproc); find . -name '*.a' -exec cp \{\} /out \; | ||
|
|
||
| FROM base AS seccomp | ||
| RUN mkdir /out && git clone --depth=1 https://github.com/seccomp/libseccomp.git; cd libseccomp; ./autogen.sh; ./configure --enable-static; make -j $(nproc); find . -name '*.a' -exec cp \{\} /out \; | ||
|
|
||
| FROM base | ||
| COPY --from=systemd /out/* /usr/lib64/ | ||
| COPY --from=yajl /out/* /usr/lib64/ | ||
| COPY --from=seccomp /out/* /usr/lib64/ | ||
| COPY build.sh /usr/bin/build.sh | ||
| CMD /usr/bin/build.sh | ||
| FROM nixos/nix | ||
| COPY . /crun | ||
| WORKDIR crun/nix | ||
| RUN nix-build | ||
| WORKDIR / | ||
| RUN rm -rf crun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { system ? builtins.currentSystem }: | ||
| let | ||
| pkgs = (import ./nixpkgs.nix { | ||
| config = { | ||
| packageOverrides = pkg: { | ||
| 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" | ||
| ''; | ||
| }); | ||
| libseccomp = (static pkg.libseccomp); | ||
| protobufc = (static pkg.protobufc); | ||
| systemd = pkg.systemd.overrideAttrs(x: { | ||
| mesonFlags = x.mesonFlags ++ [ "-Dstatic-libsystemd=true" ]; | ||
| postFixup = '' | ||
| ${x.postFixup} | ||
| sed -ri "s;$out/(.*);$nukedRef/\1;g" $lib/lib/libsystemd.a | ||
| ''; | ||
| }); | ||
| }; | ||
| }; | ||
| }); | ||
|
|
||
| static = pkg: pkg.overrideAttrs(x: { | ||
| configureFlags = (x.configureFlags or []) ++ [ "--disable-shared" ]; | ||
| enableStatic = true; | ||
| }); | ||
|
|
||
| self = with pkgs; { | ||
| crun-static = (crun.overrideAttrs(x: { | ||
| name = "crun-static"; | ||
| src = ./..; | ||
| doCheck = false; | ||
| nativeBuildInputs = [ autoreconfHook pkgconfig python3 ]; | ||
| buildInputs = x.buildInputs ++ [ criu glibc glibc.static ]; | ||
| configureFlags = [ "--enable-static-nss" ]; | ||
| prePatch = '' | ||
| export LDFLAGS="-static-libgcc -static" | ||
| 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 \ | ||
| ${libcap.lib}/lib/libcap.a \ | ||
| ${libseccomp.lib}/lib/libseccomp.a \ | ||
| ${protobufc}/lib/libprotobuf-c.a \ | ||
| ${protobuf}/lib/libprotobuf.a \ | ||
| ${systemd.lib}/lib/libsystemd.a \ | ||
| ${yajl}/lib/libyajl_s.a \ | ||
| " | ||
| echo "Using static libs: $LIBS" | ||
| ''; | ||
| })).override { | ||
| yajl = yajl.overrideAttrs(x: { | ||
| buildInputs = [ glibc glibc.static ]; | ||
| preConfigure = '' | ||
| export CMAKE_STATIC_LINKER_FLAGS="-static" | ||
| ''; | ||
| }); | ||
| }; | ||
| }; | ||
| in self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "url": "https://github.com/nixos/nixpkgs", | ||
| "rev": "2b51171fb6eadbe0909dc5f3726371a149044f77", | ||
| "date": "2020-05-13T14:24:04+02:00", | ||
| "path": "/nix/store/dnv2wqnkssh7ph5r9gbxv6gxp8ykkqn4-nixpkgs", | ||
| "sha256": "1f76j4m05sbypc1s9lbdbdp62slryvknsi78ilrb3lnmq17biymi", | ||
| "fetchSubmodules": false, | ||
| "deepClone": false, | ||
| "leaveDotGit": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| let | ||
| json = builtins.fromJSON (builtins.readFile ./nixpkgs.json); | ||
| nixpkgs = import (builtins.fetchTarball { | ||
| name = "nixos-unstable"; | ||
| url = "${json.url}/archive/${json.rev}.tar.gz"; | ||
| inherit (json) sha256; | ||
| }); | ||
| in nixpkgs |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nix build process already strips