refactoring

This commit is contained in:
Simon Gardling 2024-10-17 15:45:29 -04:00
parent 59dd30a67d
commit 4ec6a035a5
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
9 changed files with 33 additions and 37 deletions

View File

@ -119,7 +119,7 @@
tmux tmux
(pkgs.writeScriptBin "mc-attach" '' (pkgs.writeScriptBin "mc-console" ''
#!/bin/sh #!/bin/sh
${pkgs.tmux}/bin/tmux -S /run/minecraft/${service_configs.minecraft.server_name}.sock attach ${pkgs.tmux}/bin/tmux -S /run/minecraft/${service_configs.minecraft.server_name}.sock attach
'') '')
@ -237,9 +237,9 @@
"render" "render"
"minecraft" "minecraft"
"gitea" config.services.gitea.group
"jellyfin" config.services.jellyfin.group
"ollama" config.services.caddy.group
]; ];
hashedPasswordFile = "/etc/nixos/secrets/hashedPass"; hashedPasswordFile = "/etc/nixos/secrets/hashedPass";

20
flake.lock generated
View File

@ -43,11 +43,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1728784327, "lastModified": 1729129578,
"narHash": "sha256-Ib1rAnxE4ZZtO3WE7E4+mwivz37gwNOW5qPToJb9RPQ=", "narHash": "sha256-iZnoPpexSDKsCNFWfF6QFsxD/jC+l6GalSqx7Q3L41M=",
"owner": "Infinidoge", "owner": "Infinidoge",
"repo": "nix-minecraft", "repo": "nix-minecraft",
"rev": "14f679c6eaba1ef43b6f6092ba82e24cba97c858", "rev": "8a5c546a755ecc089ea8355c5b7ccbe284e8f00e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -74,16 +74,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728492678, "lastModified": 1729194116,
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", "narHash": "sha256-JrdCY/CX30eyUhd7u8hmDgZLuG/HsNDqTu8RQQTpQO0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", "rev": "8e8d47269fef696d0264584a33405bae4c9a4005",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "master",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -95,11 +95,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1727065535, "lastModified": 1729072507,
"narHash": "sha256-jX83vspAPZnnpFUylUYqP+J1RoZc9w10bbQtsEwD20A=", "narHash": "sha256-srn/XjGNtaO34/CX6H85NVIQ1ksBDOSToMiLu+22Tek=",
"owner": "SEIAROTg", "owner": "SEIAROTg",
"repo": "quadlet-nix", "repo": "quadlet-nix",
"rev": "51e2beaaf127c8b4460d909c6c29ed9d60bfde0c", "rev": "5970e7be88ec6d063a79c7669a68918c4827caa0",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -2,8 +2,8 @@
description = "Flake for server muffin"; description = "Flake for server muffin";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# nixpkgs.url = "github:NixOS/nixpkgs/master"; nixpkgs.url = "github:NixOS/nixpkgs/master";
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware.url = "github:NixOS/nixos-hardware/master";
@ -21,7 +21,7 @@
nix-minecraft, nix-minecraft,
nixos-hardware, nixos-hardware,
... ...
}: }@inputs:
let let
username = "primary"; username = "primary";
hostname = "muffin"; hostname = "muffin";
@ -34,11 +34,8 @@
# TODO: add checks to make sure none of these collide # TODO: add checks to make sure none of these collide
ports = { ports = {
https = 443; https = 443;
immich = 3001; jellyfin = 8096; # no services.jellyfin option for this
jellyfin = 8096;
torrent = 6011; torrent = 6011;
minecraft = 25565;
gitea = 3281;
ollama = 11434; ollama = 11434;
}; };
@ -75,8 +72,7 @@
}; };
jellyfin = { jellyfin = {
data_dir = service_configs.services_dir + "/jellyfin"; dir = service_configs.services_dir + "/jellyfin";
cache_dir = service_configs.services_dir + "/jellyfin_cache";
}; };
ollama = { ollama = {
@ -92,6 +88,7 @@
hostname hostname
eth_interface eth_interface
service_configs service_configs
inputs
; ;
}; };
modules = [ modules = [

View File

@ -1,4 +1,4 @@
{ service_configs, ... }: { config, service_configs, ... }:
{ {
services.caddy = { services.caddy = {
enable = true; enable = true;
@ -15,7 +15,7 @@
''; '';
"immich.gardling.com".extraConfig = '' "immich.gardling.com".extraConfig = ''
reverse_proxy 127.0.0.1:${builtins.toString service_configs.ports.immich} reverse_proxy 127.0.0.1:${builtins.toString config.services.immich.port}
''; '';
"jellyfin.gardling.com".extraConfig = '' "jellyfin.gardling.com".extraConfig = ''
@ -26,7 +26,7 @@
''; '';
${service_configs.gitea.domain}.extraConfig = '' ${service_configs.gitea.domain}.extraConfig = ''
reverse_proxy 127.0.0.1:${builtins.toString service_configs.ports.gitea} reverse_proxy 127.0.0.1:${builtins.toString config.services.gitea.settings.server.HTTP_PORT}
''; '';
}; };
}; };

View File

@ -16,8 +16,8 @@
settings = { settings = {
server = { server = {
DOMAIN = service_configs.gitea.domain; DOMAIN = service_configs.gitea.domain;
ROOT_URL = "https://" + service_configs.gitea.domain; ROOT_URL = "https://" + config.services.gitea.settings.server.DOMAIN;
HTTP_PORT = service_configs.ports.gitea; HTTP_PORT = 3281;
LANDING_PAGE = "/explore/repos"; LANDING_PAGE = "/explore/repos";
}; };
session = { session = {

View File

@ -8,7 +8,7 @@
services.immich = { services.immich = {
enable = true; enable = true;
mediaLocation = service_configs.immich.dir; mediaLocation = service_configs.immich.dir;
port = service_configs.ports.immich; port = 2283;
host = "0.0.0.0"; host = "0.0.0.0";
database = { database = {
createDB = false; createDB = false;

View File

@ -16,8 +16,8 @@
# used for local streaming # used for local streaming
openFirewall = true; openFirewall = true;
dataDir = service_configs.jellyfin.data_dir; dataDir = service_configs.jellyfin.dir;
cacheDir = service_configs.jellyfin.cache_dir; cacheDir = config.services.jellyfin.dataDir + "/cache";
}; };
users.users.${config.services.jellyfin.user}.extraGroups = [ users.users.${config.services.jellyfin.user}.extraGroups = [
@ -27,7 +27,7 @@
# https://github.com/lyarenei/jellyfin-plugin-listenbrainz/issues/107 # https://github.com/lyarenei/jellyfin-plugin-listenbrainz/issues/107
system.activationScripts.jellyfinListenBrain.text = '' system.activationScripts.jellyfinListenBrain.text = ''
cp -v /etc/nixos/secrets/Jellyfin.Plugin.ListenBrainz.xml ${service_configs.jellyfin.data_dir}/plugins/configurations/ cp -v /etc/nixos/secrets/Jellyfin.Plugin.ListenBrainz.xml ${config.services.jellyfin.dataDir}/plugins/configurations/
chown ${config.services.jellyfin.user}:${config.services.jellyfin.group} ${service_configs.jellyfin.data_dir}/plugins/configurations/Jellyfin.Plugin.ListenBrainz.xml chown ${config.services.jellyfin.user}:${config.services.jellyfin.group} ${config.services.jellyfin.dataDir}/plugins/configurations/Jellyfin.Plugin.ListenBrainz.xml
''; '';
} }

View File

@ -8,7 +8,7 @@
services.ollama = { services.ollama = {
enable = true; enable = true;
home = service_configs.ollama.data_dir + "/home"; home = service_configs.ollama.data_dir + "/home";
models = service_configs.ollama.data_dir + "/home/models"; models = config.services.ollama.home + "/models";
environmentVariables = { environmentVariables = {
OLLAMA_LLM_LIBRARY = "cpu_avx2"; OLLAMA_LLM_LIBRARY = "cpu_avx2";
}; };

View File

@ -24,11 +24,10 @@ in
enable = true; enable = true;
package = pkgs.fabricServers.fabric-1_21_1; package = pkgs.fabricServers.fabric-1_21_1;
# Aikar's flags jvmOpts = "-Xmx${heap_size} -Xms${heap_size} -XX:+UseZGC -XX:+ZGenerational";
jvmOpts = "-Xmx${heap_size} -Xms${heap_size} -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32";
serverProperties = { serverProperties = {
server-port = service_configs.ports.minecraft; server-port = 25565;
enforce-whitelist = true; enforce-whitelist = true;
gamemode = "survival"; gamemode = "survival";
white-list = true; white-list = true;