make all age use conditional
This commit is contained in:
parent
b2f0476412
commit
3cb6fba59e
8 changed files with 73 additions and 9 deletions
|
|
@ -1,17 +1,26 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# Remote build off home lio computer
|
# Remote build off home lio computer
|
||||||
programs.ssh.extraConfig = ''
|
programs.ssh.extraConfig = lib.mkIf (hasSecret "nix2lio") ''
|
||||||
Host lio_
|
Host lio_
|
||||||
PubkeyAcceptedKeyTypes ssh-ed25519
|
PubkeyAcceptedKeyTypes ssh-ed25519
|
||||||
ServerAliveInterval 60
|
ServerAliveInterval 60
|
||||||
IPQoS throughput
|
IPQoS throughput
|
||||||
IdentityFile ${config.age.secrets.nix2lio.path}
|
IdentityFile ${config.age.secrets.nix2lio.path}
|
||||||
'';
|
'';
|
||||||
nix = {
|
nix = lib.mkIf (hasSecret "nix2lio") {
|
||||||
distributedBuilds = true;
|
distributedBuilds = true;
|
||||||
buildMachines = [
|
buildMachines = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [ tailscale ];
|
environment.systemPackages = with pkgs; [ tailscale ];
|
||||||
services.tailscale = {
|
services.tailscale = lib.mkIf (hasSecret "headscale_auth") {
|
||||||
enable = true;
|
enable = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
useRoutingFeatures = "client";
|
useRoutingFeatures = "client";
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,13 @@ let
|
||||||
hostAddress6 = "fc00::1";
|
hostAddress6 = "fc00::1";
|
||||||
containerAddress6 = "fc00::3";
|
containerAddress6 = "fc00::3";
|
||||||
|
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
|
|
||||||
binds = [
|
binds = [
|
||||||
# Postgres data, must use postgres user in container and host
|
# Postgres data, must use postgres user in container and host
|
||||||
{
|
{
|
||||||
|
|
@ -31,6 +38,7 @@ let
|
||||||
uid = config.ids.uids.postgres;
|
uid = config.ids.uids.postgres;
|
||||||
gid = config.ids.gids.postgres;
|
gid = config.ids.gids.postgres;
|
||||||
}
|
}
|
||||||
|
] ++ lib.optionals (hasSecret "zitadel_master_key") [
|
||||||
# secret
|
# secret
|
||||||
{
|
{
|
||||||
host = config.age.secrets.zitadel_master_key.path;
|
host = config.age.secrets.zitadel_master_key.path;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,16 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
nixarr = {
|
nixarr = {
|
||||||
|
|
@ -9,7 +18,7 @@
|
||||||
mediaDir = "/drives/wd10/nixarr/media";
|
mediaDir = "/drives/wd10/nixarr/media";
|
||||||
stateDir = "/var/lib/nixarr/state";
|
stateDir = "/var/lib/nixarr/state";
|
||||||
|
|
||||||
vpn = {
|
vpn = lib.mkIf (hasSecret "us_chi_wg") {
|
||||||
enable = true;
|
enable = true;
|
||||||
wgConf = config.age.secrets.us_chi_wg.path;
|
wgConf = config.age.secrets.us_chi_wg.path;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -10,11 +11,17 @@ let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
disabledModules = [ declaration ];
|
disabledModules = [ declaration ];
|
||||||
imports = [ "${nixpkgs}/nixos/modules/${declaration}" ];
|
imports = [ "${nixpkgs}/nixos/modules/${declaration}" ];
|
||||||
config = {
|
config = lib.mkIf (hasSecret "oauth2_proxy_key_file") {
|
||||||
services.oauth2-proxy = {
|
services.oauth2-proxy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
httpAddress = "http://127.0.0.1:4180";
|
httpAddress = "http://127.0.0.1:4180";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -10,12 +11,18 @@ let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
disabledModules = [ declaration ];
|
disabledModules = [ declaration ];
|
||||||
imports = [ "${nixpkgs}/nixos/modules/${declaration}" ];
|
imports = [ "${nixpkgs}/nixos/modules/${declaration}" ];
|
||||||
options = { };
|
options = { };
|
||||||
config = {
|
config = lib.mkIf (hasSecret "openwebui_env") {
|
||||||
services.nginx.virtualHosts."chat.joshuabell.xyz" = {
|
services.nginx.virtualHosts."chat.joshuabell.xyz" = {
|
||||||
addSSL = true;
|
addSSL = true;
|
||||||
sslCertificate = "/var/lib/acme/joshuabell.xyz/fullchain.pem";
|
sslCertificate = "/var/lib/acme/joshuabell.xyz/fullchain.pem";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -7,10 +8,16 @@ let
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
proxyPass = "http://localhost:7575";
|
proxyPass = "http://localhost:7575";
|
||||||
};
|
};
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# TODO transfer these to o001 to use same certs?
|
# TODO transfer these to o001 to use same certs?
|
||||||
security.acme = {
|
security.acme = lib.mkIf (hasSecret "linode_rw_domains") {
|
||||||
acceptTerms = true;
|
acceptTerms = true;
|
||||||
defaults.email = "admin@joshuabell.xyz";
|
defaults.email = "admin@joshuabell.xyz";
|
||||||
certs."joshuabell.xyz" = {
|
certs."joshuabell.xyz" = {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -9,6 +10,13 @@ let
|
||||||
hostDataDir = "/var/lib/${name}";
|
hostDataDir = "/var/lib/${name}";
|
||||||
|
|
||||||
v_port = 8222;
|
v_port = 8222;
|
||||||
|
|
||||||
|
hasSecret =
|
||||||
|
secret:
|
||||||
|
let
|
||||||
|
secrets = config.age.secrets or { };
|
||||||
|
in
|
||||||
|
secrets ? ${secret} && secrets.${secret} != null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
users = {
|
users = {
|
||||||
|
|
@ -26,7 +34,7 @@ in
|
||||||
chmod -R 750 ${hostDataDir}
|
chmod -R 750 ${hostDataDir}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
containers.${name} = {
|
containers.${name} = lib.mkIf (hasSecret "vaultwarden_env") {
|
||||||
ephemeral = true;
|
ephemeral = true;
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
privateNetwork = false;
|
privateNetwork = false;
|
||||||
|
|
@ -72,7 +80,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts."vault.joshuabell.xyz" = {
|
services.nginx.virtualHosts."vault.joshuabell.xyz" = lib.mkIf (hasSecret "vaultwarden_env") {
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations = {
|
locations = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue