Skip to content

nixos-rebuild-ng: validate NixOS config path in target host#419006

Merged
thiagokokada merged 1 commit intoNixOS:masterfrom
thiagokokada:fix-418868
Jun 22, 2025
Merged

nixos-rebuild-ng: validate NixOS config path in target host#419006
thiagokokada merged 1 commit intoNixOS:masterfrom
thiagokokada:fix-418868

Conversation

@thiagokokada
Copy link
Copy Markdown
Contributor

In #418243 we started to validate NixOS config path to avoid a nasty bug in Nix, but this doesn't work in the --build-host and --target-host case because the configuration will not be available in the local host to check if it contains a nixos-version. This moves the check to --target-host instead, that is probably the correct choice anyway.

Fix #418868.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@thiagokokada
Copy link
Copy Markdown
Contributor Author

CC @Doosty for testing.
CC @tejing1 for review.

In NixOS#418243 we started to validate NixOS config path to avoid a nasty bug
in Nix, but this doesn't work in the `--build-host` and `--target-host`
case because the configuration will not be available in the local host
to check if it contains a `nixos-version`. This moves the check to
`--target-host` instead, that is probably the correct choice anyway.

Fix NixOS#418868.
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS labels Jun 22, 2025
@tejing1
Copy link
Copy Markdown
Contributor

tejing1 commented Jun 22, 2025

Oops... Yeah, that's a more sensible place to put it.

Looks good.

@Doosty
Copy link
Copy Markdown

Doosty commented Jun 22, 2025

Seems to work for me, when it did not before

❯ nix run github:thiagokokada/nixpkgs/0f6624e21a7300a11029507e7c6638a7689ff5a5#nixos-rebuild-ng -- switch --flake .#vmcloud-server --target-host root@MYIP --build-host root@MYIP  --show-trace
building the system configuration...
copying 0 paths...
activating the configuration...
setting up /etc...
reloading user units for myuser...
reloading user units for root...
restarting sysinit-reactivation.target
reloading the following units: dbus.service
Done. The new configuration is /nix/store/91f1vyhys9c2ywn2ak311pjiq6rxvkzj-nixos-system-vmcloud-server-25.11.20250619.08f2208

@thiagokokada thiagokokada merged commit 7850e6a into NixOS:master Jun 22, 2025
25 of 27 checks passed
@thiagokokada thiagokokada deleted the fix-418868 branch June 22, 2025 16:19
@nixpkgs-ci
Copy link
Copy Markdown
Contributor

nixpkgs-ci bot commented Jun 22, 2025

Successfully created backport PR for release-25.05:

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nixos-rebuild-ng: --build-host and --target-host

3 participants