Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opening a PR to collect early feedback before I sink more time in this. Keep in mind that while code reviews are welcome, this is not the focus for this PR yet.
The current state of
nixos-rebuild
is dare: it is one of the most critical piece of code we have in NixOS, but it has tons of issues:nix
had over the years, e.g.: it builds Flakes inside a temporary directory and read the resulting symlink since the code seems to predate--print-out-paths
flagGiven all of those above, improvements in the
nixos-rebuild
are difficult to do. A full rewrite is probably the easier way to improve the situation since this can be done in a separate package that will not broke anyone. So this is an attempt of the rewrite.The language of choice here is Python. I am open to other options here, and I mostly choose Python since it is the language I am most comfortable here, but I am open for other options. Still, I think Python is a good choice because:
nixpkgs
, like theNixOSTestVM
andsystemd-boot
activation scriptsmypy
for type checking,ruff
for linting,pytest
for unit testingnixos-rebuild
currently depends injq
for JSON parsing, while Python hasjson
in standard libraryI am aware about the current
switch-to-configuration-ng
rewrite, however I am not sure what is the scope of that project vsnixos-rebuild
. If the idea is just a drop-in replacement than both of those rewrites are ortogonal, sincenixos-rebuild
also includes some extra logic for e.g.: profile management. If the idea is to migrate more and more logic toswitch-to-configuration-ng
and eventually dropnixos-rebuild
, I am happy to close this PR.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.