mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
git: escape string values in configuration
This should handle the special characters that typically occur. Fixes #1206
This commit is contained in:
parent
8b82f52e75
commit
642d9ffe24
6 changed files with 42 additions and 30 deletions
|
@ -19,9 +19,19 @@ let
|
||||||
else
|
else
|
||||||
''${section} "${subsection}"'';
|
''${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
|
# generation for multiple ini values
|
||||||
mkKeyValue = k: v:
|
mkKeyValue = k: v:
|
||||||
let mkKeyValue = generators.mkKeyValueDefault { } " = " k;
|
let
|
||||||
|
mkKeyValue =
|
||||||
|
generators.mkKeyValueDefault { inherit mkValueString; } " = " k;
|
||||||
in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v));
|
in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v));
|
||||||
|
|
||||||
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
|
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[user]
|
[user]
|
||||||
email = user@example.org
|
email = "user@example.org"
|
||||||
name = John Doe
|
name = "John Doe"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[alias]
|
[alias]
|
||||||
a1 = foo
|
a1 = "foo"
|
||||||
a2 = baz
|
a2 = "baz"
|
||||||
|
escapes = "\"\\n\t"
|
||||||
|
|
||||||
[commit]
|
[commit]
|
||||||
gpgSign = true
|
gpgSign = true
|
||||||
|
@ -10,33 +11,33 @@
|
||||||
integer = 38
|
integer = 38
|
||||||
multiple = 1
|
multiple = 1
|
||||||
multiple = 2
|
multiple = 2
|
||||||
name = value
|
name = "value"
|
||||||
|
|
||||||
[extra "backcompat.with.dots"]
|
[extra "backcompat.with.dots"]
|
||||||
previously = worked
|
previously = "worked"
|
||||||
|
|
||||||
[extra "subsection"]
|
[extra "subsection"]
|
||||||
value = test
|
value = "test"
|
||||||
|
|
||||||
[filter "lfs"]
|
[filter "lfs"]
|
||||||
clean = git-lfs clean -- %f
|
clean = "git-lfs clean -- %f"
|
||||||
process = git-lfs filter-process
|
process = "git-lfs filter-process"
|
||||||
required = true
|
required = true
|
||||||
smudge = git-lfs smudge -- %f
|
smudge = "git-lfs smudge -- %f"
|
||||||
|
|
||||||
[gpg]
|
[gpg]
|
||||||
program = path-to-gpg
|
program = "path-to-gpg"
|
||||||
|
|
||||||
[user]
|
[user]
|
||||||
email = user@example.org
|
email = "user@example.org"
|
||||||
name = John Doe
|
name = "John Doe"
|
||||||
signingKey = 00112233445566778899AABBCCDDEEFF
|
signingKey = "00112233445566778899AABBCCDDEEFF"
|
||||||
|
|
||||||
[include]
|
[include]
|
||||||
path = ~/path/to/config.inc
|
path = "~/path/to/config.inc"
|
||||||
|
|
||||||
[includeIf "gitdir:~/src/dir"]
|
[includeIf "gitdir:~/src/dir"]
|
||||||
path = ~/path/to/conditional.inc
|
path = "~/path/to/conditional.inc"
|
||||||
|
|
||||||
[includeIf "gitdir:~/src/dir"]
|
[includeIf "gitdir:~/src/dir"]
|
||||||
path = @git_include_path@
|
path = "@git_include_path@"
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
[sendemail "hm-account"]
|
[sendemail "hm-account"]
|
||||||
from = hm@example.org
|
from = "hm@example.org"
|
||||||
smtpEncryption = tls
|
smtpEncryption = "tls"
|
||||||
smtpServer = smtp.example.org
|
smtpServer = "smtp.example.org"
|
||||||
smtpUser = home.manager.jr
|
smtpUser = "home.manager.jr"
|
||||||
|
|
||||||
[sendemail "hm@example.com"]
|
[sendemail "hm@example.com"]
|
||||||
from = hm@example.com
|
from = "hm@example.com"
|
||||||
smtpEncryption = tls
|
smtpEncryption = "tls"
|
||||||
smtpServer = smtp.example.com
|
smtpServer = "smtp.example.com"
|
||||||
smtpUser = home.manager
|
smtpUser = "home.manager"
|
||||||
|
|
||||||
[user]
|
[user]
|
||||||
email = hm@example.com
|
email = "hm@example.com"
|
||||||
name = H. M. Test
|
name = "H. M. Test"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
This can be anything.
|
This can be anything.
|
||||||
|
|
||||||
[user]
|
[user]
|
||||||
email = user@example.org
|
email = "user@example.org"
|
||||||
name = John Doe
|
name = "John Doe"
|
||||||
|
|
|
@ -28,6 +28,7 @@ in {
|
||||||
aliases = {
|
aliases = {
|
||||||
a1 = "foo";
|
a1 = "foo";
|
||||||
a2 = "bar";
|
a2 = "bar";
|
||||||
|
escapes = ''"\n '';
|
||||||
};
|
};
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
extra = {
|
extra = {
|
||||||
|
|
Loading…
Reference in a new issue