+5
-1
pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
·········
·········
nixos-rebuild: restore local sudo functionality
This functionality used to exist and was then removed in #331741. The
issue was that $SUDO_USER is already used by `sudo` as an environment
variable.
This change makes it possible to checkout a flake repository, as a user,
enter the devshell, and with the additions below and apply changes with
`nixos-rebuild switch`.
```nix
{ pkgs }:
let
nixos-rebuild = pkgs.writeShellApplication {
name = "nixos-rebuild";
runtimeInputs = [ pkgs.nixos-rebuild ];
text = ''
set -euo pipefail
exec nixos-rebuild --flake "$PRJ_ROOT" --use-local-sudo "$@"
'';
};
in
pkgs.mkShellNoCC {
packages = [
nixos-rebuild
];
shellHook = ''
export PRJ_ROOT=$PWD
'';
}
```
·········
·········