Centralize the logic for escaping the shell values.
This commit is contained in:
parent
6b42a09468
commit
2c3e5483e9
@ -81,6 +81,7 @@
|
||||
# me.install.user.file.talexander.".local/nixcfg" = ./README.org;
|
||||
me.install.user.talexander.file.".local/nixcfg" = {
|
||||
source = ./flake.lock;
|
||||
method = "overwrite";
|
||||
};
|
||||
|
||||
nix.settings.experimental-features = [
|
||||
|
@ -13,6 +13,12 @@ let
|
||||
attrNames
|
||||
;
|
||||
|
||||
get_shell_values = target: rec {
|
||||
source = lib.strings.escapeShellArg "${target.source}";
|
||||
homedir = config.users.users."${target.username}".home;
|
||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
||||
};
|
||||
install_user_file =
|
||||
let
|
||||
constructors = {
|
||||
@ -26,10 +32,11 @@ let
|
||||
"install" = (
|
||||
target:
|
||||
let
|
||||
source = lib.strings.escapeShellArg "${target.source}";
|
||||
homedir = config.users.users."${target.username}".home;
|
||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
||||
inherit (get_shell_values target)
|
||||
source
|
||||
destination
|
||||
mode
|
||||
;
|
||||
in
|
||||
''
|
||||
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination}
|
||||
@ -38,8 +45,9 @@ let
|
||||
"uninstall" = (
|
||||
target:
|
||||
let
|
||||
homedir = config.users.users."${target.username}".home;
|
||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
||||
inherit (get_shell_values target)
|
||||
destination
|
||||
;
|
||||
in
|
||||
''
|
||||
$DRY_RUN_CMD echo rm -f ${destination}
|
||||
@ -51,9 +59,10 @@ let
|
||||
"install" = (
|
||||
target:
|
||||
let
|
||||
source = lib.strings.escapeShellArg "${target.source}";
|
||||
homedir = config.users.users."${target.username}".home;
|
||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
||||
inherit (get_shell_values target)
|
||||
source
|
||||
destination
|
||||
;
|
||||
in
|
||||
''
|
||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
||||
@ -62,8 +71,9 @@ let
|
||||
"uninstall" = (
|
||||
target:
|
||||
let
|
||||
homedir = config.users.users."${target.username}".home;
|
||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
||||
inherit (get_shell_values target)
|
||||
destination
|
||||
;
|
||||
in
|
||||
''
|
||||
$DRY_RUN_CMD echo rm -f ${destination}
|
||||
|
Loading…
x
Reference in New Issue
Block a user