-
Notifications
You must be signed in to change notification settings - Fork 787
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2380: [nix] Add nix derivation for static builds r=rhatdan a=hswong3i #### What type of PR is this? <!-- Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. Uncomment only one `/kind <>` line, hit enter to put that in a new line, and remove leading whitespace from that line: --> > /kind feature #### What this PR does / why we need it: Similar PR goes for crun/conmon/libpod/cri-o/etc, too. Also see: - ~~containers/crun#372 - ~~containers/conmon#161 - containers/skopeo#932 - #2380 - containers/podman#6402 - cri-o/cri-o#3804 Static binaries: - [crun-0.13-linux-amd64](https://github.com/alvistack/crun/releases/download/0.13/crun-0.13-linux-amd64) - [conmon-v2.0.17-linux-amd64](https://github.com/alvistack/conmon/releases/download/v2.0.17/conmon-v2.0.17-linux-amd64) - [skopeo-v1.0.0-linux-amd64](https://github.com/alvistack/skopeo/releases/download/v1.0.0/skopeo-v1.0.0-linux-amd64) - [buildah-v1.14.9-linux-amd64](https://github.com/alvistack/buildah/releases/download/v1.14.9/buildah-v1.14.9-linux-amd64) - [podman-v1.9.3-linux-amd64](https://github.com/alvistack/libpod/releases/download/v1.9.3/podman-v1.9.3-linux-amd64) - [cri-o-v1.17.4-linux-amd64.tar.gz](https://github.com/alvistack/cri-o/releases/download/v1.17.4/cri-o-v1.17.4-linux-amd64.tar.gz) - [cri-o-v1.18.1-linux-amd64.tar.gz](https://github.com/alvistack/cri-o/releases/download/v1.18.1/cri-o-v1.18.1-linux-amd64.tar.gz) Ansible Roles: - https://github.com/alvistack/ansible-role-crun - https://github.com/alvistack/ansible-role-conmon - https://github.com/alvistack/ansible-role-skopeo - https://github.com/alvistack/ansible-role-buildah - https://github.com/alvistack/ansible-role-podman - https://github.com/alvistack/ansible-role-cri_o #### How to verify it ``` nix build -f nix/ ``` #### Which issue(s) this PR fixes: <!-- Automatically closes linked issue when PR is merged. Uncomment the following comment block and include the issue number or None on one line. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`, or `None`. --> <!-- Fixes # or None --> #### Special notes for your reviewer: Here I skip the btrfs and lvm2 support for static binary, because: 1. btrfs will not support in CentOS 8 2. With skopeo experience both btrfs and lvm2 are not easy for compile as static binary Also see: - containers/podman#6402 (comment) #### Does this PR introduce a user-facing change? <!-- If no, just write `None` in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". For more information on release notes please follow the kubernetes model: https://git.k8s.io/community/contributors/guide/release-notes.md --> ```release-note ``` Co-authored-by: Wong Hoi Sing Edison <[email protected]>
- Loading branch information
Showing
10 changed files
with
98 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ tests/tools/build | |
Dockerfile* | ||
!/tests/bud/*/Dockerfile* | ||
*.swp | ||
result |
This file contains 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 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 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 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,53 @@ | ||
{ system ? builtins.currentSystem }: | ||
let | ||
pkgs = (import ./nixpkgs.nix { | ||
config = { | ||
packageOverrides = pkg: { | ||
gpgme = (static pkg.gpgme); | ||
libassuan = (static pkg.libassuan); | ||
libgpgerror = (static pkg.libgpgerror); | ||
libseccomp = (static pkg.libseccomp); | ||
glib = pkg.glib.overrideAttrs(x: { | ||
outputs = [ "bin" "out" "dev" ]; | ||
mesonFlags = [ | ||
"-Ddefault_library=static" | ||
"-Ddevbindir=${placeholder ''dev''}/bin" | ||
"-Dgtk_doc=false" | ||
"-Dnls=disabled" | ||
]; | ||
}); | ||
}; | ||
}; | ||
}); | ||
|
||
static = pkg: pkg.overrideAttrs(x: { | ||
configureFlags = (x.configureFlags or []) ++ | ||
[ "--without-shared" "--disable-shared" ]; | ||
dontDisableStatic = true; | ||
enableSharedExecutables = false; | ||
enableStatic = true; | ||
}); | ||
|
||
self = with pkgs; buildGoPackage rec { | ||
name = "buildah"; | ||
src = ./..; | ||
goPackagePath = "github.com/containers/buildah"; | ||
doCheck = false; | ||
enableParallelBuilding = true; | ||
nativeBuildInputs = [ git installShellFiles pkg-config ]; | ||
buildInputs = [ glib glibc glibc.static gpgme libapparmor libassuan libgpgerror libseccomp libselinux ]; | ||
prePatch = '' | ||
export LDFLAGS='-s -w -static-libgcc -static' | ||
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"' | ||
export BUILDTAGS='static netgo apparmor selinux seccomp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper' | ||
''; | ||
buildPhase = '' | ||
pushd go/src/${goPackagePath} | ||
patchShebangs . | ||
make bin/buildah | ||
''; | ||
installPhase = '' | ||
install -Dm755 bin/buildah $out/bin/buildah | ||
''; | ||
}; | ||
in self |
This file contains 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": "78e324d2726127828a15f87a75b4d3199a8955ec", | ||
"date": "2020-06-16T18:23:14-07:00", | ||
"path": "/nix/store/bwhp0061k3fk00j8fskpfak261jdcjl6-nixpkgs", | ||
"sha256": "1j58aa9ngdmvbnds4x4a497nynj390dzqyb5yrvmhjc7k9anq6jm", | ||
"fetchSubmodules": false, | ||
"deepClone": false, | ||
"leaveDotGit": false | ||
} |
This file contains 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 |
This file contains 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 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