nix format
This commit is contained in:
parent
2ea7f853e4
commit
629604b44b
3 changed files with 48 additions and 26 deletions
21
flake.lock
generated
21
flake.lock
generated
|
|
@ -366,6 +366,7 @@
|
||||||
"nix-ai-tools": "nix-ai-tools",
|
"nix-ai-tools": "nix-ai-tools",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
"nvim-bundle": "nvim-bundle",
|
"nvim-bundle": "nvim-bundle",
|
||||||
|
"sops-nix": "sops-nix",
|
||||||
"zig-overlay": "zig-overlay"
|
"zig-overlay": "zig-overlay"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -391,6 +392,26 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"sops-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1759188042,
|
||||||
|
"narHash": "sha256-f9QC2KKiNReZDG2yyKAtDZh0rSK2Xp1wkPzKbHeQVRU=",
|
||||||
|
"owner": "Mic92",
|
||||||
|
"repo": "sops-nix",
|
||||||
|
"rev": "9fcfabe085281dd793589bdc770a2e577a3caa5d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "Mic92",
|
||||||
|
"repo": "sops-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = inputs@{ self, nixpkgs, darwin, home-manager, ghostty, nix-ai-tools
|
||||||
inputs@{ self, nixpkgs, darwin, home-manager, ghostty, nix-ai-tools, sops-nix, ... }:
|
, sops-nix, ... }:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs.lib) genAttrs;
|
inherit (nixpkgs.lib) genAttrs;
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,19 @@ let
|
||||||
sanitizeSecret = name: secret:
|
sanitizeSecret = name: secret:
|
||||||
let
|
let
|
||||||
sopsFile = secret.sopsFile or cfg.defaultSopsFile;
|
sopsFile = secret.sopsFile or cfg.defaultSopsFile;
|
||||||
extra = lib.filterAttrs (k: _: !(builtins.elem k [ "path" "mode" "sopsFile" ])) secret;
|
extra =
|
||||||
in
|
lib.filterAttrs (k: _: !(builtins.elem k [ "path" "mode" "sopsFile" ]))
|
||||||
{
|
secret;
|
||||||
|
in {
|
||||||
path = secret.path or "${config.xdg.configHome}/secrets/${name}";
|
path = secret.path or "${config.xdg.configHome}/secrets/${name}";
|
||||||
mode = secret.mode or "0400";
|
mode = secret.mode or "0400";
|
||||||
}
|
} // (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; }) // extra;
|
||||||
// (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; })
|
|
||||||
// extra;
|
|
||||||
in {
|
in {
|
||||||
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
||||||
|
|
||||||
options.rsydn.secrets = {
|
options.rsydn.secrets = {
|
||||||
enable = mkEnableOption "sops-nix integration for managing decrypted secrets";
|
enable =
|
||||||
|
mkEnableOption "sops-nix integration for managing decrypted secrets";
|
||||||
|
|
||||||
ageKeyFile = mkOption {
|
ageKeyFile = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
@ -29,13 +29,15 @@ in {
|
||||||
defaultSopsFile = mkOption {
|
defaultSopsFile = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr types.path;
|
||||||
default = null;
|
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 {
|
secrets = mkOption {
|
||||||
type = types.attrsOf types.attrs;
|
type = types.attrsOf types.attrs;
|
||||||
default = { };
|
default = { };
|
||||||
description = "Secret entries forwarded to `sops.secrets` with sensible defaults.";
|
description =
|
||||||
|
"Secret entries forwarded to `sops.secrets` with sensible defaults.";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
{
|
{
|
||||||
"api-key" = {
|
"api-key" = {
|
||||||
|
|
@ -49,22 +51,21 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
sops =
|
sops = {
|
||||||
{
|
age = {
|
||||||
age = {
|
keyFile = cfg.ageKeyFile;
|
||||||
keyFile = cfg.ageKeyFile;
|
generateKey = true;
|
||||||
generateKey = true;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
secrets = lib.mapAttrs sanitizeSecret cfg.secrets;
|
secrets = lib.mapAttrs sanitizeSecret cfg.secrets;
|
||||||
}
|
} // (lib.optionalAttrs (cfg.defaultSopsFile != null) {
|
||||||
// (lib.optionalAttrs (cfg.defaultSopsFile != null) {
|
defaultSopsFile = cfg.defaultSopsFile;
|
||||||
defaultSopsFile = cfg.defaultSopsFile;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
home.activation.ensureSecretDir = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
home.activation.ensureSecretDir =
|
||||||
mkdir -p "${config.xdg.configHome}/secrets"
|
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
chmod 700 "${config.xdg.configHome}/secrets"
|
mkdir -p "${config.xdg.configHome}/secrets"
|
||||||
'';
|
chmod 700 "${config.xdg.configHome}/secrets"
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue