Honor ownership.

This commit is contained in:
Tom Alexander 2025-08-09 21:19:13 -04:00
parent 03e389195c
commit 6db8e01309
No known key found for this signature in database
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 31 additions and 8 deletions

View File

@ -81,7 +81,7 @@
# me.install.user.file.talexander.".local/nixcfg" = ./README.org; # me.install.user.file.talexander.".local/nixcfg" = ./README.org;
me.install.user.talexander.file.".local/nixcfg" = { me.install.user.talexander.file.".local/nixcfg" = {
source = ./flake.lock; source = ./flake.lock;
method = "overwrite"; # method = "overwrite";
}; };
nix.settings.experimental-features = [ nix.settings.experimental-features = [

View File

@ -12,11 +12,18 @@ let
attrNames attrNames
; ;
get_shell_values = target: rec { get_shell_values =
source = lib.strings.escapeShellArg "${target.source}"; target:
let
homedir = config.users.users."${target.username}".home; homedir = config.users.users."${target.username}".home;
group = config.users.users."${target.username}".group;
in
{
source = lib.strings.escapeShellArg "${target.source}";
destination = lib.strings.escapeShellArg "${homedir}/${target.target}"; destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
mode = lib.strings.escapeShellArg "${target.mode}"; mode = lib.strings.escapeShellArg "${target.mode}";
username = lib.strings.escapeShellArg "${target.username}";
group = lib.strings.escapeShellArg "${group}";
}; };
install_user_file = install_user_file =
let let
@ -35,10 +42,17 @@ let
source source
destination destination
mode mode
username
group
; ;
flags = lib.strings.concatStringsSep " " [
(if mode != "" then "-m ${mode}" else "")
(if username != "" then "-o ${username}" else "")
(if group != "" then "-g ${group}" else "")
];
in in
'' ''
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination} $DRY_RUN_CMD install $VERBOSE_ARG -D --compare ${flags} ${source} ${destination}
'' ''
); );
"uninstall" = ( "uninstall" = (
@ -61,10 +75,19 @@ let
inherit (get_shell_values target) inherit (get_shell_values target)
source source
destination destination
username
group
; ;
owner = lib.strings.concatStringsSep ":" (
filter (val: val != "") [
username
group
]
);
in in
'' ''
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination} $DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
$DRY_RUN_CMD chown $VERBOSE_ARG -h ${owner} ${destination}
'' ''
); );
"uninstall" = ( "uninstall" = (