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
cfg = config.me.install.file;
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
{
home.activation = {
installFiles = home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] (
let
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
(lib.strings.concatStringsSep "\n" install_commands)
);
systemd.services.me-install-file = {
enable = true;
description = "me-install-file";
wantedBy = [ "multi-user.target" ];
wants = [ "multi-user.target" ];
after = [ "multi-user.target" ];
# path = with pkgs; [
# zfs
# ];
unitConfig.DefaultDependencies = "no";
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
};
script = (lib.strings.concatStringsSep "\n" install_commands);
# preStop = ''
# rm -f /home/talexander/.docker/config.json
# '';
};
}
))