- Shell 71.3%
- Nix 28.7%
| flake.lock | ||
| flake.nix | ||
| module.nix | ||
| nixos-update.sh | ||
| package.nix | ||
| README.md | ||
| tests.sh | ||
nixos-update
One-step system update for flake-based NixOS, plus automatic store maintenance.
nixos-update # flake update -> build -> diff -> confirm -> switch -> commit flake.lock
nixos-update --dry-run # update and build, show what would change, restore flake.lock
nixos-update --boot # activate at next boot (kernel updates)
nixos-update --input nixpkgs
nixos-activate # build -> diff -> confirm -> activate; updates only `activateInputs` (default: none)
nixos-activate --dry-run # preview only, flake.lock remains unchanged
Both commands are installed by the module. nixos-activate applies edited
configuration using the existing lock; it is NOT nix flake update. With
programs.nixos-update.activateInputs = [ "pi" ]; it additionally updates just
those inputs (offline: falls back to the lock; --no-update skips it).
Both build without implicit lock updates and activate the exact closure shown
in the diff (nixos-rebuild --no-reexec --store-path, required). --no-reexec
prevents a legacy self-rebuild looking for <nixpkgs/nixos>/nixos-config.
Confirmation uses [Y/n]: Enter confirms, n cancels, EOF cancels. Updates restore the old
lock on cancellation/failure/dry-run. Existing uncommitted lock changes require
--no-commit or a prior commit; unrelated staged files are never committed.
The build stays GC-rooted until activation finishes. bash tests.sh exercises
the workflows using command stubs (no real system changes).
The flake directory is $NIXOS_UPDATE_FLAKE, else /etc/nixos (a symlinked
flake.nix is followed into its git clone). --flake DIR overrides both.
Use on any NixOS machine
nix run git+https://git.samaschke.de/ksamaschke/nixos-update -- --dry-run
nix run git+https://git.samaschke.de/ksamaschke/nixos-update#nixos-activate -- --dry-run
or as a module in the system flake:
inputs.nixos-update.url = "git+https://git.samaschke.de/ksamaschke/nixos-update";
# in the host's modules:
nixos-update.nixosModules.default
{ programs.nixos-update = { enable = true; flake = "/home/me/nixos-config"; }; }
The module installs the command and turns on weekly garbage collection
(keepDays, default 14), store optimisation and a boot-menu limit
(bootEntries, default 20). All of it uses mkDefault, so host settings win.