Skip to content

Commit

Permalink
nixos/oci-containers: option to set the service name of a oci-ontainer (
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored Jan 4, 2025
2 parents 0fe10c5 + d010389 commit af96c38
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nixos/modules/virtualisation/oci-containers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let
defaultBackend = options.virtualisation.oci-containers.backend.default;

containerOptions =
{ ... }:
{ name, ... }:
{

options = {
Expand Down Expand Up @@ -59,6 +59,13 @@ let
example = literalExpression "pkgs.dockerTools.streamLayeredImage {...};";
};

serviceName = mkOption {
type = types.str;
default = "${cfg.backend}-${name}";
defaultText = "<backend>-<name>";
description = "Systemd service name that manages the container";
};

login = {

username = mkOption {
Expand Down Expand Up @@ -525,9 +532,7 @@ in
config = lib.mkIf (cfg.containers != { }) (
lib.mkMerge [
{
systemd.services = mapAttrs' (
n: v: nameValuePair "${cfg.backend}-${n}" (mkService n v)
) cfg.containers;
systemd.services = mapAttrs' (n: v: nameValuePair v.serviceName (mkService n v)) cfg.containers;

assertions =
let
Expand Down

0 comments on commit af96c38

Please sign in to comment.