feat(apply): Don't re-exec as root by default and add a flag for escalating to root locally#155
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cb01dec to
240b929
Compare
|
While I am on board with not re-executing as root, it does raise the question of whether or not we want re-execution at all by default. It has been a feature since the early days of Either the user would like for the non-root eval cache to be used at all times, and we should only elevate the functionality that requires it (i.e. a la the I personally think that we should go the
And to simply fail with "permission denied" errors in the cases where these are not able to be ran, describing the error as such and the fact that adding There is a slight problem with elevating as necessary, though. From what I understand, a user may have to type in their password at least two times: one for Nix profile modifications, and another for local switch-to-configuration. This seems unwieldy to me, but as far as I know there is no way around it. In the case that a user does want the previous re-execution as root behavior, this can be controlled through a setting (i.e. |
|
Though I'd prefer it was automatic, I'm fine with a flag for elevating to root, as I can just add it to the relevant aliases. I'm not sure about calling it For the re-exec setting, I think it should also apply to nix channel upgrades (on top of local activations). And as for the "permission denied" errors, should we handle that by failing if the uid is not root and
Unless I'm misunderstanding you, elevating as necessary is what this patch does, just without having to specify a flag. I'm using it now with |
Agreed, let's call it that instead.
Yes, which is the previous functionality as well. To clarify, I am talking about re-execution of the process in-place using What I am trying to propose we do instead, is that we do not re-execute the whole process in place and instead pass
Yes, due to the in-place re-execution this does not happen at the moment. I'm saying if we do remove that like I said, a user that passes Sorry if this has been confusing, I am talking about multiple things at once that you haven't necessarily touched in the PR. I just don't think a flag for in-place re-execution is the right thing to do, but I am willing to be convinced otherwise. |
240b929 to
eca3eea
Compare
Yes, I agree completely here.
See, this is the misunderstanding. Even without re-execution, passing Anyways, I've the added |
water-sucks
left a comment
There was a problem hiding this comment.
Looks great! Just one suggestion beforehand; when you mark as resolved, I'll merge.
…lating to root locally The new option `--local-root` provides behaviour equal to that of `nixos-rebuild --sudo` by escalating certain operations as necessary: - Channel upgrades - Local Nix profile modifications - Local switch-to-configuration runs By not re-executing by default we avoid bypassing a non-root user's eval cache when running `nixos apply` after having already built the configuration. The previous behaviour can be enabled with the new setting `apply.reexec_as_root`.
eca3eea to
9be2dd9
Compare
The new option
--local-rootprovides behaviour equal to that ofnixos-rebuild --sudoby escalating certain operations as necessary:
By not re-executing by default we avoid bypassing a non-root user's eval cache
when running
nixos applyafter having already built the configuration.The previous behaviour can be enabled with the new setting
apply.reexec_as_root.Additionally, channel upgrades now always run as root (see NixOS/nixpkgs@028893d7)