git: allow contents in git.includes
This commit is contained in:
parent
e0e8d5061d
commit
6da88339f5
|
@ -34,7 +34,7 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
includeModule = types.submodule {
|
includeModule = types.submodule ({ config, ... }: {
|
||||||
options = {
|
options = {
|
||||||
condition = mkOption {
|
condition = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
|
@ -50,11 +50,23 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
path = mkOption {
|
path = mkOption {
|
||||||
type = types.str;
|
type = with types; either str path;
|
||||||
description = "Path of the configuration file to include.";
|
description = "Path of the configuration file to include.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
contents = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Configuration to include. If empty then a path must be given.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
config.path = mkIf (config.contents != {}) (
|
||||||
|
mkDefault (pkgs.writeText "contents" (generators.toINI {} config.contents))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,6 @@ 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"]
|
||||||
|
path = @git_include_path@
|
||||||
|
|
|
@ -1,7 +1,24 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
gitInclude = {
|
||||||
|
user = {
|
||||||
|
name = "John Doe";
|
||||||
|
email = "user@example.org";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
substituteExpected = path: pkgs.substituteAll {
|
||||||
|
src = path;
|
||||||
|
|
||||||
|
git_include_path = pkgs.writeText "contents" (generators.toINI {} gitInclude);
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
programs.git = mkMerge [
|
programs.git = mkMerge [
|
||||||
|
@ -23,6 +40,10 @@ with lib;
|
||||||
path = "~/path/to/conditional.inc";
|
path = "~/path/to/conditional.inc";
|
||||||
condition = "gitdir:~/src/dir";
|
condition = "gitdir:~/src/dir";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
condition = "gitdir:~/src/dir";
|
||||||
|
contents = gitInclude;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
signing = {
|
signing = {
|
||||||
gpgPath = "path-to-gpg";
|
gpgPath = "path-to-gpg";
|
||||||
|
@ -43,7 +64,7 @@ with lib;
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/git/config
|
assertFileExists home-files/.config/git/config
|
||||||
assertFileContent home-files/.config/git/config ${./git-expected.conf}
|
assertFileContent home-files/.config/git/config ${substituteExpected ./git-expected.conf}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue