Automated upgrade failure

it seems i have somewhere something i havent noticed yet and thats why my automating updates wont work. it seems it is looking the path without finding it. my files path is /etc/nixos that is also git repo enabled and there is scripts to do updates and push the files when done to my repo.

configuration.nix block

# =============================================================
  # 10. SYSTEM AUTOMATION & MAINTENANCE
  # =============================================================
  system.autoUpgrade = {
    enable = true;
    flake = "git+file:///etc/nixos";
    flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ];
    allowReboot = false;
  };

  systemd.timers.nixos-upgrade = {
    timerConfig = {
      OnBootSec = "2h";
      OnUnitActiveSec = "1d";
      Persistent = true;
    };
  };

  systemd.services.nixos-upgrade.postStop = ''
    # 1. Fix permissions for the actual config directory
    if [ -d "/etc/nixos" ]; then
      ${pkgs.coreutils}/bin/chown -R phatle:users /etc/nixos
    fi

    # 2. Notification (Silent on success, loud on failure)
    if [ "$SERVICE_RESULT" != "success" ]; then
      ${pkgs.sudo}/bin/sudo -u phatle \
      DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u phatle)/bus \
      ${pkgs.libnotify}/bin/notify-send "System Upgrade" "FAILED! Check journalctl -u nixos-upgrade" -u critical -i dialog-error
    fi
  '';

home.nix block

# =============================================================
  # 6. SYSTEMD USER SERVICES (AUTOMATION & MAINTENANCE)
  # =============================================================

  # A. Git Automation: Watch flake.lock and push to Codeberg
  systemd.user.paths.push-nixos-changes = {
    Unit.Description = "Watch flake.lock for system updates";
    Path.PathChanged = "/etc/nixos/flake.lock";
    Install.WantedBy = [ "default.target" ];
  };

  systemd.user.services.push-nixos-changes = {
    Unit.Description = "Push NixOS config to Codeberg";
    Service = {
      Type = "oneshot";
      path = with pkgs; [ git openssh libnotify ];
      Restart = "on-failure";
      RestartSec = "5s";
      ExecStart = pkgs.writeShellScript "git-push-auto" ''
        export GIT_SSH_COMMAND="ssh -i /run/secrets/nixos_deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
        cd /etc/nixos
        if [ -n "$(git log origin/main..HEAD 2>/dev/null)" ]; then
            git push origin main
            notify-send -u normal "NixOS Git Sync" "System updated & pushed to Codeberg."
        fi
      '';
    };
  };

error messages

 journalctl -u nixos-upgrade
joulu 22 14:09:19 nixos systemd[1]: Starting NixOS Upgrade...
joulu 22 14:09:22 nixos nixos-upgrade-start[19809]: unpacking 3 channels...
joulu 22 14:09:38 nixos nixos-upgrade-start[20099]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 22 14:09:38 nixos nixos-upgrade-start[20099]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 22 14:09:38 nixos nixos-upgrade-start[19768]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 22 14:09:38 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 22 14:09:38 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 22 14:09:38 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 22 14:09:38 nixos systemd[1]: nixos-upgrade.service: Consumed 14.680s CPU time, 578.7M memory peak, 384>
-- Boot 2f0089fccc014424989a9b951f3afa17 --
joulu 22 16:11:46 nixos systemd[1]: Starting NixOS Upgrade...
joulu 22 16:11:48 nixos nixos-upgrade-start[82920]: unpacking 3 channels...
joulu 22 16:11:48 nixos nixos-upgrade-start[82961]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 22 16:11:48 nixos nixos-upgrade-start[82961]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 22 16:11:48 nixos nixos-upgrade-start[82914]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 22 16:11:48 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 22 16:11:48 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 22 16:11:48 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 22 16:11:48 nixos systemd[1]: nixos-upgrade.service: Consumed 180ms CPU time, 38.7M memory peak, 18.3M >
-- Boot ec8034720a6b4ffc92b340e33a798a8f --
joulu 23 04:45:50 nixos systemd[1]: Starting NixOS Upgrade...
joulu 23 04:45:50 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://channels.nixos>
joulu 23 04:45:50 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://channels.nixos>
joulu 23 04:45:51 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://channels.nixos>
joulu 23 04:45:52 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://channels.nixos>
joulu 23 04:45:54 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://channels.nixos>
joulu 23 04:45:54 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://releases.nixos>
joulu 23 04:45:54 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://releases.nixos>
joulu 23 04:45:55 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://releases.nixos>
joulu 23 04:45:56 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://releases.nixos>
joulu 23 04:45:58 nixos nixos-upgrade-start[1946]: warning: error: unable to download 'https://releases.nixos>
joulu 23 04:45:58 nixos nixos-upgrade-start[1946]: unpacking 3 channels...
joulu 23 04:45:59 nixos nixos-upgrade-start[2153]: warning: '--update-input' is a deprecated alias for 'flake>
joulu 23 04:45:59 nixos nixos-upgrade-start[2153]: error: getting status of '/home/phatle/NixOS': No such fil>
joulu 23 04:45:59 nixos nixos-upgrade-start[1931]: Command 'nix --extra-experimental-features 'nix-command fl>
joulu 23 04:45:59 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 23 04:45:59 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 23 04:45:59 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 23 04:45:59 nixos systemd[1]: nixos-upgrade.service: Consumed 217ms CPU time, 40.4M memory peak, 26.8M >
-- Boot b983966a49af4a52ba2abb2221f45164 --
joulu 23 12:25:39 nixos systemd[1]: Starting NixOS Upgrade...
joulu 23 12:25:40 nixos nixos-upgrade-start[10048]: unpacking 3 channels...
joulu 23 12:25:41 nixos nixos-upgrade-start[10085]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 23 12:25:41 nixos nixos-upgrade-start[10085]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 23 12:25:41 nixos nixos-upgrade-start[10047]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 23 12:25:41 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 23 12:25:41 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 23 12:25:41 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 23 12:25:41 nixos systemd[1]: nixos-upgrade.service: Consumed 418ms CPU time, 30.6M memory peak, 2.1M r>
-- Boot b19dcd1d8ef141c1b08dbebbd62bc97f --
joulu 26 09:35:50 nixos systemd[1]: Starting NixOS Upgrade...
joulu 26 09:35:50 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://channels.nixos>
joulu 26 09:35:50 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://channels.nixos>
joulu 26 09:35:51 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://channels.nixos>
joulu 26 09:35:52 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://channels.nixos>
joulu 26 09:35:55 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://channels.nixos>
joulu 26 09:35:55 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://releases.nixos>
joulu 26 09:35:55 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://releases.nixos>
joulu 26 09:35:56 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://releases.nixos>
joulu 26 09:35:57 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://releases.nixos>
joulu 26 09:35:59 nixos nixos-upgrade-start[1699]: warning: error: unable to download 'https://releases.nixos>
joulu 26 09:35:59 nixos nixos-upgrade-start[1699]: unpacking 3 channels...
joulu 26 09:35:59 nixos nixos-upgrade-start[1778]: warning: '--update-input' is a deprecated alias for 'flake>
joulu 26 09:35:59 nixos nixos-upgrade-start[1778]: error: getting status of '/home/phatle/NixOS': No such fil>
joulu 26 09:35:59 nixos nixos-upgrade-start[1670]: Command 'nix --extra-experimental-features 'nix-command fl>
joulu 26 09:35:59 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 26 09:35:59 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 26 09:35:59 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 26 09:35:59 nixos systemd[1]: nixos-upgrade.service: Consumed 222ms CPU time, 40.6M memory peak, 26.3M >
-- Boot 545a1d42c6654f008c35c7653f7f0883 --
joulu 26 14:46:39 nixos systemd[1]: Starting NixOS Upgrade...
joulu 26 14:46:42 nixos nixos-upgrade-start[10693]: unpacking 3 channels...
joulu 26 14:46:53 nixos nixos-upgrade-start[10775]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 26 14:46:53 nixos nixos-upgrade-start[10775]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 26 14:46:53 nixos nixos-upgrade-start[10692]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 26 14:46:53 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 26 14:46:53 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 26 14:46:53 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 26 14:46:53 nixos systemd[1]: nixos-upgrade.service: Consumed 9.295s CPU time, 693.2M memory peak, 170.>
-- Boot 50d12a9894a745a094a29929f19b9e4e --
joulu 26 20:23:21 nixos systemd[1]: Starting NixOS Upgrade...
joulu 26 20:23:23 nixos nixos-upgrade-start[17004]: unpacking 3 channels...
joulu 26 20:23:39 nixos nixos-upgrade-start[17099]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 26 20:23:39 nixos nixos-upgrade-start[17099]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 26 20:23:39 nixos nixos-upgrade-start[17003]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 26 20:23:39 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 26 20:23:39 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 26 20:23:39 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 26 20:23:39 nixos systemd[1]: nixos-upgrade.service: Consumed 15.149s CPU time, 551M memory peak, 57.7M>
-- Boot f3e16c2c54f64dff88bbe771beb379eb --
joulu 27 08:52:08 nixos systemd[1]: Starting NixOS Upgrade...
joulu 27 08:52:09 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://channels.nixos>
joulu 27 08:52:09 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://channels.nixos>
joulu 27 08:52:10 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://channels.nixos>
joulu 27 08:52:11 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://channels.nixos>
joulu 27 08:52:13 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://channels.nixos>
joulu 27 08:52:13 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://releases.nixos>
joulu 27 08:52:13 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://releases.nixos>
joulu 27 08:52:14 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://releases.nixos>
joulu 27 08:52:15 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://releases.nixos>
joulu 27 08:52:17 nixos nixos-upgrade-start[1784]: warning: error: unable to download 'https://releases.nixos>
joulu 27 08:52:17 nixos nixos-upgrade-start[1784]: unpacking 3 channels...
joulu 27 08:52:17 nixos nixos-upgrade-start[1876]: warning: '--update-input' is a deprecated alias for 'flake>
joulu 27 08:52:17 nixos nixos-upgrade-start[1876]: error: getting status of '/home/phatle/NixOS': No such fil>
joulu 27 08:52:17 nixos nixos-upgrade-start[1758]: Command 'nix --extra-experimental-features 'nix-command fl>
joulu 27 08:52:17 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 27 08:52:17 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 27 08:52:17 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 27 08:52:17 nixos systemd[1]: nixos-upgrade.service: Consumed 222ms CPU time, 42M memory peak, 27.3M re>
joulu 27 10:51:54 nixos systemd[1]: Starting NixOS Upgrade...
joulu 27 10:51:56 nixos nixos-upgrade-start[15350]: unpacking 3 channels...
joulu 27 10:51:56 nixos nixos-upgrade-start[15387]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 27 10:51:56 nixos nixos-upgrade-start[15387]: error: getting status of '/home/phatle/NixOS': No such fi>
joulu 27 10:51:56 nixos nixos-upgrade-start[15349]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 27 10:51:56 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 27 10:51:56 nixos sudo[15408]:     root : PWD=/ ; USER=phatle ; ENV=DBUS_SESSION_BUS_ADDRESS=unix:path=>
joulu 27 10:51:56 nixos sudo[15408]: pam_unix(sudo:session): session opened for user phatle(uid=1000) by (uid>
joulu 27 10:51:56 nixos sudo[15408]: pam_unix(sudo:session): session closed for user phatle
joulu 27 10:51:56 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 27 10:51:56 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 27 10:51:56 nixos systemd[1]: nixos-upgrade.service: Consumed 395ms CPU time, 29.4M memory peak, 80K re>
-- Boot 54309d7b95c3478590bead54e4688664 --
joulu 27 19:07:25 nixos systemd[1]: Starting NixOS Upgrade...
joulu 27 19:07:26 nixos nixos-upgrade-start[43796]: unpacking 3 channels...
joulu 27 19:07:27 nixos nixos-upgrade-start[43833]: warning: '--update-input' is a deprecated alias for 'flak>
joulu 27 19:07:27 nixos nixos-upgrade-start[43833]: error:
joulu 27 19:07:27 nixos nixos-upgrade-start[43833]:        … while fetching the input 'git+file:///etc/nixos'
joulu 27 19:07:27 nixos nixos-upgrade-start[43833]:        error: opening Git repository "/etc/nixos": reposi>
joulu 27 19:07:27 nixos nixos-upgrade-start[43795]: Command 'nix --extra-experimental-features 'nix-command f>
joulu 27 19:07:27 nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
joulu 27 19:07:27 nixos sudo[43857]:     root : PWD=/ ; USER=phatle ; ENV=DBUS_SESSION_BUS_ADDRESS=unix:path=>
joulu 27 19:07:27 nixos sudo[43857]: pam_unix(sudo:session): session opened for user phatle(uid=1000) by (uid>
joulu 27 19:07:27 nixos sudo[43857]: pam_unix(sudo:session): session closed for user phatle
joulu 27 19:07:27 nixos systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
joulu 27 19:07:27 nixos systemd[1]: Failed to start NixOS Upgrade.
joulu 27 19:07:27 nixos systemd[1]: nixos-upgrade.service: Consumed 486ms CPU time, 30.7M memory peak, 1.3M r>
lines 110-136/136 (END)

Can you share the full error message? And not cut off in half?

Also please share the generated service unit.

It is full error message journalctl all since I made the automated update. You can see all when scrolling to right more not cut in half

Sorry I see it now it is cut I will get full one

It is cut in half by the pager. You can pipe/redirect it or use --no-pager to get the whole contents.

Based on what I can see, it looks like you were originally using /home/phatle/NixOS and are now using /etc/nixos. Which user owns /etc/nixos? I suspect the error you are getting is repository path is not owned by current user. If so you have options, namely marking the directory safe in your git config.

Yeah I think that might be issue that automatic update is run by root, but git didn’t work there when it was as root so I changed to user. Git function is in home.nix to run that push so root is treating that folder as not trusted and might fix just for adding it as trusted.

Will test that and will provide later full logs without cutting anything