fork/home-manager
git clone https://git.julia.blue/fork/home-manager
4fa1ba72
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . mercurial ; 8 9iniFormat = pkgs . formats . ini { }; 10 11in { 12 13options = { 14programs . mercurial = { 15enable = mkEnableOption "Mercurial" ; 16 17package = mkOption { 18type = types . package ; 19default = pkgs . mercurial ; 20defaultText = literalExpression "pkgs.mercurial" ; 21description = "Mercurial package to install." ; 22}; 23 24userName = mkOption { 25type = types . str ; 26description = "Default user name to use." ; 27}; 28 29userEmail = mkOption { 30type = types . str ; 31description = "Default user email to use." ; 32}; 33 34aliases = mkOption { 35type = types . attrsOf types . anything ; 36default = { }; 37description = "Mercurial aliases to define." ; 38}; 39 40extraConfig = mkOption { 41type = types . either ( types . attrsOf types . anything ) types . lines ; 42default = { }; 43description = "Additional configuration to add." ; 44}; 45 46iniContent = mkOption { 47type = iniFormat . type ; 48internal = true ; 49}; 50 51ignores = mkOption { 52type = types . listOf types . str ; 53default = [ ]; 54example = [ "*~" "*.swp" ]; 55description = "List of globs for files to be globally ignored." ; 56}; 57 58ignoresRegexp = mkOption { 59type = types . listOf types . str ; 60default = [ ]; 61example = [ "^.*~$" "^.*\\.swp$" ]; 62description = 63"List of regular expressions for files to be globally ignored." ; 64}; 65}; 66}; 67 68config = mkIf cfg . enable ( mkMerge [ 69{ 70home . packages = [ cfg . package ]; 71 72programs . mercurial . iniContent . ui = { 73username = cfg . userName + " <" + cfg . userEmail + ">" ; 74}; 75 76xdg . configFile . "hg/hgrc" . source = 77iniFormat . generate "hgrc" cfg . iniContent ; 78} 79 80( mkIf ( cfg . ignores != [ ] || cfg . ignoresRegexp != [ ]) { 81programs . mercurial . iniContent . ui . ignore = 82" ${ config . xdg . configHome } /hg/hgignore_global" ; 83 84xdg . configFile . "hg/hgignore_global" . text = '' 85syntax: glob 86'' + concatStringsSep "\n" cfg . ignores + "\n" + '' 87syntax: regexp 88'' + concatStringsSep "\n" cfg . ignoresRegexp + "\n" ; 89}) 90 91( mkIf ( cfg . aliases != { }) { 92programs . mercurial . iniContent . alias = cfg . aliases ; 93}) 94 95( mkIf ( lib . isAttrs cfg . extraConfig ) { 96programs . mercurial . iniContent = cfg . extraConfig ; 97}) 98 99( mkIf ( lib . isString cfg . extraConfig ) { 100xdg . configFile . "hg/hgrc" . text = cfg . extraConfig ; 101}) 102]); 103}