Closed bonds closed 2 months ago
I'll comment here since the issue on the fork was closed and yes in theory it'll effect base nh.
We can see here that the hostname is an optional argument https://github.com/viperML/nh/blob/master/src/interface.rs#L102 Then here we take that argument, but importantly when it isn't provided it fetches it using the hostname crate https://crates.io/crates/hostname. https://github.com/viperML/nh/blob/master/src/nixos.rs#L45-L48
now over in the issue on the fork you show that you do not specify a hostname manually and therefore the hostname crate should be used. You also show that when running hostname in your shell you get your expected computer hostname with the .local domain.
Unfortunately I'm not sure why that is happening. On my own machines I do see in settings > general > sharing that the hostname does end in .local, but I've never experienced it showing up in the substitution to the nix build command.
I have two hostname binaries on my machies one from uutils coreutils and the other from apple both do not have local at the end and I'm running Sonoma 14.6.1.
The double double quotes you show in your other issue seems to be a non issue, I'm not sure honestly but it shows on my machine with no issue, and I'm not sure why removing your computer name from the double quotes fixed things as that is a core nix thing and not a nh thing.
So essentially sorry I didn't get the change to comment on the fork issue before you came here but I still don't know why you have these issues.
Thanks @ToyVo ! Maybe this is all something weird and specific to my machine, but I figure just in case it's not I should let the people smarter than me know about it and decide what's the right thing to do. Plus its hard for me to resist a good mystery. :)
For good measure I checked:
$ which hostname
/bin/hostname
Can you run with --verbose and paste the output?
Here's what running with --verbose shows:
$ nh_darwin --verbose os switch .
TRACE nh_darwin::logging:86: Logging OK
DEBUG nh_darwin:24: args=NHParser { verbose: true, elevation_program: None, command: Os(OsArgs { action: Switch(OsRebuildArgs { common: CommonRebuildArgs { dry: false, ask: false, update: false, pull: false, no_nom: false, diff_provider: "nvd diff", out_link: None }, flakeref: FlakeRef("."), hostname: None, specialisation: None, no_specialisation: false, extra_args: [], bypass_root_check: false }) }) }
DEBUG nh_darwin:27: path="/nix/store/km3c37gszw4bzz2vbdrq7dm8r2mb1fng-nvd-0.2.3/bin:/nix/store/4sjkgb128h71an4yvma8mc98y2vl4gid-nix-output-monitor-2.1.2/bin:/Users/scott/bin/darwin:/Users/scott/bin:/Users/scott/.local/bin:/Users/scott/.cargo/bin:/Users/scott/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
DEBUG nh_darwin::nixos:56: out_path=("/var/folders/vz/56khkw3d73b1nrr27x6wz0dh0000gn/T/nh-oshPI6gF/result", TempDir { path: "/var/folders/vz/56khkw3d73b1nrr27x6wz0dh0000gn/T/nh-oshPI6gF" })
DEBUG nh_darwin::nixos:66: flakeref is owned by root: false
> Building Darwin configuration
DEBUG nh_darwin::commands:156: cmd=Pipeline { nix build '.#darwinConfigurations.""accismus.local"".config.system.build.toplevel' --log-format internal-json --verbose --out-link /var/folders/vz/56khkw3d73b1nrr27x6wz0dh0000gn/T/nh-oshPI6gF/result | nom --json }
fetching git input 'git+file:///Users/scott'
error: flake 'git+file:///Users/scott?dir=.config/nix' does not provide attribute 'packages.aarch64-darwin.darwinConfigurations.""accismus.local"".config.system.build.toplevel', 'legacyPackages.aarch64-darwin.darwinConfigurations.""accismus.local"".config.system.build.toplevel' or 'darwinConfigurations.""accismus.local"".config.system.build.toplevel'
┏━ 1 Errors:
┃ error: flake 'git+file:///Users/scott?dir=.config/nix' does not provide attribute 'package…
┣━━━
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 13:35:03 after 0s
Error:
0: Command exited with status Exited(1)
Location:
src/commands.rs:170
Ah, I see this is caused by https://github.com/viperML/nh/pull/140
I will push a fix this week. Ideally I would be doing some sanity checks on what is passed to nix build, but I don't.
Over on nh_darwin, this has been fixed by taking more inspiration from the darwin-rebuild script to account for the .local part
The actual reason is that on macOS gethostname call returns the FQDN, causing nh_darwin to read that. However, darwin-rebuild calls scutil --get LocalHostName which returns just the hostname part. ~@thecaralice
I would be happy to know what the problem is
I would be happy to know what the problem is
There are multiple ways to define what a hostname is, a good example of that being hostname(1)
. nh
calls hostname::get
, which in turn calls gethostname(3)
, just like hostname(1)
with no arguments. nixos-rebuild
reads the /proc/sys/kernel/hostname
file, which happens to match what gethostname(3)
returns. However, darwin-rebuild
calls scutil --get LocalHostName
, which returns the part of the hostname before the period, like hostname(1)
with -s
flag provided.
A hostname ending in .local does not work, see https://github.com/ToyVo/nh_darwin/issues/12#issuecomment-2322988194
Unfortunately macos doesn't let me remove the
.local
part of the hostname. I filed the ticket withnh_darwin
but was told this is maybe an issue that needs to be fixed upstream innh
.