Commit graph

947 commits

Author SHA1 Message Date
raf
ec31d400f7
Merge pull request #526 from faukah/push-ktkqmuzzlwkq
Some checks failed
Build NH / Build NH on Linux (push) Has been cancelled
Build NH / Build NH on Darwin (push) Has been cancelled
Check formating & lints / treewide-checks (push) Has been cancelled
Tag version / main (push) Has been cancelled
Test NH / Test NH on Linux (push) Has been cancelled
Test NH / Test NH on Darwin (push) Has been cancelled
chore: bump dependencies
2026-01-08 23:22:06 +03:00
faukah
f467418778 chore: bump dependencies 2026-01-08 21:01:36 +01:00
NotAShelf
5f279c597e
chore: bump crate version
Some checks failed
Build NH / Build NH on Linux (push) Has been cancelled
Build NH / Build NH on Darwin (push) Has been cancelled
Check formating & lints / treewide-checks (push) Has been cancelled
Tag version / main (push) Has been cancelled
Test NH / Test NH on Linux (push) Has been cancelled
Test NH / Test NH on Darwin (push) Has been cancelled
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I231966751c35e5ca390f58a8afc52e996a6a6964
2026-01-07 11:12:30 +03:00
raf
d47475dd36
Merge pull request #497 from nix-community/notashelf/push-xwtloylwummt
treewide: refactor `--build-host` to use remote build semantics
2026-01-07 10:38:37 +03:00
NotAShelf
ed1e21a092
nixos: move SSH guard from execute_build to rebuild_and_activate
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib42fe0268a9852055e283deeac4606f66a6a6964
2026-01-07 10:26:40 +03:00
NotAShelf
288b3e9ef3
nixos: move essential files list into a constant
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: If55c758a3ef8022ac2a9798be31a0ffa6a6a6964
2026-01-07 10:26:39 +03:00
NotAShelf
67d12846a2
nix: disable tests requiring sudo on Darwin
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id2ae10eae0c6aa66034c5bf725c9447f6a6a6964
2026-01-07 10:26:38 +03:00
NotAShelf
9bc6d79bf3
commands: handle "program:" prefix in \ElevationStrategyArg\ parsing
The program prefix was advertised as valid, but it actually wasn't
because I regressed it during a different refactor. Strip the "program:"
prefix when present to correctly parse elevation paths, and add a
regression test so that I don't mess it up again.

The deprecation warning advertised "program:<path>" as a valid value but the
parser treated it as a literal path. Strip the "program:" prefix when present
to correctly parse elevation program paths. Add unit test for this case.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I33de2df17654f95a656a4ee649cf7c9b6a6a6964
2026-01-06 16:43:45 +03:00
raf
bab129e36d
Merge pull request #521 from faukah/faukah/add-sudo-to-nativeCheckInputs
nix: add sudo to `nativeCheckInputs`
2026-01-05 12:22:35 +03:00
faukah
97d0d7ca00 nix/package: add sudo to nativeCheckInputs 2026-01-05 10:00:42 +01:00
raf
ac0ee87fef
Merge branch 'master' into notashelf/push-xwtloylwummt
Some checks failed
Build NH / Build NH on Linux (push) Has been cancelled
Build NH / Build NH on Darwin (push) Has been cancelled
Check formating & lints / treewide-checks (push) Has been cancelled
Test NH / Test NH on Linux (push) Has been cancelled
Test NH / Test NH on Darwin (push) Has been cancelled
2026-01-05 00:43:12 +03:00
NotAShelf
1c44bc4835
various: add ElevationStrategyArg for type-safe CLI parsing
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I8837714ede1884ef22c9c0f0c10016746a6a6964
2026-01-05 00:42:00 +03:00
NotAShelf
260799845e
treewide: change elevation program to elevation strategy
This is a massive change, and it primarily concerns
`--elevation-*program*` not making any sense for remote operations. The
change to *strategy* allows the flag to be more descriptive in terms of
how it operates, and allows us to add new strategies to handle.

