systemd exec fix

This commit is contained in:
sascha.koenig 2025-11-11 11:08:35 +01:00
parent bb66bcc2c5
commit 320ce3d0bc

View File

@ -8,6 +8,9 @@
hostname ? "AZPILOGISTIK01",
...
}: {
# Direkt aus dem Git-Repository installieren
nix run git+https://git.az-gruppe.com/AZ-Intec-GmbH/AZ-NIX.git#homeConfigurations.logistik@AZPILOGISTIK01.activationPackage
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "pi";
@ -232,14 +235,28 @@
systemd.user.services.home-manager-update = {
Unit = {
Description = "Update home-manager configuration from git";
After = "network-online.target";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.writeShellScript "home-manager-update" ''
set -e
cd /home/${config.home.username}/AZ-NIX
${pkgs.git}/bin/git pull
${config.programs.home-manager.package}/bin/home-manager switch --flake .#logistik@${hostname}
echo "[$(date)] Starting home-manager update..."
# Prüfe ob lokales Repo existiert
if [ -d "/home/${config.home.username}/AZ-NIX" ]; then
echo "Using local repository..."
cd /home/${config.home.username}/AZ-NIX
${pkgs.git}/bin/git pull
${pkgs.nix}/bin/nix run home-manager/release-25.05 -- switch --flake .#logistik@${hostname}
else
echo "Using remote repository..."
${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}
fi
echo "[$(date)] Update completed"
''}";
};
};