mirror of
https://github.com/nix-community/home-manager
synced 2025-01-12 03:59:49 +01:00
36a53d9f26
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
104 lines
2.6 KiB
Nix
104 lines
2.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.mercurial;
|
|
|
|
iniFormat = pkgs.formats.ini { };
|
|
|
|
in {
|
|
|
|
options = {
|
|
programs.mercurial = {
|
|
enable = mkEnableOption (lib.mdDoc "Mercurial");
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.mercurial;
|
|
defaultText = literalExpression "pkgs.mercurial";
|
|
description = lib.mdDoc "Mercurial package to install.";
|
|
};
|
|
|
|
userName = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc "Default user name to use.";
|
|
};
|
|
|
|
userEmail = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc "Default user email to use.";
|
|
};
|
|
|
|
aliases = mkOption {
|
|
type = types.attrsOf types.anything;
|
|
default = { };
|
|
description = lib.mdDoc "Mercurial aliases to define.";
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.either (types.attrsOf types.anything) types.lines;
|
|
default = { };
|
|
description = lib.mdDoc "Additional configuration to add.";
|
|
};
|
|
|
|
iniContent = mkOption {
|
|
type = iniFormat.type;
|
|
internal = true;
|
|
};
|
|
|
|
ignores = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "*~" "*.swp" ];
|
|
description =
|
|
lib.mdDoc "List of globs for files to be globally ignored.";
|
|
};
|
|
|
|
ignoresRegexp = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "^.*~$" "^.*\\.swp$" ];
|
|
description = lib.mdDoc
|
|
"List of regular expressions for files to be globally ignored.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
{
|
|
home.packages = [ cfg.package ];
|
|
|
|
programs.mercurial.iniContent.ui = {
|
|
username = cfg.userName + " <" + cfg.userEmail + ">";
|
|
};
|
|
|
|
xdg.configFile."hg/hgrc".source =
|
|
iniFormat.generate "hgrc" cfg.iniContent;
|
|
}
|
|
|
|
(mkIf (cfg.ignores != [ ] || cfg.ignoresRegexp != [ ]) {
|
|
programs.mercurial.iniContent.ui.ignore =
|
|
"${config.xdg.configHome}/hg/hgignore_global";
|
|
|
|
xdg.configFile."hg/hgignore_global".text = ''
|
|
syntax: glob
|
|
'' + concatStringsSep "\n" cfg.ignores + "\n" + ''
|
|
syntax: regexp
|
|
'' + concatStringsSep "\n" cfg.ignoresRegexp + "\n";
|
|
})
|
|
|
|
(mkIf (cfg.aliases != { }) {
|
|
programs.mercurial.iniContent.alias = cfg.aliases;
|
|
})
|
|
|
|
(mkIf (lib.isAttrs cfg.extraConfig) {
|
|
programs.mercurial.iniContent = cfg.extraConfig;
|
|
})
|
|
|
|
(mkIf (lib.isString cfg.extraConfig) {
|
|
xdg.configFile."hg/hgrc".text = cfg.extraConfig;
|
|
})
|
|
]);
|
|
}
|