Fixes https://github.com/nix-community/nh/issues/434

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9e51838007feca7d2d914402d7f11dbc6a6a6964
2026-01-05 00:41:59 +03:00
NotAShelf
38bd0d20d7
treewide: consolidate remote activation logic into nh::remote
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I3a52c45ee7fd9f9ab27bed587a2c57336a6a6964
2026-01-04 17:31:34 +03:00
NotAShelf
a868222d2c
various: fix minor typos
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I1bf3cecd4d5a8d055cbe43b5075372426a6a6964
2026-01-04 17:31:33 +03:00
NotAShelf
00e1d23df8
xtask: populate ENVIRONMENT section in manpages
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6cfae3f78880cd471815bcd4b438823c6a6a6964
2026-01-04 17:31:32 +03:00
NotAShelf
5c959c8478
docs: move everything to docs dir; minor cleanup
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ifc315034046804817b1aa86e4b9510e86a6a6964
2026-01-04 17:31:17 +03:00
NotAShelf
97eaee12ec
generations: degrade gracefully when profile is out of sync
Some checks failed
Build NH / Build NH on Linux (push) Has been cancelled
Build NH / Build NH on Darwin (push) Has been cancelled
Check formating & lints / treewide-checks (push) Has been cancelled
Tag version / main (push) Has been cancelled
Test NH / Test NH on Linux (push) Has been cancelled
Test NH / Test NH on Darwin (push) Has been cancelled
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I68fc8047286cdc6f64161089ecebd11f6a6a6964
2026-01-03 00:08:12 +03:00
NotAShelf
cc753854ff
interface: clean up descriptions for build_host and target_host
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I2e1e9f814905fca8483cfbe3c3e58d0e6a6a6964
2026-01-02 22:51:28 +03:00
NotAShelf
579cf6c1bd
docs: update changelog to reflect remote build improvements
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I2ac16d3c416ed8c68e3daf0318abd1fb6a6a6964
2026-01-02 22:51:27 +03:00
NotAShelf
f946e9d245
remote: remove unused RemoteHost::host method; update tests & docs
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I1f5c07d0425db0ad156d1606b28fae166a6a6964
2026-01-02 22:15:47 +03:00
NotAShelf
bec6f8ddd0
remote: add IPv6 SSH host transformation
For compatibility and I guess consistency with nixos-rebuild-ng which
*does* this, but ours is bit safer so hah!

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ie6ed6ea08b16acf690c8e4bb56d063546a6a6964
2026-01-02 21:54:48 +03:00
NotAShelf
c552929266
interface: add NH_NO_VALIDATE environment variable support
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I30dce4dea68a07975c58afc475bf37496a6a6964
2026-01-02 21:54:47 +03:00
NotAShelf
30f096ae01
remote: add best-effort process cleanup on interrupt
Implement optional remote process cleanup when user cancels the
operation (i.e., presses Ctrl+C) during a remote build. If the
environment variable NH_REMOTE_CLEANUP is set to `"1"`, `"true`, or
`"yes"` NH will also attempt to run `pkill` on the remote host to
terminate the Nix process. This is implemented to match
nixos-rebuild-ng's cleanup behaviour, but it is opt-in instead of
opt-out due to the fragility of the action.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I555c84087018025b111a51715c5aa42a6a6a6964
2026-01-02 21:54:46 +03:00
NotAShelf
c860cdabb3
nixos: skip canonicalize for remote builds without local results
Some checks are pending
Build NH / Build NH on Linux (push) Waiting to run
Build NH / Build NH on Darwin (push) Waiting to run
Check formating & lints / treewide-checks (push) Waiting to run
Test NH / Test NH on Linux (push) Waiting to run
Test NH / Test NH on Darwin (push) Waiting to run
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I4b2199926f36bc5a1b3c7ec06284d6b16a6a6964
2026-01-02 16:21:03 +03:00
NotAShelf
abc331f9fc
remote: make validation logic more generic; add SSH batching & tiny cleanup
Some checks are pending
Build NH / Build NH on Linux (push) Waiting to run
Build NH / Build NH on Darwin (push) Waiting to run
Check formating & lints / treewide-checks (push) Waiting to run
Test NH / Test NH on Linux (push) Waiting to run
Test NH / Test NH on Darwin (push) Waiting to run
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ibb16d8eb12dd37ce4621b97f982412bc6a6a6964
2026-01-02 03:36:46 +03:00
NotAShelf
eea7516840
remote: allow disabling path validation; better errors
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I22149e081658df72d8ad7f29df184a196a6a6964
2026-01-02 01:49:47 +03:00
NotAShelf
0f676a733d
remote: properly quote SSH command arguments; improve error handling
I've cramped too many things in one commit again. Guess it's better to
explain, generally, what has changed.

