nix/nixos/users/albert/switcher.nix
2023-12-13 21:01:21 +09:00

34 lines
No EOL
858 B
Nix

{self, ...}: {
pkgs,
config,
...
}: {
# https://github.com/NobbZ/nixos-config/blob/a1c99894088f43a0ba31812ad53f0e09dc36f15a/nixos/modules/switcher.nix#L14-L31
_file = ./switcher.nix;
environment.systemPackages = [self.packages."${pkgs.system}".switcher];
security.sudo.extraRules = let
storePrefix = "/nix/store/*";
systemName = "nixos-system-${config.networking.hostName}-*";
in [
{
commands = [
{
command = "${storePrefix}-nix-*/bin/nix-env -p /nix/var/nix/profiles/system --set ${storePrefix}-${systemName}";
options = ["NOPASSWD"];
}
];
groups = ["wheel"];
}
{
commands = [
{
command = "${storePrefix}-${systemName}/bin/switch-to-configuration";
options = ["NOPASSWD"];
}
];
groups = ["wheel"];
}
];
}