nixos-rebuild-ng: use nix-env --list-generations everywhere - #567183
Draft
thiagokokada wants to merge 2 commits into
Draft
thiagokokada wants to merge 2 commits into
thiagokokada wants to merge 2 commits into
Conversation
Now that NixOS/nix#16523 is merged, we can remove the previous `nix.get_generations()` that was basically an reimplementation of `nix-env --list-generations` in Python. This renames the previous `nix.get_generations_from_nix_env()` to `nix.get_generations()` too. For context, the reason we had `nix.get_generations{,from_nix_env}` before was: - For `nixos-rebuild list-generations`, we want to run it as a normal (i.e., non-root) user. - For `nixos-rebuild switch --rollback`, it doesn't matter if the user is root or not, but we want to also allow the user to run this for remote hosts (the Python code only worked locally). So `nix.get_generations()` covered the first case (locally without root), and `nix.get_generations_from_nix_env()` covered the second case (remotely with root). Now `nix-env --list-generations` works without root we can always use it.
This check is incorrect for remote targets (we need to check the remote not the local if the profile path exists). Moving the check to the callers of the function instead when we return no generations.
Contributor
Author
|
Waiting until NixOS/nix#16523 is released in a stable version and that version becomes the default in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Now that NixOS/nix#16523 is merged, we can remove the previous
nix.get_generations()that was basically an reimplementation ofnix-env --list-generationsin Python. This renames the previousnix.get_generations_from_nix_env()tonix.get_generations()too.For context, the reason we had
nix.get_generations{,from_nix_env}before was:
nixos-rebuild list-generations, we want to run it as a normal (i.e., non-root) user.nixos-rebuild switch --rollback, it doesn't matter if the user is root or not, but we want to also allow the user to run this for remote hosts (the Python code only worked locally).So
nix.get_generations()covered the first case (locally without root), andnix.get_generations_from_nix_env()covered the second case (remotely with root). Nownix-env --list-generationsworks without root we can always use it.Fix #435555.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.