diff options
author | Kaiden Fey <kookie@spacekookie.de> | 2020-09-21 14:12:32 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-09-21 14:12:32 +0200 |
commit | f80843dd45d7acd563d0a5b014cec3a2ea686fc2 (patch) | |
tree | 87189d873d6f932d85f9c1a480462b37d96cd6a5 /home-manager/modules/programs/git.nix | |
parent | e0800985dab8f8ebb4cebdfd7e361fd1fafdb2a7 (diff) | |
parent | 9b1b55ba0264a55add4b7b4e022bdc2832b531f6 (diff) |
Merge commit '9b1b55ba0264a55add4b7b4e022bdc2832b531f6'
Diffstat (limited to '')
-rw-r--r-- | home-manager/modules/programs/git.nix | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/home-manager/modules/programs/git.nix b/home-manager/modules/programs/git.nix index a56aa10d50e..312269de316 100644 --- a/home-manager/modules/programs/git.nix +++ b/home-manager/modules/programs/git.nix @@ -19,10 +19,20 @@ let else ''${section} "${subsection}"''; + mkValueString = v: + let + escapedV = '' + "${ + replaceStrings [ "\n" " " ''"'' "\\" ] [ "\\n" "\\t" ''\"'' "\\\\" ] v + }"''; + in generators.mkValueStringDefault { } (if isString v then escapedV else v); + # generation for multiple ini values mkKeyValue = k: v: - let mkKeyValue = generators.mkKeyValueDefault { } "=" k; - in concatStringsSep "\n" (map mkKeyValue (toList v)); + let + mkKeyValue = + generators.mkKeyValueDefault { inherit mkValueString; } " = " k; + in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v)); # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI gitFlattenAttrs = let @@ -205,6 +215,36 @@ in { ''; }; }; + + delta = { + enable = mkEnableOption "" // { + description = '' + Whether to enable the <command>delta</command> syntax highlighter. + See <link xlink:href="https://github.com/dandavison/delta" />. + ''; + }; + + options = mkOption { + type = with types; + let + primitiveType = either str (either bool int); + sectionType = attrsOf primitiveType; + in attrsOf (either primitiveType sectionType); + default = { }; + example = { + features = "decorations"; + whitespace-error-style = "22 reverse"; + decorations = { + commit-decoration-style = "bold yellow box ul"; + file-style = "bold yellow ul"; + file-decoration-style = "none"; + }; + }; + description = '' + Options to configure delta. + ''; + }; + }; }; }; @@ -237,7 +277,14 @@ in { genIdentity = name: account: with account; nameValuePair "sendemail.${name}" ({ - smtpEncryption = if smtp.tls.enable then "tls" else ""; + smtpEncryption = if smtp.tls.enable then + (if smtp.tls.useStartTls + || versionOlder config.home.stateVersion "20.09" then + "tls" + else + "ssl") + else + ""; smtpServer = smtp.host; smtpUser = userName; from = address; @@ -299,5 +346,15 @@ in { ([ "git-lfs" "smudge" ] ++ skipArg ++ [ "--" "%f" ]); }; }) + + (mkIf cfg.delta.enable { + programs.git.iniContent = + let deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta"; + in { + core.pager = deltaCommand; + interactive.diffFilter = "${deltaCommand} --color-only"; + delta = cfg.delta.options; + }; + }) ]); } |