1

I'm setting up NixOS 24.05 and I'm using the equivalent version of Home Manager. I'm trying to move the directory for GNUPG to $HOME/.local/share/gnupg also known as $XDG_DATA_HOME/gnupg. I know that XDG_DATA_HOME is set correctly prior to making this question. Running gpgconf --list-dirs gives me the following output:

sysconfdir:/etc/gnupg
bindir:/nix/store/wfwk6kv1mp5v94dly55c3ql1rwsqrky0-gnupg-2.4.5/bin
libexecdir:/nix/store/wfwk6kv1mp5v94dly55c3ql1rwsqrky0-gnupg-2.4.5/libexec
libdir:/nix/store/wfwk6kv1mp5v94dly55c3ql1rwsqrky0-gnupg-2.4.5/lib/gnupg
datadir:/nix/store/wfwk6kv1mp5v94dly55c3ql1rwsqrky0-gnupg-2.4.5/share/gnupg
localedir:/nix/store/wfwk6kv1mp5v94dly55c3ql1rwsqrky0-gnupg-2.4.5/share/locale
socketdir:/run/user/1000/gnupg
dirmngr-socket:/run/user/1000/gnupg/S.dirmngr
keyboxd-socket:/run/user/1000/gnupg/S.keyboxd
agent-ssh-socket:/run/user/1000/gnupg/S.gpg-agent.ssh
agent-extra-socket:/run/user/1000/gnupg/S.gpg-agent.extra
agent-browser-socket:/run/user/1000/gnupg/S.gpg-agent.browser
agent-socket:/run/user/1000/gnupg/S.gpg-agent
homedir:/home/hanna/.gnupg

Upon setting the GNUPGHOME environment variable or using Home Manager's programs.gpg.homedir option, neither of these resulted in the homedir setting changing in gpgconf and thus the directory always being created at that path.

It does not seem to be respecting any settings I am setting to change this, and I'm hoping someone can help with this.

1 Answer 1

0

I don't know whether you've figured it out or not, but the various xdg directories can be declaratively defined in home-manager by enabling xdg. A sample configuration could look like this:

{ config, lib, pkgs, ... }:

{
  xdg = {
    enable = true;

    cacheHome = "${config.home.homeDirectory}/.cache";
    configHome = "${config.home.homeDirectory}/.config";
    dataHome = "${config.home.homeDirectory}/.local/share";
    stateHome = "${config.home.homeDirectory}/.local/state";

    userDirs = {
      enable = true;

      createDirectories = true;
    };
  };

  home.packages = with pkgs; [
    xdg-utils
    xdg-user-dirs
  ];
}

Then, you could set programs.gpg.homedir to a desired XDG directory. For example:

...
programs.gpg = {
  enable = true;
  homedir = "${config.xdg.dataHome}/gnupg";
};
...

Don't forget to either do a boot rebuild (and reboot), or a switch rebuild; in the latter case you'll need to log out of the session and back in for the changes to take effect.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.