chore: nf-fmt-nix

This commit is contained in:
arcnmx 2024-10-02 21:33:38 -07:00
parent 7cdcaad10d
commit d04959b11a
5 changed files with 87 additions and 44 deletions

View file

@ -72,7 +72,10 @@ in {
return = "302 https://wiki.${domain}/minecraft/";
};
"/minecraft/map" = {xvars, ...}: let
defaultMap = if minecraft.ports.bluemap.enable then "bmap" else "dmap";
defaultMap =
if minecraft.ports.bluemap.enable
then "bmap"
else "dmap";
in {
return = "302 ${xvars.get.scheme}://${xvars.get.host}/minecraft/${defaultMap}/";
};

View file

@ -1,4 +1,8 @@
{config, lib, ...}: let
{
config,
lib,
...
}: let
in {
users = {
groups.backups = {

View file

@ -1,4 +1,10 @@
{pkgs, config, systemConfig, lib, ...}: let
{
pkgs,
config,
systemConfig,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.attrsets) mapAttrs' mapAttrsToList nameValuePair;
inherit (lib.lists) concatMap toList;
@ -34,7 +40,8 @@
ls = "${pkgs.coreutils}/bin/ls";
tail = "${pkgs.coreutils}/bin/tail";
mkLatestDb = database: ''${ls} ${mkSharedPath "plex/Databases/${database}"}* | ${tail} -n1'';
in concatMapStringsSep " &&\n" mkLatestDb databases;
in
concatMapStringsSep " &&\n" mkLatestDb databases;
};
};
postgresql = {
@ -58,7 +65,14 @@
in {
services.restic.backups = let
isBackup = config.networking.hostName == "hakurei";
mkBackupB2 = name: subpath': { config, enable ? config.enable, user ? config.user or null, subpath ? subpath', compression ? "max", settings ? {} }: let
mkBackupB2 = name: subpath': {
config,
enable ? config.enable,
user ? config.user or null,
subpath ? subpath',
compression ? "max",
settings ? {},
}: let
tags = [
"infra"
"shared-${name}"
@ -72,7 +86,8 @@ in {
paths = map mkSharedPath (toList subpath);
extraBackupArgs = mkMerge [
(mkIf (compression != "auto") [
"--compression" compression
"--compression"
compression
])
(concatMap (tag: ["--tag" tag]) tags)
];
@ -82,13 +97,24 @@ in {
RandomizedDelaySec = "4h";
};
};
in mkIf (enable || isBackup) (mkMerge [ conf settings ]);
in
mkIf (enable || isBackup) (mkMerge [conf settings]);
backups = mapAttrs' (subpath: service: let
name = replaceStrings ["/"] ["-"] subpath;
in nameValuePair "${name}-b2" (mkBackupB2 name subpath service)) sharedServices;
in backups;
in
nameValuePair "${name}-b2" (mkBackupB2 name subpath service))
sharedServices;
in
backups;
users.groups.${group} = {
members = mapAttrsToList (_: { config, enable ? config.enable, user ? config.user or null, ... }: mkIf (enable && user != null) user) sharedServices;
members = mapAttrsToList (_: {
config,
enable ? config.enable,
user ? config.user or null,
...
}:
mkIf (enable && user != null) user)
sharedServices;
};
sops.secrets = let
sopsFile = mkDefault ../secrets/restic.yaml;

View file

@ -23,7 +23,8 @@
repo = "minecraft-modpack";
branch = "marka-${versions.majorMinor mcVersion}";
pages = true;
packUrl = if pages
packUrl =
if pages
then "https://${owner}.github.io/${repo}/pack.toml"
else "https://raw.githubusercontent.com/${owner}/${repo}/refs/heads/${branch}/pack.toml";
};
@ -42,7 +43,8 @@ in {
broadcast-console-to-ops = false;
op-permission-level = 2;
};
in mkMerge [
in
mkMerge [
(mapDefaults props)
(mkIf enableDynmap {
max-tick-time = 60000 * 12;
@ -99,11 +101,14 @@ in {
};
};
preStart = let
forgeDir = {
forgeDir =
{
neoforge = "neoforged/neoforge";
forge = "minecraftforge/forge";
}.${forge};
in mkMerge [
}
.${forge};
in
mkMerge [
"${pkgs.coreutils}/bin/ln -sf $PWD/libraries/net/${forgeDir}/*/unix_args.txt $RUNTIME_DIRECTORY/unix_args.txt"
(mkIf packwizUpdate ''
if ! java -jar packwiz-installer-bootstrap.jar -g -s server ${modpack.packUrl}; then
@ -124,7 +129,8 @@ in {
};
tmpfiles.rules = let
inherit (config.systemd.services.minecraft-java-server.gensokyo-zone) cacheMounts;
in mkMerge [
in
mkMerge [
[
#["d ${backupsDir} 775 ${cfg.user} ${cfg.group} - -"]
"d ${cacheMounts."minecraft/logs".source} 750 ${cfg.user} ${cfg.group} - -"

View file

@ -25,9 +25,11 @@ in {
systemd.services.plex = mkIf cfg.enable {
gensokyo-zone = {
sharedMounts.plex.path = mkDefault cfg.dataDir;
cacheMounts = mapAttrs' (name: _: nameValuePair "plex/${name}" {
cacheMounts = mapAttrs' (name: _:
nameValuePair "plex/${name}" {
path = mkDefault "${cfg.dataDir}/${name}";
}) plexCaches;
})
plexCaches;
};
# /var/lib/plex/mesa_shader_cache
environment.MESA_SHADER_CACHE_DIR = mkDefault cfg.dataDir;
@ -36,8 +38,10 @@ in {
ln = "${pkgs.coreutils}/bin/ln";
install = "${pkgs.coreutils}/bin/install";
# systemd doesn't seem to like spaces so use a symlink instead...
mkCacheSetup = name: { path ? "Plex Media Server/${subpath}", subpath ? name }:
''${ln} -srfT "$PLEX_DATADIR/"${escapeShellArg name} "$PLEX_DATADIR/"${escapeShellArg path}'';
mkCacheSetup = name: {
path ? "Plex Media Server/${subpath}",
subpath ? name,
}: ''${ln} -srfT "$PLEX_DATADIR/"${escapeShellArg name} "$PLEX_DATADIR/"${escapeShellArg path}'';
cacheSetup = mapAttrsToList mkCacheSetup (filterAttrs (_: cache: cache.path or "" != null) plexCaches);
preStartScript = pkgs.writeShellScript "plex-run-prestart" ''
set -eu