The primary "fix" that this commit addresses is SSH command construction
by shell-quoting *all* arguments before passing them to the remote
shell, instead of using SSH's `'--'` separator with individual args.
This helps ensure special chars, spaces and shell metachars in paths (I
blame Nix) or arguments args are handled correctly.

Additionally, there are a few improvements to the "robustness" of remote
copying: previously we'd attempt to copy from build-host to target-host,
which is fine, but we failed fast instead of attempting the logically
correct behaviour which is to COPY BACK and THEN relay to the target
host. If remote-to-remote copy fails, the system now logs a warning and
relays through localhost instead of failing. This makes nh's *fallback
behaviour* (but not the first pass) consistent with nixos-rebuild.

Other than that, some build command consolidation and moderately large
documentation tweaks. The code is getting out of hand, so I'd like to
merge this and be done as soon as possible.

God that was a long summary. Hope someone gets to read this.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib540fc287f1b1e22e2b68b9c9c7b03046a6a6964
2026-01-02 01:49:46 +03:00
NotAShelf
96db8f3e05
nixos: properly escape paths
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iffe2d63b55ee4a9bab41bb6184184add6a6a6964
2026-01-02 01:49:45 +03:00
NotAShelf
a556c71dc5
nixos: validate essential files in'haphazard' remote build semantics
I don't like NixOS' remote builds.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iea646b3b47926536a1bb1a70e3d776fa6a6a6964
2026-01-02 01:49:44 +03:00
NotAShelf
98d23918bb
remote: support ipv6; fix minor quoting issues & add more tests
Here's to you, Dami.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I49e84a3efab65791800348c92b1fc5da6a6a6964
2026-01-02 01:49:43 +03:00
NotAShelf
afcd686e83
remote: implement interrupt handling for remote builds
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I296043d85fd74fc68013dc9f1f3761ea6a6a6964
2026-01-02 01:49:42 +03:00
raf
16371ce2c1
Merge branch 'master' into notashelf/push-xwtloylwummt 2026-01-02 01:49:41 +03:00
NotAShelf
8ff64d3a75
commands: consolidate duplicate logic; drop unused cmdline parser
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia782562b87e2614a390d8f435114142b6a6a6964
2026-01-02 01:49:40 +03:00
NotAShelf
6ad3d11b3b
remote: optimize SSH connections and add proper cleanup
Remove the redundant and poor connectivity checks that added overhead
without any tangible benefit, and implement SSH ControlMaster cleanup on
program exit. This reduces the number of SSH connections made during
remote operations and makes sure SSH control processes are properly
terminated

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ideb1825cb7e8302316d7d25b64e7859b6a6a6964
2026-01-02 01:49:39 +03:00
NotAShelf
deac4d7323
remote: optimize decision matrix to reduce number of connections
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I73a94927d1270b4a499bb22b8220a1326a6a6964
2026-01-02 01:49:38 +03:00
NotAShelf
2add284ccb
remote: handle non-UTF8 strings more explicitly
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Idf201a23f71795e0caea9813280084036a6a6964
2026-01-02 01:49:37 +03:00
NotAShelf
ac353fad19
remote: attempt to reduce remote copy roundtrips
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9eb3904e832e58e0f4ac306d537f7dee6a6a6964
2026-01-02 01:49:37 +03:00
NotAShelf
6f8357dc5a
remote: add a hostname method for normalizing compared hostnames
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: If5d2072431348a8468150abf15a7a2a06a6a6964
2026-01-02 01:49:36 +03:00
raf
9ff86fa142
Merge branch 'master' into notashelf/push-xwtloylwummt 2026-01-02 01:49:35 +03:00
NotAShelf
ac4f86cdc3
remote: consolidate remote connectivitiy checks
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I2366fac6ca7a72fc73eecfc0b07bd2d76a6a6964
2026-01-02 01:49:34 +03:00
raf
3b371f0e84
Merge branch 'master' into notashelf/push-xwtloylwummt 2026-01-02 01:49:33 +03:00
NotAShelf
55719ceeba
remote: add SSH reachability checks; enforce local symlink creation
Tiny improvement to how remote connections are made. We now check BEFORE
the connection is made, so that we can avoid all that expensive eval if
it's not reachable. This is not infallible, but it is better. To fix
some target-host quirks, we also have to deal with local symlinks so we
enforce it locally either way.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I65fd7258828459ea82fe6739383567556a6a6964
2026-01-02 01:49:32 +03:00
NotAShelf
8bb85b6146
various: simplify argument mapping
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia8506cad3352243001a281e99b8162c26a6a6964
2026-01-02 01:49:31 +03:00
NotAShelf
bd947bf7ed
commands: fix error handling in nom pipeline execution
Fixes a minor issue in how commands that are invalid or improperly
handled are forwarded to the Nix command. Replaces `join()` with
`popen()` to access individual processes in the pipeline. This way we
can better check the exist status of the `nix build` process and
properly propagate them.

