Skip to content

Commit 83ef7bf

Browse files
authored
nixos-rebuild-ng: implement the remaining missing features (#360215)
2 parents b6bd36b + 98e9372 commit 83ef7bf

File tree

14 files changed

+934
-351
lines changed

14 files changed

+934
-351
lines changed

pkgs/by-name/ni/nixos-rebuild-ng/README.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,6 @@ ruff format .
9191
conflicting with the current `nixos-rebuild`. This means you can keep both in
9292
your system at the same time, but it also means that a few things like bash
9393
completion are broken right now (since it looks at `nixos-rebuild` binary)
94-
- `_NIXOS_REBUILD_EXEC` is **not** implemented yet, so different from
95-
`nixos-rebuild`, this will use the current version of `nixos-rebuild-ng` in
96-
your `PATH` to build/set profile/switch, while `nixos-rebuild` builds the new
97-
version (the one that will be switched) and re-exec to it instead. This means
98-
that in case of bugs in `nixos-rebuild-ng`, the only way that you will get
99-
them fixed is **after** you switch to a new version
100-
- `nix` bootstrap is also **not** implemented yet, so this means that you will
101-
eval with an old version of Nix instead of a newer one. This is unlikely to
102-
cause issues, because the build will happen in the daemon anyway (that is
103-
only changed after the switch), and unless you are using bleeding edge `nix`
104-
features you will probably have zero problems here. You can basically think
105-
that using `nixos-rebuild-ng` is similar to running `nixos-rebuild --fast`
106-
right now
107-
- Ignore any performance advantages of the rewrite right now, because of the 2
108-
caveats above
109-
- `--target-host` and `--build-host` are not implemented yet and this is
110-
probably the thing that will be most difficult to implement. Help here is
111-
welcome
11294
- Bugs in the profile manipulation can cause corruption of your profile that
11395
may be difficult to fix, so right now I only recommend using
11496
`nixos-rebuild-ng` if you are testing in a VM or in a filesystem with
@@ -118,20 +100,29 @@ ruff format .
118100

119101
## TODO
120102

121-
- [ ] Remote host/builders (via SSH)
103+
- [x] Remote host/builders (via SSH)
122104
- [x] Improve nix arguments handling (e.g.: `nixFlags` vs `copyFlags` in the
123105
old `nixos-rebuild`)
124-
- [ ] `_NIXOS_REBUILD_EXEC`
106+
- [x] `_NIXOS_REBUILD_REEXEC`
125107
- [ ] Port `nixos-rebuild.passthru.tests`
126108
- [ ] Change module system to allow easier opt-in, like
127109
`system.switch.enableNg` for `switch-to-configuration-ng`
128110
- [ ] Improve documentation
129-
- [ ] `nixos-rebuild repl` (calling old `nixos-rebuild` for now)
130-
- [ ] `nix` build/bootstrap
111+
- [x] `nixos-rebuild repl`
131112
- [ ] Generate tab completion via [`shtab`](https://docs.iterative.ai/shtab/)
132113
- [x] Reduce build closure
133114

134115
## TODON'T
135116

136-
- Reimplement `systemd-run` logic (will be moved to the new
137-
[`apply`](https://github.com/NixOS/nixpkgs/pull/344407) script)
117+
- Reimplement `systemd-run` logic: will be moved to the new
118+
[`apply`](https://github.com/NixOS/nixpkgs/pull/344407) script
119+
- Nix bootstrap: it is only used for non-Flake paths and it is basically
120+
useless nowadays. It was created at a time when Nix was changing frequently
121+
and there was a need to bootstrap a new version of Nix before evaluating the
122+
configuration (otherwise the new Nixpkgs version may have code that is only
123+
compatible with a newer version of Nix). Nixpkgs now has a policy to be
124+
compatible with Nix 2.3, and even if this is bumped as long we don't do
125+
drastic minimum version changes this should not be an issue. Also, the daemon
126+
itself always run with the previous version since even we can replace Nix in
127+
`PATH` (so Nix client), but we can't replace the daemon without switching to
128+
a new version.

pkgs/by-name/ni/nixos-rebuild-ng/package.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ python3Packages.buildPythonApplication rec {
3939
nix
4040
];
4141

42-
preBuild = ''
43-
substituteInPlace nixos_rebuild/__init__.py \
44-
--subst-var-by nixos_rebuild ${lib.getExe nixos-rebuild}
45-
'';
46-
4742
postInstall =
4843
''
4944
installManPage ${nixos-rebuild}/share/man/man8/nixos-rebuild.8

0 commit comments

Comments
 (0)