Skip to content

Commit

Permalink
feat: use system Podman package
Browse files Browse the repository at this point in the history
  • Loading branch information
pedorich-n committed Dec 5, 2024
1 parent 1083667 commit fc4930d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
11 changes: 6 additions & 5 deletions home-manager-module.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{ libUtils }:
{
config,
osConfig,
lib,
pkgs,
...
}:
let
inherit (lib) types mkOption attrValues mergeAttrsList mkIf;
inherit (lib) types mkOption attrValues mergeAttrsList mkIf getExe;

cfg = config.virtualisation.quadlet;
quadletUtils = import ./utils.nix {
inherit lib;
inherit lib osConfig pkgs;
systemdLib = (libUtils { inherit lib config pkgs; }).systemdUtils.lib;
isUserSystemd = true;
};
containerOpts = types.submodule (import ./container.nix { inherit quadletUtils; });
networkOpts = types.submodule (import ./network.nix { inherit quadletUtils pkgs; });
networkOpts = types.submodule (import ./network.nix { inherit quadletUtils; });
podOpts = types.submodule (import ./pod.nix { inherit quadletUtils; });

activationScript = lib.hm.dag.entryBefore [ "reloadSystemd" ] ''
Expand Down Expand Up @@ -108,8 +109,8 @@ in
Type = "oneshot";
# podman rootless requires "newuidmap" (the suid version, not the non-suid one from pkgs.shadow)
Environment = "PATH=/run/wrappers/bin";
ExecStart = "${pkgs.podman}/bin/podman auto-update";
ExecStartPost = "${pkgs.podman}/bin/podman image prune -f";
ExecStart = "${getExe quadletUtils.podmanPackage} auto-update";
ExecStartPost = "${getExe quadletUtils.podmanPackage} image prune -f";
TimeoutStartSec = "900s";
TimeoutStopSec = "10s";
};
Expand Down
5 changes: 2 additions & 3 deletions network.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
quadletUtils,
pkgs,
}:
{
config,
Expand All @@ -9,7 +8,7 @@
...
}:
let
inherit (lib) types mkOption;
inherit (lib) types mkOption getExe;

networkOpts = {
disableDns = quadletUtils.mkOption {
Expand Down Expand Up @@ -156,7 +155,7 @@ in
};
Network = quadletUtils.configToProperties networkConfig networkOpts;
Service = {
ExecStop = "${pkgs.podman}/bin/podman network rm ${networkName}";
ExecStop = "${getExe quadletUtils.podmanPackage} network rm ${networkName}";
} // config.serviceConfig;
};
in
Expand Down
6 changes: 3 additions & 3 deletions nixos-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let

cfg = config.virtualisation.quadlet;
quadletUtils = import ./utils.nix {
inherit lib;
inherit lib config pkgs;
systemdLib =
(libUtils {
inherit lib config pkgs;
Expand All @@ -19,7 +19,7 @@ let
};

containerOpts = types.submodule (import ./container.nix { inherit quadletUtils; });
networkOpts = types.submodule (import ./network.nix { inherit quadletUtils pkgs; });
networkOpts = types.submodule (import ./network.nix { inherit quadletUtils; });
podOpts = types.submodule (import ./pod.nix { inherit quadletUtils; });
in
{
Expand Down Expand Up @@ -67,7 +67,7 @@ in
# Ensure podman-user-generator is available for systemd user services.
{
"systemd/user-generators/podman-user-generator" = {
source = "${pkgs.podman}/lib/systemd/user-generators/podman-user-generator";
source = "${quadletUtils.podmanPackage}/lib/systemd/user-generators/podman-user-generator";
};
}
// mergeAttrsList (
Expand Down
4 changes: 3 additions & 1 deletion utils.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, systemdLib, isUserSystemd }:
{ lib, systemdLib, isUserSystemd, config ? { }, osConfig ? { }, pkgs }:

let
attrsToList =
Expand Down Expand Up @@ -31,4 +31,6 @@ in
# systemd recommends multi-user.target over default.target.
# https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#default.target
defaultTarget = if isUserSystemd then "default.target" else "multi-user.target";

podmanPackage = config.virtualisation.podman.package or osConfig.virtualisation.podman.package or pkgs.podman;
}

0 comments on commit fc4930d

Please sign in to comment.