Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostname ending in .local does not work #149

Closed
bonds opened this issue Sep 1, 2024 · 9 comments
Closed

hostname ending in .local does not work #149

bonds opened this issue Sep 1, 2024 · 9 comments

Comments

@bonds
Copy link

bonds commented Sep 1, 2024

A hostname ending in .local does not work, see ToyVo#12 (comment)

Unfortunately macos doesn't let me remove the .local part of the hostname. I filed the ticket with nh_darwin but was told this is maybe an issue that needs to be fixed upstream in nh.

@ToyVo
Copy link

ToyVo commented Sep 1, 2024

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.

@bonds
Copy link
Author

bonds commented Sep 1, 2024

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

@viperML
Copy link
Owner

viperML commented Sep 1, 2024

Can you run with --verbose and paste the output?

@bonds
Copy link
Author

bonds commented Sep 1, 2024

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

@viperML
Copy link
Owner

viperML commented Sep 1, 2024

Ah, I see this is caused by #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.

@ToyVo
Copy link

ToyVo commented Sep 7, 2024

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

@viperML
Copy link
Owner

viperML commented Sep 7, 2024

I would be happy to know what the problem is

@thecaralice
Copy link

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.

@viperML
Copy link
Owner

viperML commented Sep 9, 2024

@viperML viperML closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants