nixos-rebuild-ng: enable reexec if system.rebuild.enableNg is enabled
This commit is contained in:
@@ -48,6 +48,7 @@ let
|
|||||||
nixos-rebuild-ng = pkgs.nixos-rebuild-ng.override {
|
nixos-rebuild-ng = pkgs.nixos-rebuild-ng.override {
|
||||||
nix = config.nix.package;
|
nix = config.nix.package;
|
||||||
withNgSuffix = false;
|
withNgSuffix = false;
|
||||||
|
withReexec = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultConfigTemplate = ''
|
defaultConfigTemplate = ''
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
runCommand,
|
runCommand,
|
||||||
scdoc,
|
scdoc,
|
||||||
withNgSuffix ? true,
|
withNgSuffix ? true,
|
||||||
|
withReexec ? false,
|
||||||
withShellFiles ? true,
|
withShellFiles ? true,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -48,6 +49,7 @@ python3Packages.buildPythonApplication rec {
|
|||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace nixos_rebuild/__init__.py \
|
substituteInPlace nixos_rebuild/__init__.py \
|
||||||
--subst-var-by executable ${executable} \
|
--subst-var-by executable ${executable} \
|
||||||
|
--subst-var-by withReexec ${lib.boolToString withReexec} \
|
||||||
--subst-var-by withShellFiles ${lib.boolToString withShellFiles}
|
--subst-var-by withShellFiles ${lib.boolToString withShellFiles}
|
||||||
|
|
||||||
substituteInPlace pyproject.toml \
|
substituteInPlace pyproject.toml \
|
||||||
|
|||||||
@@ -248,22 +248,14 @@ def reexec(
|
|||||||
flake_build_flags: dict[str, Args],
|
flake_build_flags: dict[str, Args],
|
||||||
) -> None:
|
) -> None:
|
||||||
drv = None
|
drv = None
|
||||||
|
attr = "config.system.build.nixos-rebuild"
|
||||||
try:
|
try:
|
||||||
# Need to set target_host=None, to avoid connecting to remote
|
# Need to set target_host=None, to avoid connecting to remote
|
||||||
if flake := Flake.from_arg(args.flake, None):
|
if flake := Flake.from_arg(args.flake, None):
|
||||||
drv = nix.build_flake(
|
drv = nix.build_flake(attr, flake, **flake_build_flags, no_link=True)
|
||||||
"pkgs.nixos-rebuild-ng",
|
|
||||||
flake,
|
|
||||||
**flake_build_flags,
|
|
||||||
no_link=True,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
drv = nix.build(
|
build_attr = BuildAttr.from_arg(args.attr, args.file)
|
||||||
"pkgs.nixos-rebuild-ng",
|
drv = nix.build(attr, build_attr, **build_flags, no_out_link=True)
|
||||||
BuildAttr.from_arg(args.attr, args.file),
|
|
||||||
**build_flags,
|
|
||||||
no_out_link=True,
|
|
||||||
)
|
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
logger.warning("could not find a newer version of nixos-rebuild")
|
logger.warning("could not find a newer version of nixos-rebuild")
|
||||||
|
|
||||||
@@ -306,7 +298,7 @@ def execute(argv: list[str]) -> None:
|
|||||||
# Re-exec to a newer version of the script before building to ensure we get
|
# Re-exec to a newer version of the script before building to ensure we get
|
||||||
# the latest fixes
|
# the latest fixes
|
||||||
if (
|
if (
|
||||||
False # disabled until we introduce `config.system.build.nixos-rebuild-ng`
|
"@withReexec@" == "true"
|
||||||
and can_run
|
and can_run
|
||||||
and not args.fast
|
and not args.fast
|
||||||
and not os.environ.get("_NIXOS_REBUILD_REEXEC")
|
and not os.environ.get("_NIXOS_REBUILD_REEXEC")
|
||||||
|
|||||||
Reference in New Issue
Block a user