systemd exec fix

This commit is contained in:
sascha.koenig 2025-11-11 11:24:34 +01:00
parent 8c12b7e81c
commit 65eb40f74e

View File

@ -229,9 +229,13 @@
programs.home-manager.enable = true; programs.home-manager.enable = true;
# Systemd Timer für nächtliches home-manager update # Systemd Timer für nächtliches home-manager update
systemd.user.services.home-manager-update = { # Der hostname wird zur Build-Zeit in das Script eingebettet
systemd.user.services.home-manager-update = let
flakeConfig = "logistik@${hostname}";
repoUrl = "git+https://git.az-gruppe.com/AZ-Intec-GmbH/AZ-NIX.git";
in {
Unit = { Unit = {
Description = "Update home-manager configuration from git"; Description = "Update home-manager configuration for ${hostname}";
After = "network-online.target"; After = "network-online.target";
}; };
Service = { Service = {
@ -239,21 +243,21 @@
ExecStart = "${pkgs.writeShellScript "home-manager-update" '' ExecStart = "${pkgs.writeShellScript "home-manager-update" ''
set -e set -e
echo "[$(date)] Starting home-manager update..." echo "[$(${pkgs.coreutils}/bin/date)] Starting home-manager update for ${flakeConfig}..."
# Prüfe ob lokales Repo existiert # Prüfe ob lokales Repo existiert
if [ -d "/home/${config.home.username}/AZ-NIX" ]; then if [ -d "/home/${config.home.username}/AZ-NIX" ]; then
echo "Using local repository..." echo "Using local repository..."
cd /home/${config.home.username}/AZ-NIX cd /home/${config.home.username}/AZ-NIX
${pkgs.git}/bin/git pull ${pkgs.git}/bin/git pull
${pkgs.nix}/bin/nix run home-manager/release-25.05 -- switch --flake .#logistik@${hostname} ${pkgs.nix}/bin/nix run home-manager/release-25.05 -- switch --flake .#${flakeConfig}
else else
echo "Using remote repository..." echo "Using remote repository..."
${pkgs.nix}/bin/nix run home-manager/release-25.05 -- switch \ ${pkgs.nix}/bin/nix run home-manager/release-25.05 -- switch \
--flake git+https://git.az-gruppe.com/AZ-Intec-GmbH/AZ-NIX.git#logistik@${hostname} --flake ${repoUrl}#${flakeConfig}
fi fi
echo "[$(date)] Update completed" echo "[$(${pkgs.coreutils}/bin/date)] Update completed successfully"
''}"; ''}";
}; };
}; };