nixos/tools: add system.rebuild.enableNg

This commit is contained in:
Thiago Kenji Okada 2024-12-05 19:22:01 +00:00
parent 9ad61cfc19
commit ae6664cc51
2 changed files with 17 additions and 2 deletions

View File

@ -45,6 +45,10 @@ let
nixos-install = pkgs.nixos-install.override { nix = config.nix.package; };
nixos-rebuild = pkgs.nixos-rebuild.override { nix = config.nix.package; };
nixos-rebuild-ng = pkgs.nixos-rebuild-ng.override {
nix = config.nix.package;
withNgSuffix = false;
};
defaultConfigTemplate = ''
# Edit this configuration file to define what should be installed on
@ -214,6 +218,13 @@ in
'';
};
options.system.rebuild.enableNg = lib.mkEnableOption "" // {
description = ''
Whether to use nixos-rebuild-ng in place of nixos-rebuild, the
Python-based re-implementation of the original in Bash.
'';
};
imports = let
mkToolModule = { name, package ? pkgs.${name} }: { config, ... }: {
options.system.tools.${name}.enable = lib.mkEnableOption "${name} script" // {
@ -240,7 +251,11 @@ in
# These may be used in auxiliary scripts (ie not part of toplevel), so they are defined unconditionally.
system.build = {
inherit nixos-generate-config nixos-install nixos-rebuild;
inherit nixos-generate-config nixos-install;
nixos-rebuild =
if config.system.rebuild.enableNg
then nixos-rebuild-ng
else nixos-rebuild;
nixos-option = lib.warn "Accessing nixos-option through `config.system.build` is deprecated, use `pkgs.nixos-option` instead." pkgs.nixos-option;
nixos-enter = lib.warn "Accessing nixos-enter through `config.system.build` is deprecated, use `pkgs.nixos-enter` instead." pkgs.nixos-enter;
};

View File

@ -105,7 +105,7 @@ ruff format .
old `nixos-rebuild`)
- [x] `_NIXOS_REBUILD_REEXEC`
- [ ] Port `nixos-rebuild.passthru.tests`
- [ ] Change module system to allow easier opt-in, like
- [x] Change module system to allow easier opt-in, like
`system.switch.enableNg` for `switch-to-configuration-ng`
- [x] Improve documentation
- [x] `nixos-rebuild repl`