1 parent
1947ee0c9f
commit
6fa74fead8
22 files changed
+116
-144
No files matched your search
@@ -0,0 +1,10 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
fs = import ./fs.nix { inherit lib; };
|
||||
hosts = import ./hosts.nix { inherit lib; };
|
||||
secrets = import ./secrets.nix { inherit lib; };
|
||||
|
||||
dotsPath = ../dots;
|
||||
in
|
||||
fs // hosts // secrets // { inherit dotsPath; }
|
||||
@@ -0,0 +1,6 @@
|
||||
{ lib }:
|
||||
|
||||
{
|
||||
dirNames =
|
||||
path: builtins.attrNames (lib.filterAttrs (_: t: t == "directory") (builtins.readDir path));
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
fs = import ./fs.nix { inherit lib; };
|
||||
|
||||
hostsPath = ../hosts;
|
||||
hostMeta =
|
||||
host:
|
||||
let
|
||||
metaPath = hostsPath + "/${host}/meta.nix";
|
||||
in
|
||||
if builtins.pathExists metaPath then
|
||||
import metaPath
|
||||
else
|
||||
throw "meta.nix required in ${toString metaPath}";
|
||||
hostNames = fs.dirNames hostsPath;
|
||||
in
|
||||
{
|
||||
inherit hostsPath hostMeta hostNames;
|
||||
|
||||
adminHosts = builtins.filter (host: (hostMeta host).host.admin or false) hostNames;
|
||||
nixosHosts = hostNames;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{ lib }:
|
||||
|
||||
{
|
||||
mkSopsSecrets =
|
||||
sopsDir: owner: groups:
|
||||
let
|
||||
opts = lib.optionalAttrs (owner != null) { inherit owner; };
|
||||
mkGroup =
|
||||
group: names:
|
||||
lib.listToAttrs (
|
||||
map (name: {
|
||||
name = "${group}/${name}";
|
||||
value = {
|
||||
sopsFile = "${sopsDir}/${group}.yaml";
|
||||
key = name;
|
||||
}
|
||||
// opts;
|
||||
}) names
|
||||
);
|
||||
in
|
||||
lib.mergeAttrsList (lib.mapAttrsToList mkGroup groups);
|
||||
|
||||
sopsAvailability =
|
||||
config: osConfig:
|
||||
let
|
||||
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? secrets;
|
||||
hmSopsAvailable = config ? sops && config.sops ? secrets;
|
||||
in
|
||||
{
|
||||
available = osSopsAvailable || hmSopsAvailable;
|
||||
secrets = if osSopsAvailable then osConfig.sops.secrets else config.sops.secrets;
|
||||
templates = if osSopsAvailable then osConfig.sops.templates else config.sops.templates;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user