summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2020-03-20 10:55:23 +0100
committerSascha Grunert <sgrunert@suse.com>2020-05-11 13:11:07 +0200
commitc21258b70ed91ab5ff8b1d345123fed1011a49c9 (patch)
treed5f74fb3191ee33f8565f18971cf37426e57afa6 /nix
parent18b273b72ba76d485eb1b4d5df48bff1685953ff (diff)
downloadpodman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.tar.gz
podman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.tar.bz2
podman-c21258b70ed91ab5ff8b1d345123fed1011a49c9.zip
Add podman static build
We’re now able to build a static podman binary based on a custom nix derivation. This is integrated in cirrus as well, whereas a later target would be to provide a self-contained static binary bundle which can be installed on any Linux x64-bit system. Fixes: https://github.com/containers/libpod/issues/1399 Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Diffstat (limited to 'nix')
-rw-r--r--nix/default.nix53
-rw-r--r--nix/nixpkgs.json9
-rw-r--r--nix/nixpkgs.nix8
3 files changed, 70 insertions, 0 deletions
diff --git a/nix/default.nix b/nix/default.nix
new file mode 100644
index 000000000..211caee93
--- /dev/null
+++ b/nix/default.nix
@@ -0,0 +1,53 @@
+let
+ pkgs = import ./nixpkgs.nix {
+ config = {
+ packageOverrides = pkg: {
+ go_1_12 = pkg.go_1_14;
+ };
+ };
+ };
+
+ static = pkg: pkg.overrideAttrs(old: {
+ configureFlags = (old.configureFlags or []) ++
+ [ "--without-shared" "--disable-shared" ];
+ dontDisableStatic = true;
+ enableSharedExecutables = false;
+ enableStatic = true;
+ });
+
+ patchLvm2 = pkg: pkg.overrideAttrs(old: {
+ configureFlags = [
+ "--disable-cmdlib" "--disable-readline" "--disable-udev_rules"
+ "--disable-udev_sync" "--enable-pkgconfig" "--enable-static_link"
+ ];
+ preConfigure = old.preConfigure + ''
+ substituteInPlace libdm/Makefile.in --replace \
+ SUBDIRS=dm-tools SUBDIRS=
+ substituteInPlace tools/Makefile.in --replace \
+ "TARGETS += lvm.static" ""
+ substituteInPlace tools/Makefile.in --replace \
+ "INSTALL_LVM_TARGETS += install_tools_static" ""
+ '';
+ postInstall = "";
+ });
+
+ self = {
+ podman-static = (pkgs.podman.overrideAttrs(old: {
+ name = "podman-static";
+ buildInputs = old.buildInputs ++ (with pkgs; [
+ (static pkgs.libassuan)
+ (static pkgs.libgpgerror)
+ git
+ glibc
+ glibc.static
+ ]);
+ src = ./..;
+ EXTRA_LDFLAGS = ''-linkmode external -extldflags "-static -lm"'';
+ BUILDTAGS = ''static apparmor selinux seccomp systemd varlink containers_image_ostree_stub'';
+ })).override {
+ gpgme = (static pkgs.gpgme);
+ libseccomp = (static pkgs.libseccomp);
+ lvm2 = (patchLvm2 (static pkgs.lvm2));
+ };
+ };
+in self
diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json
new file mode 100644
index 000000000..fbc774373
--- /dev/null
+++ b/nix/nixpkgs.json
@@ -0,0 +1,9 @@
+{
+ "url": "https://github.com/nixos/nixpkgs",
+ "rev": "a08d4f605bca62c282ce9955d5ddf7d824e89809",
+ "date": "2020-03-20T10:10:15+01:00",
+ "sha256": "1bniq08dlmrmrz4aga1cj0d7rqbaq9xapm5ar15wdv2c6431z2m8",
+ "fetchSubmodules": false,
+ "deepClone": false,
+ "leaveDotGit": false
+}
diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix
new file mode 100644
index 000000000..21e7f17a2
--- /dev/null
+++ b/nix/nixpkgs.nix
@@ -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