Add a check and uninstall phase.
This commit is contained in:
parent
1cb4fa4234
commit
eb5815048f
@ -14,6 +14,14 @@ let
|
|||||||
;
|
;
|
||||||
|
|
||||||
install_user_file =
|
install_user_file =
|
||||||
|
let
|
||||||
|
constructors = {
|
||||||
|
"overwrite" = install_user_file_overwrite;
|
||||||
|
"symlink" = install_user_file_symlink;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
stage: target: (constructors."${target.method}"."${stage}" target);
|
||||||
|
old_install_user_file =
|
||||||
let
|
let
|
||||||
constructors = {
|
constructors = {
|
||||||
"overwrite" = install_user_file_overwrite;
|
"overwrite" = install_user_file_overwrite;
|
||||||
@ -21,27 +29,35 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
(target: (constructors."${target.method}" target));
|
(target: (constructors."${target.method}" target));
|
||||||
install_user_file_overwrite =
|
install_user_file_overwrite = {
|
||||||
target:
|
"check" = (target: "");
|
||||||
let
|
"install" = (
|
||||||
source = lib.strings.escapeShellArg "${target.source}";
|
target:
|
||||||
destination = lib.strings.escapeShellArg "${target.target}";
|
let
|
||||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
source = lib.strings.escapeShellArg "${target.source}";
|
||||||
in
|
destination = lib.strings.escapeShellArg "${target.target}";
|
||||||
# $DRY_RUN_CMD ${pkgs.toyboy}/bin/install $VERBOSE_ARG -D -m ${mode} ${source} ${destination}
|
mode = lib.strings.escapeShellArg "${target.mode}";
|
||||||
''
|
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}
|
||||||
install_user_file_symlink =
|
''
|
||||||
target:
|
);
|
||||||
let
|
"uninstall" = (target: "");
|
||||||
source = lib.strings.escapeShellArg "${target.source}";
|
};
|
||||||
destination = lib.strings.escapeShellArg "${target.target}";
|
install_user_file_symlink = {
|
||||||
mode = lib.strings.escapeShellArg "${target.mode}";
|
"check" = (target: "");
|
||||||
in
|
"install" = (
|
||||||
''
|
target:
|
||||||
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
let
|
||||||
'';
|
source = lib.strings.escapeShellArg "${target.source}";
|
||||||
|
destination = lib.strings.escapeShellArg "${target.target}";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
$DRY_RUN_CMD ln $VERBOSE_ARG -s ${source} ${destination}
|
||||||
|
''
|
||||||
|
);
|
||||||
|
"uninstall" = (target: "");
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
@ -141,7 +157,9 @@ in
|
|||||||
builtins.map (user: (builtins.map (path: user.file."${path}") (attrNames user.file))) enabled_users
|
builtins.map (user: (builtins.map (path: user.file."${path}") (attrNames user.file))) enabled_users
|
||||||
);
|
);
|
||||||
enabled_file_targets = filter (target: target.enable) all_file_targets;
|
enabled_file_targets = filter (target: target.enable) all_file_targets;
|
||||||
install_commands = builtins.map install_user_file enabled_file_targets;
|
check_commands = builtins.map (install_user_file "check") enabled_file_targets;
|
||||||
|
install_commands = builtins.map (install_user_file "install") enabled_file_targets;
|
||||||
|
uninstall_commands = builtins.map (install_user_file "uninstall") enabled_file_targets;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
systemd.services.me-install-file = {
|
systemd.services.me-install-file = {
|
||||||
@ -158,10 +176,8 @@ in
|
|||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = "yes";
|
RemainAfterExit = "yes";
|
||||||
};
|
};
|
||||||
script = (lib.strings.concatStringsSep "\n" install_commands);
|
script = (lib.strings.concatStringsSep "\n" (check_commands ++ install_commands));
|
||||||
# preStop = ''
|
preStop = (lib.strings.concatStringsSep "\n" uninstall_commands);
|
||||||
# rm -f /home/talexander/.docker/config.json
|
|
||||||
# '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."install_out".text = config.systemd.services.me-install-file.script;
|
environment.etc."install_out".text = config.systemd.services.me-install-file.script;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user