encrypt secret.nix with git-crypt
This commit is contained in:
parent
f3eda5575e
commit
1565ee0a23
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
* text=auto eol=lf
|
||||
secret.nix filter=git-crypt diff=git-crypt
|
@ -2,17 +2,22 @@
|
||||
with lib;
|
||||
with types;
|
||||
let
|
||||
secret = description:
|
||||
mkOption {
|
||||
inherit description;
|
||||
type = nullOr str;
|
||||
};
|
||||
mkCredOption = service: extra:
|
||||
mkOption {
|
||||
description = "Credentials for ${service}";
|
||||
type = nullOr (submodule {
|
||||
options = {
|
||||
user = mkOption {
|
||||
type = string;
|
||||
type = str;
|
||||
description = "Username for ${service}";
|
||||
};
|
||||
password = mkOption {
|
||||
type = string;
|
||||
type = str;
|
||||
description = "Password for ${service}";
|
||||
};
|
||||
} // extra;
|
||||
@ -21,17 +26,20 @@ let
|
||||
in rec {
|
||||
options.secrets = {
|
||||
wireguard = mkOption {
|
||||
type = attrs;
|
||||
description = "Wireguard conf";
|
||||
type = attrs;
|
||||
};
|
||||
windows-samba = mkCredOption "samba on windows" { };
|
||||
linux-samba = mkCredOption "samba on linux" { };
|
||||
spotify = mkCredOption "Spotify" { };
|
||||
};
|
||||
config = let
|
||||
unlocked = import (pkgs.runCommand "check-secret" { }
|
||||
"set +e; grep -qI . ${../secret.nix}; echo $? > $out") == 0;
|
||||
secretnix = import ../secret.nix;
|
||||
secrets = if isNull secretnix then
|
||||
mapAttrs (n: v: null) options.secrets
|
||||
secrets = if !unlocked || isNull secretnix then
|
||||
builtins.trace "secret.nix locked, building without any secrets"
|
||||
(mapAttrs (n: v: null) options.secrets)
|
||||
else
|
||||
secretnix;
|
||||
in { inherit secrets; };
|
||||
|
BIN
secret.nix.gpg
BIN
secret.nix.gpg
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user