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

Period in username not "escaped" #135

Closed
horriblename opened this issue Jul 16, 2024 · 7 comments · Fixed by #140
Closed

Period in username not "escaped" #135

horriblename opened this issue Jul 16, 2024 · 7 comments · Fixed by #140

Comments

@horriblename
Copy link

on my work laptop my username is "firstname.lastname" and running nh home switch . gives this error:

'...' does not provide attribute 'packages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage', 'legacyPackages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage' or 'homeConfigurations.firstname.lastname.config.home.activationPackage'

-c firstname.lastname doesn't help either

@viperML
Copy link
Owner

viperML commented Jul 16, 2024

Could paste the output with --verbose?

@horriblename
Copy link
Author

TRACE nh::logging:86: Logging OK
DEBUG nh:21: args=NHParser { verbose: true, command: Home(HomeArgs { subcommand: Switch(HomeRebuildArgs { common: CommonRebuildArgs { dry: false, ask: false, flakeref: FlakeRef("."), update: false, no_nom: false, diff_provider: "nvd diff" }, configuration: None, extra_args: [], backup_extension: None }) }) }
DEBUG nh::home:40: out_dir: TempDir { path: "/tmp/nh-home-c8DPMs" }
DEBUG nh::home:41: out_link "/tmp/nh-home-c8DPMs/result"
DEBUG configuration_exists: nh::commands:79: cmd=Exec { nix eval '.#homeConfigurations' --apply ' x: x ? "firstname.lastname@C02D60Q6MD6V" ' } flakeref=FlakeRef(".") configuration="firstname.lastname@C02D60Q6MD6V"
warning: Git tree '/Users/firstname.lastname/privrepo/dots.nix' is dirty
DEBUG configuration_exists: nh::home:192: result="false\n" flakeref=FlakeRef(".") configuration="firstname.lastname@C02D60Q6MD6V"
DEBUG configuration_exists: nh::home:181: return=false flakeref=FlakeRef(".") configuration="firstname.lastname@C02D60Q6MD6V"
DEBUG configuration_exists: nh::commands:79: cmd=Exec { nix eval '.#homeConfigurations' --apply ' x: x ? "firstname.lastname" ' } flakeref=FlakeRef(".") configuration="firstname.lastname"
warning: Git tree '/Users/firstname.lastname/privrepo/dots.nix' is dirty
DEBUG configuration_exists: nh::home:192: result="true\n" flakeref=FlakeRef(".") configuration="firstname.lastname"
DEBUG configuration_exists: nh::home:181: return=true flakeref=FlakeRef(".") configuration="firstname.lastname"
DEBUG nh::home:56: hm_config_name: firstname.lastname
> Building home configuration
DEBUG nh::commands:136: cmd=Pipeline { nix build '.#homeConfigurations.firstname.lastname.config.home.activationPackage' --log-format internal-json --verbose --out-link /tmp/nh-home-c8DPMs/result | nom --json }
warning: Git tree '/Users/firstname.lastname/privrepo/dots.nix' is dirty
error: flake 'git+file:///Users/firstname.lastname/privrepo/dots.nix' does not provide attribute 'packages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage', 'legacyPackages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage' or 'homeConfigurations.firstname.lastname.config.home.activationPackage'
┏━ 1 Errors:
┃ error: flake 'git+file:///Users/firstname.lastname/privrepo/dots.nix' does not provide attribute 'packages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage', 'legacyPackages.x86_64-darwin.homeConfigurations.firstname.lastname.config.home.activationPackage' or 'homeConfigurations.firstname.lastname.config.home.activationPackage'
┣━━━
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 17:53:42 after 0s
Error:
   0: Command exited with status Exited(1)

Location:
   src/commands.rs:151

for reference, home-manager switch --flake firstname.lastname worked fine

@viperML
Copy link
Owner

viperML commented Jul 16, 2024

it seems we need to handle the dot to pass it properly to nix build

@ToyVo
Copy link
Contributor

ToyVo commented Jul 16, 2024

This line
https://github.com/viperML/nh/blob/master/src/home.rs#L59

            "{}#homeConfigurations.{}.config.home.activationPackage",

should be changed to

            "{}#homeConfigurations.\"{}\".config.home.activationPackage",

that won't effect anyone who doesn't have a .

@ToyVo
Copy link
Contributor

ToyVo commented Jul 16, 2024

This line is for nixos, could be useful there too, it doesn't harm.
https://github.com/viperML/nh/blob/master/src/nixos.rs#L46

@viperML
Copy link
Owner

viperML commented Jul 17, 2024

I'm curious about how @horriblename deals with this on a daily basis, as apparently shells like bash and fish interpret the quotes.

Dumping the received argv[1] shows the following:

$ gcc -Wall ./main.c -o main

$ ./main .#foo."a.b".baz
|.|#|f|o|o|.|a|.|b|.|b|a|z

$ ./main .#foo.\"a.b\".baz
|.|#|f|o|o|.|"|a|.|b|"|.|b|a|z

HM adds the escaped quotes here: https://github.com/nix-community/home-manager/blob/afd2021bedff2de92dfce0e257a3d03ae65c603d/home-manager/home-manager#L213

@horriblename
Copy link
Author

I don't recall ever needing to type literal " in the shell luckily 😀 but \" is probably what I'd do as well

obreitwi added a commit to obreitwi/nh that referenced this issue Aug 5, 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

Successfully merging a pull request may close this issue.

3 participants