1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-10-01 02:37:27 +02:00
home-manager/modules/programs/mu.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

60 lines
2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.mu;
# Used to generate command line arguments that mu can operate with.
genCmdMaildir = path: "--maildir=" + path;
# Takes the list of accounts with mu.enable = true, and generates a
# command-line flag for initializing the mu database.
myAddresses = let
# Set of email account sets where mu.enable = true.
muAccounts =
filter (a: a.mu.enable) (attrValues config.accounts.email.accounts);
addrs = map (a: a.address) muAccounts;
# Construct list of lists containing email aliases, and flatten
aliases = flatten (map (a: a.aliases) muAccounts);
# Prefix --my-address= to each account's address AND all defined aliases
addMyAddress = map (addr: "--my-address=" + addr) (addrs ++ aliases);
in concatStringsSep " " addMyAddress;
in {
meta.maintainers = [ maintainers.KarlJoad ];
options = {
programs.mu = {
enable = mkEnableOption (lib.mdDoc "mu, a maildir indexer and searcher");
# No options/config file present for mu, and program author will not be
# adding one soon. See https://github.com/djcb/mu/issues/882 for more
# information about this.
};
accounts.email.accounts = mkOption {
type = with types;
attrsOf (submodule {
options.mu.enable = mkEnableOption (lib.mdDoc "mu indexing");
});
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.mu ];
home.activation.runMuInit = let
maildirOption = genCmdMaildir config.accounts.email.maildirBasePath;
dbLocation = config.xdg.cacheHome + "/mu";
in hm.dag.entryAfter [ "writeBoundary" ] ''
# If the database directory exists, then `mu init` should NOT be run.
# In theory, mu is the only thing that creates that directory, and it is
# only created during the initial index.
if [[ ! -d "${dbLocation}" ]]; then
$DRY_RUN_CMD ${pkgs.mu}/bin/mu init ${maildirOption} ${myAddresses} $VERBOSE_ARG;
fi
'';
};
}