nixos/ports: use _module.args

This commit is contained in:
Guanran Wang 2024-10-19 13:00:06 +08:00
parent 60d435c2af
commit 2e3649cc9d
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
10 changed files with 30 additions and 26 deletions

View file

@ -9,7 +9,6 @@
imports = [ imports = [
"${modulesPath}/virtualisation/amazon-image.nix" "${modulesPath}/virtualisation/amazon-image.nix"
./anti-feature.nix ./anti-feature.nix
./ports.nix
./services/forgejo.nix ./services/forgejo.nix
./services/keycloak.nix ./services/keycloak.nix
@ -23,6 +22,8 @@
../../../nixos/profiles/sing-box-server ../../../nixos/profiles/sing-box-server
]; ];
_module.args.ports = import ./ports.nix;
boot.loader.grub.device = lib.mkForce "/dev/nvme0n1"; boot.loader.grub.device = lib.mkForce "/dev/nvme0n1";
system.stateVersion = "24.05"; system.stateVersion = "24.05";

View file

@ -1,11 +1,9 @@
{ {
lib.ports = { keycloak = 8010;
keycloak = 8010; vaultwarden = 8040;
vaultwarden = 8040; wastebin = 8050;
wastebin = 8050;
prometheus = 9010; prometheus = 9010;
blackbox = 9020; blackbox = 9020;
alertmanager = 9030; alertmanager = 9030;
};
} }

View file

@ -1,11 +1,11 @@
{ {
lib, lib,
config,
pkgs, pkgs,
ports,
... ...
}: }:
let let
port = config.lib.ports.keycloak; port = ports.keycloak;
in in
{ {
services.keycloak = { services.keycloak = {
@ -13,9 +13,10 @@ in
settings = { settings = {
cache = "local"; cache = "local";
hostname = "id.ny4.dev"; hostname = "id.ny4.dev";
http-enabled = true;
http-host = "127.0.0.1"; http-host = "127.0.0.1";
http-port = port; http-port = port;
proxy = "edge"; proxy-headers = "xforwarded";
}; };
database.passwordFile = toString (pkgs.writeText "password" "keycloak"); database.passwordFile = toString (pkgs.writeText "password" "keycloak");
}; };

View file

@ -3,10 +3,10 @@
pkgs, pkgs,
config, config,
nodes, nodes,
ports,
... ...
}: }:
let let
inherit (config.lib) ports;
targets = lib.mapAttrsToList (_name: node: node.fqdn) nodes ++ [ "pek0.ny4.dev" ]; targets = lib.mapAttrsToList (_name: node: node.fqdn) nodes ++ [ "pek0.ny4.dev" ];
in in
{ {

View file

@ -1,6 +1,11 @@
{ lib, config, ... }: {
lib,
config,
ports,
...
}:
let let
port = config.lib.ports.vaultwarden; port = ports.vaultwarden;
in in
{ {
services.vaultwarden = { services.vaultwarden = {

View file

@ -1,6 +1,6 @@
{ lib, config, ... }: { lib, ports, ... }:
let let
port = config.lib.ports.wastebin; port = ports.wastebin;
in in
{ {
services.wastebin = { services.wastebin = {

View file

@ -2,7 +2,6 @@
{ {
imports = [ imports = [
./anti-feature.nix ./anti-feature.nix
./ports.nix
./services/telegram-bot/danbooru_img_bot.nix ./services/telegram-bot/danbooru_img_bot.nix
./services/ip-checker.nix ./services/ip-checker.nix
@ -11,6 +10,8 @@
../../../nixos/profiles/sing-box-server ../../../nixos/profiles/sing-box-server
]; ];
_module.args.ports = import ./ports.nix;
system.stateVersion = "24.05"; system.stateVersion = "24.05";
networking.firewall.allowedUDPPorts = [ 443 ]; networking.firewall.allowedUDPPorts = [ 443 ];

View file

@ -1,6 +1,4 @@
{ {
lib.ports = { redlib = 8010;
redlib = 8010; ip-checker = 8020;
ip-checker = 8020;
};
} }

View file

@ -2,11 +2,11 @@
lib, lib,
pkgs, pkgs,
inputs, inputs,
config, ports,
... ...
}: }:
let let
port = config.lib.ports.ip-checker; port = ports.ip-checker;
in in
{ {
systemd.services."ip-checker" = { systemd.services."ip-checker" = {

View file

@ -1,6 +1,6 @@
{ lib, config, ... }: { lib, ports, ... }:
let let
port = config.lib.ports.redlib; port = ports.redlib;
in in
{ {
services.redlib = { services.redlib = {