From 504f8ecf09f297ad5624e06e6fc5a51fe17782a2 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 26 May 2025 21:17:11 -0400 Subject: [PATCH] Add support for setting the group owning the file. --- nix/configuration/util/install_files/default.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nix/configuration/util/install_files/default.nix b/nix/configuration/util/install_files/default.nix index 61183b9..a3e31bb 100644 --- a/nix/configuration/util/install_files/default.nix +++ b/nix/configuration/util/install_files/default.nix @@ -58,6 +58,13 @@ let example = ".local/share/foo/bar.txt"; description = "The path where the file should be written."; }; + group = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + defaultText = "${prefix}.‹path›.group"; + example = ".local/share/foo/bar.txt"; + description = "The group that should own the file."; + }; }; config = { @@ -138,9 +145,14 @@ in destination = lib.strings.escapeShellArg "${target_config.target}"; mode = lib.strings.escapeShellArg "${target_config.mode}"; escaped_username = lib.strings.escapeShellArg "${username}"; + escaped_group = + if target_config.group == null then + "$(id -g ${escaped_username})" + else + (lib.strings.escapeShellArg "${target_config.group}"); in '' - $DRY_RUN_CMD install $VERBOSE_ARG -D --compare -o ${escaped_username} -m ${mode} ${source} ${destination} + $DRY_RUN_CMD install $VERBOSE_ARG -D --compare -o ${escaped_username} -g ${escaped_group} -m ${mode} ${source} ${destination} '' ) active_install_file_targets ) active_install_users