NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18k stars 14.01k forks source link

mercurial via home-manager within nix-darwin is not reading the ~/.config/hg config files #346194

Open fredcy opened 3 weeks ago

fredcy commented 3 weeks ago

Describe the bug

When I enable and configure the "mercurial" package via home-manager (within nix-darwin), the generated config files in ~/.config/hg are not read by the hg executable and so they do not take effect as needed.

Steps To Reproduce

Using home-manager (25.05) within nix-darwin (nixpgks 24.05), enable the mercurial package:

 programs.mercurial = {
    enable = true;
    userName = "Joe Schoe";
    userEmail = "joe@example.com";
};

Build the nix-darwin flake (with included home-manager module): darwin-rebuild switch --flake .

Verify that the generated ~/.config/hg/hgrc file includes username=Joe Schmoe <joe@example.com>.

Verify that hg picks up the generated configuration: hg config ui.username

Verify that hg is looking in the generated ~/.config/hg/hgrc file: hg --debug ui.username

Expected behavior

I expect the first hg command to report the user name/email value that we set, like this:

% hg config ui.username
Joe Schmoe <joe@example.com>
%

Instead, it reports no value at all:

% hg config ui.username
%

I expect the output of hg --debug config ui.username to show that it is reading the ~/.config/hg/hgrc file among others, but it does not:

% hg --debug config ui.username
starting pager for command 'config'
read config from: resource:mercurial.defaultrc.mergetools.rc
read config from: /nix/store/n5apv7svzvka6i0xc40m7lk6yrdk2yvp-mercurial-6.6.3/etc/mercurial/hgrc
read config from: /etc/mercurial/hgrc
read config from: /Users/joe/.hgrc

(The /nix/store/n5apv7svzvka6i0xc40m7lk6yrdk2yvp-mercurial-6.6.3/etc/mercurial/hgrc path is "no such file or directory")

Additional context

I have used the same mercurial home-manager config on a linux system (with just nixpkgs, not nixos) and it works fine there, reading the hg config files in ~/.config/hg.

Notify maintainers

@techknowlogick @edolstra @lukegb

Metadata

% nix-shell -p nix-info --run "nix-info -m"
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.6.0, macOS 14.6.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - nixpkgs: `/nix/store/mrpfclqc430y8gc7xs3rrp59cjk1pc9b-source`

Add a :+1: reaction to issues you find important.

fredcy commented 3 weeks ago

I'm able to work around the issue by adding symlinks to the config files generated by home-manager:

ln -s ~/.config/hg/hgrc ~/.hgrc
ln -s ~/.config/hg/hgignore_global ~/.hgignore_global
JohnRTitor commented 3 weeks ago

Please submit home manager issues to their repo. Thanks.

Additionally darwin package may not necessarily store it's configs in .config/hg but rather in .hg.

If anything this should be reported to upstream package repo.