From d4a77341eea5041889dd9900aa57487b036bfb90 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Sun, 25 Jun 2023 14:21:19 +0100 Subject: [PATCH] Add podman to deck --- users/deck/default.nix | 1 + users/deck/podman.nix | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 users/deck/podman.nix diff --git a/users/deck/default.nix b/users/deck/default.nix index 86fbb45..60a3aad 100644 --- a/users/deck/default.nix +++ b/users/deck/default.nix @@ -29,6 +29,7 @@ in { imports = [ ../configs/system + ./podman.nix ]; home = { diff --git a/users/deck/podman.nix b/users/deck/podman.nix new file mode 100644 index 0000000..0fe8a23 --- /dev/null +++ b/users/deck/podman.nix @@ -0,0 +1,73 @@ +{pkgs, config, ...}: let + PODMAN_VERSION = "4.5.1"; + podman-static = pkgs.stdenv.mkDerivation { + name = "podman-static"; + src = pkgs.fetchzip { + url = "https://github.com/mgoltzsche/podman-static/releases/download/v${PODMAN_VERSION}/podman-linux-amd64.tar.gz"; + hash = "sha256-66eReaToPuusoQI+Ooh+3bKQi39dA46etwX9REwApRc="; + }; + + runtimeDependencies = with pkgs; [ + conmon + crun + slirp4netns + fuse-overlayfs + ]; + + installPhase = '' + mkdir -p $out + cp -r usr/local/bin $out + cp -r usr/local/lib $out + cp -r etc $out + rm $out/etc/containers/containers.conf + + substituteInPlace $out/etc/containers/storage.conf \ + --replace "/var" "${config.home.homeDirectory}/.local/share" + + sed -i "s|mount_program =.*|mount_program = \"${pkgs.fuse-overlayfs}/bin/fuse-overlayfs\"|g" \ + "$out/etc/containers/storage.conf" + ''; + + }; + + dest_path = ".local/podman"; + + configuration = '' + # See https://github.com/containers/common/blob/master/pkg/config/containers.conf + [engine] + infra_image="k8s.gcr.io/pause:3.8" + # can be croupfs, systemd + cgroup_manager = "systemd" + # can be file, journald + events_logger="file" + exit_command_delay = 10 + # can be runc, crun + runtime = "crun" + stop_timeout = 5 + conmon_path = [ "${pkgs.conmon}/bin/conmon" ] + helper_binaries_dir = [ "${podman-static}/lib/podman" ] + static_dir = "${config.home.homeDirectory}/.local/share/containers/storage/libpod" + volume_path = "${config.home.homeDirectory}/local/share/containers/storage/volumes" + [engine.runtimes] + crun = [ "${pkgs.crun}/bin/crun" ] + [network] + cni_plugin_dirs = [ "${podman-static}/lib/cni" ] + ''; + + conf_path = ".config/containers"; + +in +{ + home.packages = [ + podman-static + pkgs.podman-compose + ]; + + home.file = { + "${conf_path}" = { + source = "${podman-static}/etc/containers"; + recursive = true; + }; + "${conf_path}/containers.conf".text = configuration; + }; +}