nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.29k stars 1.68k forks source link

bug: `passwordCommand` is not used in the same way by mbsync and imapnotify #5123

Open fuzy112 opened 3 months ago

fuzy112 commented 3 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I need to set my passwordCommand to something like ${pkgs.coreutils}/bin/cat \${XDG_RUNTIME_DIR}/agenix/mailpassword.

However, I cannot find a way to let both mbsync and imapnotify works, because the value is in different ways:

mbsync just concatenates the strings together and it works well with the command above,

while imapnotify escapes the strings and as a result the environment variable is not evaluated.

Maintainer CC

@NickHu @KarlJoad

System information

- system: `"x86_64-linux"`
 - host os: `Linux 5.15.133.1-microsoft-standard-WSL2, NixOS, 24.05 (Uakari), 24.05.20240309.3030f18`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11, nixos-wsl"`
 - nixpkgs: `/nix/store/nra828scc8qs92b9pxra5csqzffb6hpl-source`
KarlJoad commented 3 months ago

I think I understand what you are saying, but could you provide the generated outputs for both mbsync and imapnotify, please? That way we can compare both output strings.

KarlJoad commented 3 months ago

Relevant lines:

fuzy112 commented 3 months ago

Karl H @.***> writes:

I think I understand what you are saying, but could you provide the generated outputs for both mbsync and imapnotify, please? That way we can compare both output strings.

Sure.

I set my passwordCommand to cat ${config.age.secrets."mailpassword".path} and enabled mbsync and imapnotify. The outputs are as follows.

Resulted .mbsyncrc:

PassCmd "cat $XDG_RUNTIME_DIR/agenix/mailpassword"

Resulted imapnotify-*-config.json:

 {
  "passwordCmd": "'cat' '$XDG_RUNTIME_DIR/agenix/mailpassword'",
  "port": 993,
  "tls": true,
  "tlsOptions": {
    "starttls": false
  },
}

Unrelated parts are omitted from the output.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

fuzy112 commented 3 months ago

I set my passwordCommand to cat ${config.age.secrets."mailpassword".path} and enabled mbsync and imapnotify. The outputs are as follows.

A possible workaround is to write command to a file:

passwordCommand =
  let
    passScript = pkgs.writeText "pass-script.sh" ''
      ${pkgs.coreutils}/bin/cat "${config.age.secrets."mailpassword".path}"
    '';
  in
    "${pkgs.runtimeShell} ${passScript}";
KarlJoad commented 3 months ago
 {
  "passwordCmd": "'cat' '$XDG_RUNTIME_DIR/agenix/mailpassword'",
  "port": 993,
  "tls": true,
  "tlsOptions": {
    "starttls": false
  },
}

This seems like imapnotify expecting something different than mbsync. To be fair, I think imapnotify may have different goals than mbsync.

When I re-wrote the mbsync module, I was attempting to get it into a state usable for myself. I upstreamed it because it seemed useful (and closed an open issue about mbsync). I'm not 100% sure which style should be preferred (spaces enclosed in quotes, so a single string is a whole command) or if imapnotify's method is preferable. I would appreciate people who use/wrote imapnotify to weigh in and see which method is preferable.

stale[bot] commented 3 weeks ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.