1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-23 18:29:47 +01:00

git: add option to define store names for generated include files (#3171)

This allows to use gitconfig/gitconfig-some-intent
as store path suffixes for the texts.
This commit is contained in:
Ronny Pfannschmidt 2022-08-26 21:48:50 +02:00 committed by GitHub
parent 3d3bbdfe95
commit 5bb1f67568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View file

@ -130,10 +130,20 @@ let
</citerefentry>. </citerefentry>.
''; '';
}; };
};
config.path = mkIf (config.contents != { }) contentSuffix = mkOption {
(mkDefault (pkgs.writeText "contents" (gitToIni config.contents))); type = types.str;
default = "gitconfig";
description = ''
Nix store name for the git configuration text file,
when generating the configuration text from nix options.
'';
};
};
config.path = mkIf (config.contents != { }) (mkDefault
(pkgs.writeText (hm.strings.storeFileName config.contentSuffix)
(gitToIni config.contents)));
}); });
in { in {

View file

@ -56,3 +56,6 @@
[includeIf "gitdir:~/src/dir"] [includeIf "gitdir:~/src/dir"]
path = "@git_include_path@" path = "@git_include_path@"
[includeIf "gitdir:~/src/otherproject"]
path = "@git_named_include_path@"

View file

@ -14,7 +14,9 @@ let
substituteExpected = path: substituteExpected = path:
pkgs.substituteAll { pkgs.substituteAll {
src = path; src = path;
git_include_path = pkgs.writeText "contents" git_include_path = pkgs.writeText "hm_gitconfig"
(builtins.readFile ./git-expected-include.conf);
git_named_include_path = pkgs.writeText "hm_gitconfigwork"
(builtins.readFile ./git-expected-include.conf); (builtins.readFile ./git-expected-include.conf);
}; };
@ -46,6 +48,11 @@ in {
condition = "gitdir:~/src/dir"; condition = "gitdir:~/src/dir";
contents = gitInclude; contents = gitInclude;
} }
{
condition = "gitdir:~/src/otherproject";
contents = gitInclude;
contentSuffix = "gitconfig-work";
}
]; ];
signing = { signing = {
gpgPath = "path-to-gpg"; gpgPath = "path-to-gpg";