Switch to a systemd unit file to remove the need for home-manager.

This commit is contained in:
Tom Alexander 2025-04-11 18:34:27 -04:00
parent 83eaba357f
commit f667c9daa6
No known key found for this signature in database
GPG Key ID: D3A179C9A53C0EDE

View File

@ -116,27 +116,39 @@ in
let let
cfg = config.me.install.file; cfg = config.me.install.file;
install_file_targets = filter (target: config.me.install.file."${target}".enable) (attrNames cfg); install_file_targets = filter (target: config.me.install.file."${target}".enable) (attrNames cfg);
install_commands = builtins.map (
target:
let
target_config = config.me.install.file."${target}";
source = lib.strings.escapeShellArg "${target_config.source}";
destination = lib.strings.escapeShellArg "${target_config.target}";
mode = lib.strings.escapeShellArg "${target_config.mode}";
in
# $DRY_RUN_CMD ${pkgs.toyboy}/bin/install $VERBOSE_ARG -D -m ${mode} ${source} ${destination}
''
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination}
''
) install_file_targets;
in in
{ {
home.activation = { systemd.services.me-install-file = {
installFiles = home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] ( enable = true;
let description = "me-install-file";
install_commands = builtins.map ( wantedBy = [ "multi-user.target" ];
target: wants = [ "multi-user.target" ];
let after = [ "multi-user.target" ];
target_config = config.me.install.file."${target}"; # path = with pkgs; [
source = lib.strings.escapeShellArg "${target_config.source}"; # zfs
destination = lib.strings.escapeShellArg "${target_config.target}"; # ];
mode = lib.strings.escapeShellArg "${target_config.mode}"; unitConfig.DefaultDependencies = "no";
in serviceConfig = {
# $DRY_RUN_CMD ${pkgs.toyboy}/bin/install $VERBOSE_ARG -D -m ${mode} ${source} ${destination} Type = "oneshot";
'' RemainAfterExit = "yes";
$DRY_RUN_CMD install $VERBOSE_ARG -D --compare -m ${mode} ${source} ${destination} };
'' script = (lib.strings.concatStringsSep "\n" install_commands);
) install_file_targets; # preStop = ''
in # rm -f /home/talexander/.docker/config.json
(lib.strings.concatStringsSep "\n" install_commands) # '';
);
}; };
} }
)) ))