Also improves naming a little bit because why not?

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I8a44abf924f9c9a1c06d102e5a3f40aa6a6a6964
2026-01-02 01:49:30 +03:00
NotAShelf
28f047f7a7
various: defer shell splitting to shlex
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I0b82e84223c3df61cfa23464bd3d4bcc6a6a6964
2026-01-02 01:49:29 +03:00
NotAShelf
aef1be1b09
various: implement missing --build-host flags for Home and Darwin
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I946d8e54261e9136c83f6dfe38b046106a6a6964
2026-01-02 01:49:28 +03:00
NotAShelf
79340a5061
treewide: refactor --build-host to use remote build semantics
Fixes https://github.com/nix-community/nh/issues/428

This is a large architectural change to NH, which lead to me extracting
the remote build logic to its own file so that we may implement it for
Darwin and Home-Manager as well. The `--builders` flag was dropped from
`nh::commands`, and it was replaced with the new and shiny logic that 
hopefully avoids previous pitfalls.

The new `nh::remote` module handles remote builds, including:

- Parsing remote host specifications.
- Copying derivations to remote hosts using `nix-copy-closure`.
- Building derivations on remote hosts via `nix build`.
- Copying results back to localhost or directly to a target host.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I236eb1e35dd645f2169462d207bc82e76a6a6964
2026-01-02 01:49:27 +03:00
NotAShelf
882f2e25c0
interface: deprecate --no-registries following upstream Nix
Some checks are pending
Build NH / Build NH on Linux (push) Waiting to run
Build NH / Build NH on Darwin (push) Waiting to run
Check formating & lints / treewide-checks (push) Waiting to run
Tag version / main (push) Waiting to run
Test NH / Test NH on Linux (push) Waiting to run
Test NH / Test NH on Darwin (push) Waiting to run
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I3c2a6a78a5ea6f6014b7c7fc0bdfc3016a6a6964
2026-01-02 01:47:43 +03:00
NotAShelf
2f527ef962
flake: bump Nixpkgs
Some checks failed
Tag version / main (push) Has been cancelled
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I39cf506604bf244e75312394afb03abd6a6a6964
2025-12-27 17:06:10 +03:00