refactor: nix fmt classic to nix fmt
This commit is contained in:
parent
ca78adc858
commit
f9614371a3
57 changed files with 923 additions and 493 deletions
|
|
@ -1,24 +1,43 @@
|
|||
{ config, lib, inputs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption mkIf types;
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkOption
|
||||
mkIf
|
||||
types
|
||||
;
|
||||
cfg = config.rsydn.secrets;
|
||||
|
||||
sanitizeSecret = name: secret:
|
||||
sanitizeSecret =
|
||||
name: secret:
|
||||
let
|
||||
sopsFile = secret.sopsFile or cfg.defaultSopsFile;
|
||||
extra =
|
||||
lib.filterAttrs (k: _: !(builtins.elem k [ "path" "mode" "sopsFile" ]))
|
||||
secret;
|
||||
in {
|
||||
extra = lib.filterAttrs (
|
||||
k: _:
|
||||
!(builtins.elem k [
|
||||
"path"
|
||||
"mode"
|
||||
"sopsFile"
|
||||
])
|
||||
) secret;
|
||||
in
|
||||
{
|
||||
path = secret.path or "${config.xdg.configHome}/secrets/${name}";
|
||||
mode = secret.mode or "0400";
|
||||
} // (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; }) // extra;
|
||||
in {
|
||||
}
|
||||
// (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; })
|
||||
// extra;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
||||
|
||||
options.rsydn.secrets = {
|
||||
enable =
|
||||
mkEnableOption "sops-nix integration for managing decrypted secrets";
|
||||
enable = mkEnableOption "sops-nix integration for managing decrypted secrets";
|
||||
|
||||
ageKeyFile = mkOption {
|
||||
type = types.str;
|
||||
|
|
@ -29,15 +48,13 @@ in {
|
|||
defaultSopsFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description =
|
||||
"Optional default SOPS file used when a secret definition omits `sopsFile`.";
|
||||
description = "Optional default SOPS file used when a secret definition omits `sopsFile`.";
|
||||
};
|
||||
|
||||
secrets = mkOption {
|
||||
type = types.attrsOf types.attrs;
|
||||
default = { };
|
||||
description =
|
||||
"Secret entries forwarded to `sops.secrets` with sensible defaults.";
|
||||
description = "Secret entries forwarded to `sops.secrets` with sensible defaults.";
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"api-key" = {
|
||||
|
|
@ -58,14 +75,14 @@ in {
|
|||
};
|
||||
|
||||
secrets = lib.mapAttrs sanitizeSecret cfg.secrets;
|
||||
} // (lib.optionalAttrs (cfg.defaultSopsFile != null) {
|
||||
}
|
||||
// (lib.optionalAttrs (cfg.defaultSopsFile != null) {
|
||||
defaultSopsFile = cfg.defaultSopsFile;
|
||||
});
|
||||
|
||||
home.activation.ensureSecretDir =
|
||||
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
mkdir -p "${config.xdg.configHome}/secrets"
|
||||
chmod 700 "${config.xdg.configHome}/secrets"
|
||||
'';
|
||||
home.activation.ensureSecretDir = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
mkdir -p "${config.xdg.configHome}/secrets"
|
||||
chmod 700 "${config.xdg.configHome}/secrets"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue