about summary refs log tree commit diff
path: root/pkgs/applications/virtualization/podman/default.nix
diff options
context:
space:
mode:
authorzowoq <59103226+zowoq@users.noreply.github.com>2023-02-10 08:24:43 +1000
committerzowoq <59103226+zowoq@users.noreply.github.com>2023-02-14 19:22:24 +1000
commit02f92550441de39d0e42b39b538ac5529714ed41 (patch)
tree3098a40b35f920a167b84d9ff0076e12de8d0784 /pkgs/applications/virtualization/podman/default.nix
parent04b9fcca931dbbf0e9d4861498dbf341d08fa52f (diff)
downloadnixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar.gz
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar.bz2
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar.lz
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar.xz
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.tar.zst
nixlib-02f92550441de39d0e42b39b538ac5529714ed41.zip
podman: remove wrapper
trying to get all of the podman functionality to work with the wrapper
 is becoming more complicated with each release, it isn't sustainable

removing the wrapper does mean that using extraPackages will need to build from source

- include pkgs.zfs by default in the wrapped podman used by the module so it is cached
  - anyone using zfsUnstable will need to build from source

- remove unnecessary serviceConfig overrides

- set HELPER_BINARIES_DIR during build

- use install.bin target on linux for podman/tmpfiles
  - also installs quadlet/rootlessport in libexec

- remove unnecessary rootlessport output

- remove unnecessary substituteInPlace
Diffstat (limited to 'pkgs/applications/virtualization/podman/default.nix')
-rw-r--r--pkgs/applications/virtualization/podman/default.nix73
1 files changed, 57 insertions, 16 deletions
diff --git a/pkgs/applications/virtualization/podman/default.nix b/pkgs/applications/virtualization/podman/default.nix
index 0ac55e0bec24..7e6ea949218b 100644
--- a/pkgs/applications/virtualization/podman/default.nix
+++ b/pkgs/applications/virtualization/podman/default.nix
@@ -14,8 +14,52 @@
 , go-md2man
 , nixosTests
 , python3
+, makeWrapper
+, symlinkJoin
+, extraPackages ? [ ]
+, runc
+, crun
+, conmon
+, slirp4netns
+, fuse-overlayfs
+, util-linux
+, iptables
+, iproute2
+, catatonit
+, gvproxy
+, aardvark-dns
+, netavark
+, testers
+, podman
 }:
+let
+  # do not add qemu to this wrapper, store paths get written to the podman vm config and break when GCed
 
+  binPath = lib.makeBinPath ([
+  ] ++ lib.optionals stdenv.isLinux [
+    runc
+    crun
+    conmon
+    slirp4netns
+    fuse-overlayfs
+    util-linux
+    iptables
+    iproute2
+  ] ++ extraPackages);
+
+  helpersBin = symlinkJoin {
+    name = "podman-helper-binary-wrapper";
+
+    # this only works for some binaries, others may need to be be added to `binPath` or in the modules
+    paths = [
+      gvproxy
+    ] ++ lib.optionals stdenv.isLinux [
+      aardvark-dns
+      catatonit # added here for the pause image and also set in `containersConf` for `init_path`
+      netavark
+    ];
+  };
+in
 buildGoModule rec {
   pname = "podman";
   version = "4.4.1";
@@ -36,9 +80,9 @@ buildGoModule rec {
 
   doCheck = false;
 
-  outputs = [ "out" "man" ] ++ lib.optionals stdenv.isLinux [ "rootlessport" ];
+  outputs = [ "out" "man" ];
 
-  nativeBuildInputs = [ pkg-config go-md2man installShellFiles python3 ];
+  nativeBuildInputs = [ pkg-config go-md2man installShellFiles makeWrapper python3 ];
 
   buildInputs = lib.optionals stdenv.isLinux [
     btrfs-progs
@@ -50,13 +94,16 @@ buildGoModule rec {
     systemd
   ];
 
+  HELPER_BINARIES_DIR = "${helpersBin}/bin";
+  PREFIX = "${placeholder "out"}";
+
   buildPhase = ''
     runHook preBuild
     patchShebangs .
     ${if stdenv.isDarwin then ''
       make podman-remote # podman-mac-helper uses FHS paths
     '' else ''
-      make bin/podman bin/rootlessport
+      make bin/podman bin/rootlessport bin/quadlet
     ''}
     make docs
     runHook postBuild
@@ -64,26 +111,20 @@ buildGoModule rec {
 
   installPhase = ''
     runHook preInstall
-    mkdir -p {$out/{bin,etc,lib,share},$man} # ensure paths exist for the wrapper
     ${if stdenv.isDarwin then ''
-      mv bin/{darwin/podman,podman}
+      install bin/darwin/podman -Dt $out/bin
     '' else ''
-      install -Dm644 contrib/tmpfile/podman.conf -t $out/lib/tmpfiles.d
-      for s in contrib/systemd/**/*.in; do
-        substituteInPlace "$s" --replace "@@PODMAN@@" "podman" # don't use unwrapped binary
-      done
-      PREFIX=$out make install.systemd
-      install -Dm555 bin/rootlessport -t $rootlessport/bin
+      make install.bin install.systemd
     ''}
-    install -Dm555 bin/podman -t $out/bin
-    PREFIX=$out make install.completions
-    MANDIR=$man/share/man make install.man
+    make install.completions install.man
+    wrapProgram $out/bin/podman \
+      --prefix PATH : ${lib.escapeShellArg binPath}
     runHook postInstall
   '';
 
   postFixup = lib.optionalString stdenv.isLinux ''
-    RPATH=$(patchelf --print-rpath $out/bin/podman)
-    patchelf --set-rpath "${lib.makeLibraryPath [ systemd ]}":$RPATH $out/bin/podman
+    RPATH=$(patchelf --print-rpath $out/bin/.podman-wrapped)
+    patchelf --set-rpath "${lib.makeLibraryPath [ systemd ]}":$RPATH $out/bin/.podman-wrapped
   '';
 
   passthru.tests = {