nixos-config/modules/secrets.nix

39 lines
929 B
Nix
Raw Normal View History

2019-08-27 23:41:02 +04:00
{ pkgs, config, lib, ... }:
with lib;
with types;
let
mkCredOption = service: extra:
mkOption {
description = "Credentials for ${service}";
type = nullOr (submodule {
options = {
user = mkOption {
type = string;
description = "Username for ${service}";
};
password = mkOption {
type = string;
description = "Password for ${service}";
};
} // extra;
});
};
in rec {
options.secrets = {
wireguard = mkOption {
type = attrs;
description = "Wireguard conf";
};
2019-09-18 00:51:45 +04:00
windows-samba = mkCredOption "samba on windows" { };
2019-09-26 02:46:10 +04:00
linux-samba = mkCredOption "samba on linux" { };
2020-02-08 03:53:35 +04:00
spotify = mkCredOption "Spotify" { };
2019-08-27 23:41:02 +04:00
};
config = let
secretnix = import ../secret.nix;
secrets = if isNull secretnix then
mapAttrs (n: v: null) options.secrets
else
secretnix;
in { inherit secrets; };
}