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

home-manager: support username with special chars #5609

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

DDoSolitary
Copy link
Contributor

Description

The home manager script fails when $USER contains special characters.

For example, my work PC is managed by company's LDAP and username is <COMPANY>\<user>). When running home-manager switch I get the following error:

error: flake 'path:/home/<COMPANY>/<user>/.config/home-manager' does not provide attribute 'packages.x86_64-linux.homeConfigurations."<COMPANY>\<user>".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."<COMPANY>\<user>".activationPackage' or 'homeConfigurations."<COMPANY>\<user>".activationPackage'
       Did you mean <COMPANY><user>?

There are two types of strings that need escaping:

  • strings in Nix expressions (e.g. home.nix generated by home-manager init)
    they need backslashes before special chars
  • flake URI (passed to nix build)
    they need URI's percent encoding, luckily jq supports that

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@DDoSolitary DDoSolitary force-pushed the fix-user-special-char branch from dbf97eb to 9bf775f Compare July 5, 2024 09:22
@DDoSolitary DDoSolitary force-pushed the fix-user-special-char branch 2 times, most recently from 4646442 to cc5b232 Compare August 3, 2024 17:00
Copy link

stale bot commented Nov 14, 2024

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.

If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

@DDoSolitary DDoSolitary force-pushed the fix-user-special-char branch from cc5b232 to b0e2f68 Compare December 3, 2024 12:33
@teto teto merged commit 6e5b2d9 into nix-community:master Dec 11, 2024
3 checks passed
@DDoSolitary DDoSolitary deleted the fix-user-special-char branch December 22, 2024 14:32
colonelpanic8 pushed a commit to colonelpanic8/home-manager that referenced this pull request Dec 30, 2024
The home manager script fails when $USER contains special characters.

For example, my work PC is managed by company's LDAP and username is <COMPANY>\<user>). When running home-manager switch I get the following error:
```
error: flake 'path:/home/<COMPANY>/<user>/.config/home-manager' does not provide attribute 'packages.x86_64-linux.homeConfigurations."<COMPANY>\<user>".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."<COMPANY>\<user>".activationPackage' or 'homeConfigurations."<COMPANY>\<user>".activationPackage'
       Did you mean <COMPANY><user>?
```
There are two types of strings that need escaping:

    strings in Nix expressions (e.g. home.nix generated by home-manager init)
    they need backslashes before special chars
    flake URI (passed to nix build)
    they need URI's percent encoding, luckily jq supports that
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 this pull request may close these issues.

2 participants