kaas
This commit is contained in:
parent
5c1e6807b6
commit
cf9dcf2568
12 changed files with 244 additions and 137 deletions
43
clan/flake-module.nix
Normal file
43
clan/flake-module.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
imports = [
|
||||||
|
./machines.nix
|
||||||
|
./tags.nix
|
||||||
|
./instances.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
clan = {
|
||||||
|
meta = {
|
||||||
|
name = "arda";
|
||||||
|
domain = "arda";
|
||||||
|
description = "My personal machines at home";
|
||||||
|
};
|
||||||
|
|
||||||
|
directory = ../.;
|
||||||
|
|
||||||
|
specialArgs = {
|
||||||
|
ardaLib = {
|
||||||
|
types =
|
||||||
|
./types
|
||||||
|
|> (inputs.import-tree.withLib lib).leafs
|
||||||
|
|> lib.map (mod: {
|
||||||
|
name = mod |> lib.baseNameOf |> lib.splitString "." |> lib.head;
|
||||||
|
value = lib.types.submoduleWith {modules = [mod];};
|
||||||
|
})
|
||||||
|
|> lib.listToAttrs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exportInterfaces =
|
||||||
|
./interfaces
|
||||||
|
|> (inputs.import-tree.withLib lib).leafs
|
||||||
|
|> lib.map (mod: {
|
||||||
|
name = mod |> lib.baseNameOf |> lib.splitString "." |> lib.head;
|
||||||
|
value = import mod;
|
||||||
|
})
|
||||||
|
|> lib.listToAttrs;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,103 +1,19 @@
|
||||||
{
|
{
|
||||||
meta = {
|
self,
|
||||||
name = "arda";
|
inputs,
|
||||||
domain = "arda";
|
...
|
||||||
description = "My personal machines at home";
|
}: let
|
||||||
};
|
db =
|
||||||
|
self.clan.exports
|
||||||
directory = ./.;
|
|> inputs.clan-core.lib.getExport {
|
||||||
|
serviceName = "arda/persistence";
|
||||||
exportInterfaces = {
|
roleName = "default";
|
||||||
persistence = import ./interfaces/persistence.nix;
|
machineName = "ulmo";
|
||||||
gateway = import ./interfaces/gateway.nix;
|
instanceName = "persistence";
|
||||||
};
|
}
|
||||||
|
|> (v: v.persistence.driver.${v.persistence.main});
|
||||||
inventory.machines = {
|
in {
|
||||||
aule = {
|
clan.inventory.instances = {
|
||||||
name = "aule";
|
|
||||||
description = "Planned build server.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [];
|
|
||||||
};
|
|
||||||
mandos = {
|
|
||||||
name = "mandos";
|
|
||||||
description = "Living room Steam box.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [
|
|
||||||
"capability:mobility:stationary"
|
|
||||||
"operational:availability:wake-on-demand"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
manwe = {
|
|
||||||
name = "manwe";
|
|
||||||
description = "Main desktop.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [
|
|
||||||
"capability:mobility:stationary"
|
|
||||||
"operational:availability:manual"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
melkor = {
|
|
||||||
name = "melkor";
|
|
||||||
description = "Planned machine with no defined role yet.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [];
|
|
||||||
};
|
|
||||||
orome = {
|
|
||||||
name = "orome";
|
|
||||||
description = "Work laptop.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [
|
|
||||||
"capability:mobility:portable"
|
|
||||||
"operational:availability:manual"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
tulkas = {
|
|
||||||
name = "tulkas";
|
|
||||||
description = "Steam Deck.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [
|
|
||||||
"capability:mobility:portable"
|
|
||||||
"operational:availability:manual"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
ulmo = {
|
|
||||||
name = "ulmo";
|
|
||||||
description = "Primary self-hosted services machine.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [
|
|
||||||
"capability:mobility:stationary"
|
|
||||||
"operational:availability:always-on"
|
|
||||||
"operational:storage:large"
|
|
||||||
"operational:role:gateway"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
varda = {
|
|
||||||
name = "varda";
|
|
||||||
description = "Planned machine with no defined role yet.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [];
|
|
||||||
};
|
|
||||||
yavanna = {
|
|
||||||
name = "yavanna";
|
|
||||||
description = "Planned machine with no defined role yet.";
|
|
||||||
machineClass = "nixos";
|
|
||||||
tags = [];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
inventory.tags = {
|
|
||||||
config,
|
|
||||||
machines,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
# tag_name = [ "list" "of" "machines" ]
|
|
||||||
"capability:hardware:gpu" = [""];
|
|
||||||
"capability:hardware:audio" = [""];
|
|
||||||
"capability:hardware:bluetooth" = [""];
|
|
||||||
};
|
|
||||||
|
|
||||||
inventory.instances = {
|
|
||||||
users-chris = {
|
users-chris = {
|
||||||
module = {
|
module = {
|
||||||
name = "users";
|
name = "users";
|
||||||
|
|
@ -137,6 +53,12 @@
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
driver = "caddy";
|
driver = "caddy";
|
||||||
|
|
||||||
|
hosts = {
|
||||||
|
"auth.kruining.eu" = ''
|
||||||
|
reverse_proxy h2c://[::1]:9092
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -147,7 +69,6 @@
|
||||||
input = "self";
|
input = "self";
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO :: Convert to use tags instead
|
|
||||||
roles.default.tags = ["operational:availability:always-on" "operational:storage:large"];
|
roles.default.tags = ["operational:availability:always-on" "operational:storage:large"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -161,7 +82,7 @@
|
||||||
tags = ["operational:availability:always-on"];
|
tags = ["operational:availability:always-on"];
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
persistence_instance = "persistence";
|
database = db;
|
||||||
|
|
||||||
organization = {
|
organization = {
|
||||||
nix = {
|
nix = {
|
||||||
|
|
@ -305,8 +226,7 @@
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
database = db;
|
||||||
persistence_instance = "persistence";
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
sonarr = {
|
sonarr = {
|
||||||
|
|
@ -10,19 +10,26 @@ in {
|
||||||
default = name;
|
default = name;
|
||||||
};
|
};
|
||||||
|
|
||||||
protocol = mkOption {
|
endpoint = mkOption {
|
||||||
type = types.str;
|
type = types.submoduleWith {
|
||||||
default = "http";
|
modules = [../types/endpoint.nix];
|
||||||
|
};
|
||||||
|
default = name;
|
||||||
};
|
};
|
||||||
|
|
||||||
host = mkOption {
|
# protocol = mkOption {
|
||||||
type = types.str;
|
# type = types.str;
|
||||||
default = "[::1]";
|
# default = "http";
|
||||||
};
|
# };
|
||||||
|
|
||||||
port = mkOption {
|
# host = mkOption {
|
||||||
type = types.port;
|
# type = types.str;
|
||||||
};
|
# default = "[::1]";
|
||||||
|
# };
|
||||||
|
|
||||||
|
# port = mkOption {
|
||||||
|
# type = types.port;
|
||||||
|
# };
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
default = {};
|
default = {};
|
||||||
|
|
@ -8,7 +8,11 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
driver = mkOption {
|
driver = mkOption {
|
||||||
type = types.attrsOf types.anything;
|
type = types.attrsOf (types.submoduleWith {
|
||||||
|
modules = [
|
||||||
|
../types/endpoint.nix
|
||||||
|
];
|
||||||
|
});
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
75
clan/machines.nix
Normal file
75
clan/machines.nix
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
{...}: {
|
||||||
|
clan.inventory.machines = {
|
||||||
|
aule = {
|
||||||
|
name = "aule";
|
||||||
|
description = "Planned build server.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [];
|
||||||
|
};
|
||||||
|
mandos = {
|
||||||
|
name = "mandos";
|
||||||
|
description = "Living room Steam box.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [
|
||||||
|
"capability:mobility:stationary"
|
||||||
|
"operational:availability:wake-on-demand"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
manwe = {
|
||||||
|
name = "manwe";
|
||||||
|
description = "Main desktop.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [
|
||||||
|
"capability:mobility:stationary"
|
||||||
|
"operational:availability:manual"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
melkor = {
|
||||||
|
name = "melkor";
|
||||||
|
description = "Planned machine with no defined role yet.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [];
|
||||||
|
};
|
||||||
|
orome = {
|
||||||
|
name = "orome";
|
||||||
|
description = "Work laptop.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [
|
||||||
|
"capability:mobility:portable"
|
||||||
|
"operational:availability:manual"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
tulkas = {
|
||||||
|
name = "tulkas";
|
||||||
|
description = "Steam Deck.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [
|
||||||
|
"capability:mobility:portable"
|
||||||
|
"operational:availability:manual"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ulmo = {
|
||||||
|
name = "ulmo";
|
||||||
|
description = "Primary self-hosted services machine.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [
|
||||||
|
"capability:mobility:stationary"
|
||||||
|
"operational:availability:always-on"
|
||||||
|
"operational:storage:large"
|
||||||
|
"operational:role:gateway"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
varda = {
|
||||||
|
name = "varda";
|
||||||
|
description = "Planned machine with no defined role yet.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [];
|
||||||
|
};
|
||||||
|
yavanna = {
|
||||||
|
name = "yavanna";
|
||||||
|
description = "Planned machine with no defined role yet.";
|
||||||
|
machineClass = "nixos";
|
||||||
|
tags = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
12
clan/tags.nix
Normal file
12
clan/tags.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{...}: {
|
||||||
|
clan.inventory.tags = {
|
||||||
|
config,
|
||||||
|
machines,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
# tag_name = [ "list" "of" "machines" ]
|
||||||
|
"capability:hardware:gpu" = [""];
|
||||||
|
"capability:hardware:audio" = [""];
|
||||||
|
"capability:hardware:bluetooth" = [""];
|
||||||
|
};
|
||||||
|
}
|
||||||
44
clan/types/endpoint.nix
Normal file
44
clan/types/endpoint.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
host = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "localhost";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
};
|
||||||
|
|
||||||
|
protocol = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
password = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
path = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
query = mkOption {
|
||||||
|
type = types.nullOr (types.attrsOf types.str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
hash = mkOption {
|
||||||
|
type = types.nullOr (types.attrsOf types.str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ in {
|
||||||
readme = builtins.readFile ./README.md;
|
readme = builtins.readFile ./README.md;
|
||||||
exports = {
|
exports = {
|
||||||
inputs = ["persistence"];
|
inputs = ["persistence"];
|
||||||
out = ["gateway"];
|
out = ["gateway" "persistence"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ in {
|
||||||
default = "zitadel";
|
default = "zitadel";
|
||||||
};
|
};
|
||||||
|
|
||||||
persistence_instance = mkOption {
|
database = mkOption {
|
||||||
type = types.str;
|
type = types.anything; #ardaLib.types.endpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
|
|
@ -345,7 +345,19 @@ in {
|
||||||
|> (v: v.persistence.driver.postgresql);
|
|> (v: v.persistence.driver.postgresql);
|
||||||
in {
|
in {
|
||||||
exports = mkExports {
|
exports = mkExports {
|
||||||
gateway.services.identity = {port = settings.port;};
|
gateway = {
|
||||||
|
services.identity = {endpoint.port = settings.port;};
|
||||||
|
functions.auth = {
|
||||||
|
body = ''
|
||||||
|
forward_auth h2c://[::1]:${toString settings.port} {
|
||||||
|
uri /api/authz/forward-auth
|
||||||
|
copy_headers Remote-User Remote-Groups Remote-Email Remote-Name
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
persistence.databases = ["zitadel"];
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModule = {
|
nixosModule = {
|
||||||
|
|
@ -423,8 +435,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
Database.postgres = {
|
Database.postgres = {
|
||||||
Host = database.host;
|
Host = settings.database.host;
|
||||||
Port = database.port;
|
Port = settings.database.port;
|
||||||
Databae = "zitadel";
|
Databae = "zitadel";
|
||||||
User = {
|
User = {
|
||||||
Username = "zitadel";
|
Username = "zitadel";
|
||||||
|
|
@ -434,12 +446,12 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
steps = {
|
steps = {
|
||||||
InstanceName = "eu";
|
InstanceName = "eu";
|
||||||
|
|
||||||
MachineKeyPath = "/var/lib/zitadel/machine-key.json";
|
MachineKeyPath = "/var/lib/zitadel/machine-key.json";
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ in {
|
||||||
driver.postgresql = {
|
driver.postgresql = {
|
||||||
host = "localhost";
|
host = "localhost";
|
||||||
port = settings.port;
|
port = settings.port;
|
||||||
databases = requested_databases;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
enable = mkEnableOption "Enable configured *arr services";
|
enable = mkEnableOption "Enable configured *arr services";
|
||||||
|
|
||||||
persistence_instance = mkOption {
|
database = mkOption {
|
||||||
type = types.str;
|
type = types.anything; #ardaLib.types.endpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
services = mkOption {
|
services = mkOption {
|
||||||
|
|
@ -77,7 +77,7 @@ in {
|
||||||
|> lib.imap1 (i: name: {
|
|> lib.imap1 (i: name: {
|
||||||
inherit name;
|
inherit name;
|
||||||
value = {
|
value = {
|
||||||
port = 2000 + i;
|
endpoint.port = 2000 + i;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|> lib.listToAttrs;
|
|> lib.listToAttrs;
|
||||||
|
|
|
||||||
|
|
@ -103,12 +103,12 @@
|
||||||
}:
|
}:
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
systems = import systems;
|
systems = import systems;
|
||||||
clan = import ./clan.nix;
|
|
||||||
|
|
||||||
imports = with inputs; [
|
imports = with inputs; [
|
||||||
flake-parts.flakeModules.modules
|
flake-parts.flakeModules.modules
|
||||||
clan-core.flakeModules.default
|
clan-core.flakeModules.default
|
||||||
home-manager.flakeModules.default
|
home-manager.flakeModules.default
|
||||||
|
./clan/flake-module.nix
|
||||||
./packages/flake-module.nix
|
./packages/flake-module.nix
|
||||||
./clanServices/flake-module.nix
|
./clanServices/flake-module.nix
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{baseNixosModules, lib, sharedContext, ...}: {
|
|
||||||
clan =
|
|
||||||
(import ../clan.nix {
|
|
||||||
inherit baseNixosModules lib;
|
|
||||||
})
|
|
||||||
// {
|
|
||||||
specialArgs = sharedContext;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue