diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-07-09 01:57:05 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-07-09 01:57:05 +0530 |
| commit | 1314456be1c96e7c61487a7eee11f80682dafdf1 (patch) | |
| tree | fa130bad69313475670aa58633e7c1641fcab77d /modules/programs/git | |
| parent | a2beb86ab62f0f2c5052b8efe46bec5086907e3b (diff) | |
| download | home-manager-config-1314456be1c96e7c61487a7eee11f80682dafdf1.tar.gz home-manager-config-1314456be1c96e7c61487a7eee11f80682dafdf1.zip | |
feat: added assertions for automatically validation related options
Some programs and their configurations may depend on other programs.
For a truly portable configuration users must be able to get appropriate error messages if a options is enabled but its requirements (like a dependent option) is not met.
The build crashes for those and keeps the config concise.
Diffstat (limited to 'modules/programs/git')
| -rw-r--r-- | modules/programs/git/assertions.nix | 13 | ||||
| -rw-r--r-- | modules/programs/git/default.nix | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/modules/programs/git/assertions.nix b/modules/programs/git/assertions.nix new file mode 100644 index 0000000..fbe5d3c --- /dev/null +++ b/modules/programs/git/assertions.nix @@ -0,0 +1,13 @@ +{ config, ... }: +{ + assertions = [ + { + assertion = + !config.programs.git.useSSH || (config.programs.git.enable && config.programs.ssh.enable); + message = '' + programs.git.useSSH is enabled but programs.ssh.enable is not. + SSH must be enabled (programs.ssh.enable = true) to use SSH for git. + ''; + } + ]; +} diff --git a/modules/programs/git/default.nix b/modules/programs/git/default.nix index 2c4303b..133c063 100644 --- a/modules/programs/git/default.nix +++ b/modules/programs/git/default.nix @@ -6,6 +6,8 @@ # Git - Distributed version control system { + imports = [ ./assertions.nix ]; + options.programs.git = { username = lib.mkOption { type = lib.types.str; |
