-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nix derivation for static builds
- Loading branch information
Showing
5 changed files
with
82 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ 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" | ||
]; | ||
}); | ||
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 []) ++ | ||
[ "--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 = [ installShellFiles pkg-config ]; | ||
buildInputs = [ glib glibc glibc.static gpgme libapparmor libassuan libgpgerror libseccomp libselinux systemd ]; | ||
prePatch = '' | ||
export LDFLAGS='-static-libgcc -static -s -w' | ||
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 . | ||
GIT_COMMIT='unknown' make binary | ||
''; | ||
installPhase = '' | ||
install -Dm755 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": "0f114432d4a9399e0b225d5be1599c7ebc5e2772", | ||
"date": "2020-05-29T19:54:08-05:00", | ||
"path": "/nix/store/ds31sjj3ppsk0xclkficx9p3w6qslmdc-nixpkgs", | ||
"sha256": "1qd2dlc5dk98y0xdahv9k72ibv5dsy10jg25xqvj38sadxbs3g0j", | ||
"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 |