mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
chore: nf-fmt-nix
This commit is contained in:
parent
7486517713
commit
9903866044
160 changed files with 4570 additions and 3019 deletions
|
|
@ -1,4 +1,8 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.dnsmasq = { config, ... }: {
|
||||
config.exports.services.dnsmasq = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "dns";
|
||||
nixos = {
|
||||
serviceAttr = "dnsmasq";
|
||||
|
|
|
|||
|
|
@ -24,7 +24,12 @@
|
|||
};
|
||||
id = mkOption {
|
||||
type = str;
|
||||
default = cfg.services.${config.serviceName}.id/* or config.name*/;
|
||||
default =
|
||||
cfg.services.${config.serviceName}.id
|
||||
/*
|
||||
or config.name
|
||||
*/
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.lists) all imap0;
|
||||
inherit (lib.trivial) id;
|
||||
in {
|
||||
config.exports.services.home-assistant = { config, ... }: let
|
||||
config.exports.services.home-assistant = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.home-assistant;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
assertPort = nixosConfig: cfg: {
|
||||
assertion = config.ports.default.port == cfg.config.http.server_port;
|
||||
message = "port mismatch";
|
||||
|
|
@ -16,10 +21,11 @@ in {
|
|||
assertHomekitPort = let
|
||||
portName = i: "homekit${toString i}";
|
||||
mkAssertPort = i: homekit: config.ports.${portName i}.port or null == homekit.port;
|
||||
in nixosConfig: cfg: {
|
||||
assertion = all id (imap0 mkAssertPort cfg.config.homekit);
|
||||
message = "homekit port mismatch";
|
||||
};
|
||||
in
|
||||
nixosConfig: cfg: {
|
||||
assertion = all id (imap0 mkAssertPort cfg.config.homekit);
|
||||
message = "homekit port mismatch";
|
||||
};
|
||||
in {
|
||||
id = mkAlmostOptionDefault "home";
|
||||
nixos = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
config.exports.services.invidious = { config, ... }: {
|
||||
config.exports.services.invidious = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "yt";
|
||||
nixos = {
|
||||
serviceAttr = "invidious";
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.kerberos = { config, ... }: {
|
||||
config.exports.services.kerberos = {config, ...}: {
|
||||
id = "krb5";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
default = {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,32 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.keycloak = { config, ... }: {
|
||||
config.exports.services.keycloak = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "sso";
|
||||
nixos = {
|
||||
serviceAttr = "keycloak";
|
||||
assertions = let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.keycloak;
|
||||
in f nixosConfig cfg;
|
||||
in mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.${cfg.protocol}.port == cfg.port;
|
||||
message = "port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.${cfg.protocol}.enable;
|
||||
message = "port enable mismatch";
|
||||
}))
|
||||
];
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in
|
||||
mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.${cfg.protocol}.port == cfg.port;
|
||||
message = "port mismatch";
|
||||
}))
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.${cfg.protocol}.enable;
|
||||
message = "port enable mismatch";
|
||||
}))
|
||||
];
|
||||
};
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
http = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.ldap = { config, ... }: {
|
||||
config.exports.services.ldap = {config, ...}: {
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
default = {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.minecraft-bedrock-server = { config, ... }: let
|
||||
config.exports.services.minecraft-bedrock-server = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.minecraft-bedrock-server;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in {
|
||||
nixos = {
|
||||
serviceAttr = "minecraft-bedrock-server";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.lists) all imap0;
|
||||
inherit (lib.trivial) id;
|
||||
in {
|
||||
config.exports.services.mosquitto = { config, ... }: {
|
||||
config.exports.services.mosquitto = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "mqtt";
|
||||
nixos = {
|
||||
serviceAttr = "mosquitto";
|
||||
|
|
@ -13,7 +17,8 @@ in {
|
|||
(nixosConfig: let
|
||||
cfg = nixosConfig.services.mosquitto;
|
||||
portName = i:
|
||||
if i == 0 then "default"
|
||||
if i == 0
|
||||
then "default"
|
||||
else "listener${toString i}";
|
||||
mkAssertPort = i: listener: config.ports.${portName i}.port or null == listener.port;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.motion = { config, ... }: {
|
||||
config.exports.services.motion = {config, ...}: {
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
default = {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,34 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.nfs = { config, ... }: let
|
||||
config.exports.services.nfs = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.nfs;
|
||||
in f nixosConfig cfg;
|
||||
mkAssertionPort = portName: mkAssertion (nixosConfig: cfg: let
|
||||
portAttr = "${portName}Port";
|
||||
in {
|
||||
assertion = mkAssertPort config.ports.${portName} cfg.server.${portAttr};
|
||||
message = "${portAttr} mismatch";
|
||||
});
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
mkAssertionPort = portName:
|
||||
mkAssertion (nixosConfig: cfg: let
|
||||
portAttr = "${portName}Port";
|
||||
in {
|
||||
assertion = mkAssertPort config.ports.${portName} cfg.server.${portAttr};
|
||||
message = "${portAttr} mismatch";
|
||||
});
|
||||
mkAssertPort = port: cfgPort: let
|
||||
cmpPort = if port.enable then port.port else null;
|
||||
in cfgPort == cmpPort;
|
||||
cmpPort =
|
||||
if port.enable
|
||||
then port.port
|
||||
else null;
|
||||
in
|
||||
cfgPort == cmpPort;
|
||||
in {
|
||||
nixos = {
|
||||
serviceAttrPath = [ "services" "nfs" "server" ];
|
||||
serviceAttrPath = ["services" "nfs" "server"];
|
||||
assertions = mkIf config.enable [
|
||||
(mkAssertionPort "statd")
|
||||
(mkAssertionPort "lockd")
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.nginx = { config, ... }: let
|
||||
config.exports.services.nginx = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.nginx;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
assertPorts = nixosConfig: cfg: {
|
||||
assertion = config.ports.http.port == cfg.defaultHTTPListenPort && config.ports.https.port == cfg.defaultSSLListenPort;
|
||||
message = "ports mismatch";
|
||||
|
|
|
|||
|
|
@ -1,22 +1,28 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.openwebrx = { config, ... }: {
|
||||
config.exports.services.openwebrx = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "webrx";
|
||||
nixos = {
|
||||
serviceAttr = "openwebrx";
|
||||
assertions = let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.openwebrx;
|
||||
in f nixosConfig cfg;
|
||||
in mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.default.port == cfg.port;
|
||||
message = "port mismatch";
|
||||
}))
|
||||
];
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in
|
||||
mkIf config.enable [
|
||||
(mkAssertion (nixosConfig: cfg: {
|
||||
assertion = config.ports.default.port == cfg.port;
|
||||
message = "port mismatch";
|
||||
}))
|
||||
];
|
||||
};
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
config.exports.services.postgresql = { config, ... }: let
|
||||
config.exports.services.postgresql = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.postgresql;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
in {
|
||||
nixos = {
|
||||
serviceAttr = "postgresql";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
in {
|
||||
config.exports.services.proxmox = { config, ... }: {
|
||||
config.exports.services.proxmox = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "prox";
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports.default = mapAlmostOptionDefaults {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@
|
|||
inherit (lib.trivial) mapNullable;
|
||||
inherit (lib.strings) concatStringsSep;
|
||||
systemConfig = config;
|
||||
portModule = {config, service, ...}: {
|
||||
portModule = {
|
||||
config,
|
||||
service,
|
||||
...
|
||||
}: {
|
||||
options = with lib.types; {
|
||||
enable =
|
||||
mkEnableOption "port"
|
||||
|
|
@ -86,7 +90,7 @@
|
|||
};
|
||||
assertions = mkOption {
|
||||
type = listOf (functionTo attrs);
|
||||
default = [ ];
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
defaults = {
|
||||
|
|
@ -107,7 +111,8 @@
|
|||
serviceConfig = getAttrFromPath config.nixos.serviceAttrPath;
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = serviceConfig nixosConfig;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
enableAssertion = nixosConfig: cfg: {
|
||||
assertion = (! cfg ? enable) || (config.enable == cfg.enable);
|
||||
message = "enable == nixosConfig.${concatStringsSep "." config.nixos.serviceAttrPath}.enable";
|
||||
|
|
@ -120,12 +125,18 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
nixosModule = {config, system, ...}: let
|
||||
nixosModule = {
|
||||
config,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
mapAssertion = service: a: let
|
||||
res = a config;
|
||||
in res // {
|
||||
message = "system.exports.${service.name}: " + res.message or "assertion failed";
|
||||
};
|
||||
in
|
||||
res
|
||||
// {
|
||||
message = "system.exports.${service.name}: " + res.message or "assertion failed";
|
||||
};
|
||||
assertions = mapAttrsToList (_: service: map (mapAssertion service) service.nixos.assertions) system.exports.services;
|
||||
in {
|
||||
config = {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs filterAttrs mapAttrsToList;
|
||||
inherit (lib.lists) sort;
|
||||
in {
|
||||
config.exports.services.sshd = { config, ... }: let
|
||||
config.exports.services.sshd = {config, ...}: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.openssh;
|
||||
in f nixosConfig cfg;
|
||||
in
|
||||
f nixosConfig cfg;
|
||||
sorted = sort (a: b: a > b);
|
||||
assertPorts = nixosConfig: cfg: let
|
||||
nixosPorts = cfg.ports;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.unifi = { config, ... }: {
|
||||
config.exports.services.unifi = {config, ...}: {
|
||||
nixos.serviceAttr = "unifi";
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
config.exports.services.vouch-proxy = { config, ... }: {
|
||||
config.exports.services.vouch-proxy = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "login";
|
||||
defaults.port.listen = mkAlmostOptionDefault "localhost";
|
||||
nixos = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
{
|
||||
lib,
|
||||
gensokyo-zone,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
config.exports.services.zigbee2mqtt = { config, ... }: {
|
||||
config.exports.services.zigbee2mqtt = {config, ...}: {
|
||||
id = mkAlmostOptionDefault "z2m";
|
||||
nixos = {
|
||||
serviceAttr = "zigbee2mqtt";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue