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.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";
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.settings.experimental-features = [
|
nix.settings.experimental-features = [
|
||||||
|
@ -13,6 +13,12 @@ let
|
|||||||
attrNames
|
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 =
|
install_user_file =
|
||||||
let
|
let
|
||||||
constructors = {
|
constructors = {
|
||||||
@ -26,10 +32,11 @@ let
|
|||||||
"install" = (
|
"install" = (
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
source = lib.strings.escapeShellArg "${target.source}";
|
inherit (get_shell_values target)
|
||||||
homedir = config.users.users."${target.username}".home;
|
source
|
||||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
destination
|
||||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
mode
|
||||||
|
;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination}
|
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination}
|
||||||
@ -38,8 +45,9 @@ let
|
|||||||
"uninstall" = (
|
"uninstall" = (
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
homedir = config.users.users."${target.username}".home;
|
inherit (get_shell_values target)
|
||||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
destination
|
||||||
|
;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
$DRY_RUN_CMD echo rm -f ${destination}
|
$DRY_RUN_CMD echo rm -f ${destination}
|
||||||
@ -51,9 +59,10 @@ let
|
|||||||
"install" = (
|
"install" = (
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
source = lib.strings.escapeShellArg "${target.source}";
|
inherit (get_shell_values target)
|
||||||
homedir = config.users.users."${target.username}".home;
|
source
|
||||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
destination
|
||||||
|
;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
||||||
@ -62,8 +71,9 @@ let
|
|||||||
"uninstall" = (
|
"uninstall" = (
|
||||||
target:
|
target:
|
||||||
let
|
let
|
||||||
homedir = config.users.users."${target.username}".home;
|
inherit (get_shell_values target)
|
||||||
destination = lib.strings.escapeShellArg "${homedir}/${target.target}";
|
destination
|
||||||
|
;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
$DRY_RUN_CMD echo rm -f ${destination}
|
$DRY_RUN_CMD echo rm -f ${destination}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user