sync
# Install
- hydrate ${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch
+ hydrate ${config.system.build.nixos-rebuild}/bin/nixos-rebuild ${cfg.operation}
sync
while read user;do
- remove_arg=-r
- if [[ "$(userenv_query "$user" .otherPackagesAction)" == keep ]];then
- remove_arg=
- fi
+ configured_action=$(userenv_query "$user" .otherPackagesAction)
+ action=
+ case "$configured_action" in
+ keep) action=-i;;
+ remove) action=-ir;;
+ set-remove) action=--set;;
+ *) die "Unexpected otherPackagesAction $configured_action for user $user"
+ esac
hydrate /run/wrappers/bin/sudo -u "$user" \
- ${pkgs.nix}/bin/nix-env -f '<nixpkgs>' $remove_arg -iA "$(userenv_query "$user" .package)"
+ ${pkgs.nix}/bin/nix-env -f '<nixpkgs>' "$action" -A "$(userenv_query "$user" .package)"
sync
done < <( config_query '.userEnvironments | keys []' )
''}
'';
};
+ operation = lib.mkOption {
+ type = lib.types.enum [
+ "switch"
+ "boot"
+ ];
+ default = "switch";
+ example = "boot";
+ description = ''
+ Whether to run
+ `nixos-rebuild switch --upgrade` or run
+ `nixos-rebuild boot --upgrade`
+ '';
+ };
+
signingKeys = mkOption {
type = types.listOf types.path;
description = ''
security.sudo.extraRules = lib.mkAfter [
{
groups = [ "users" ];
+ runAs = "root";
commands = [
{
command = "${auto-upgrade-script}";