chore: nf-fmt-nix

This commit is contained in:
arcnmx 2024-07-31 11:13:50 -07:00
parent c2726dd41b
commit ffde3c1c27
14 changed files with 170 additions and 131 deletions

View file

@ -54,12 +54,15 @@ let
++ optional (sshd.ports.public.enable or false) sshd.ports.public.port ++ optional (sshd.ports.public.enable or false) sshd.ports.public.port
++ [sshd.ports.standard.port] ++ [sshd.ports.standard.port]
); );
in mkOptionDefault port; in
mkOptionDefault port;
hostName = let hostName = let
hostName = if config.network != null hostName =
if config.network != null
then system.network.networks.${config.network}.fqdn then system.network.networks.${config.network}.fqdn
else sshHostConfig.hostName; else sshHostConfig.hostName;
in mkOptionDefault hostName; in
mkOptionDefault hostName;
hostKeyAlias = mkOptionDefault sshHostConfig.hostKeyAlias; hostKeyAlias = mkOptionDefault sshHostConfig.hostKeyAlias;
matchBlockSettings = { matchBlockSettings = {
hostname = mkDefault config.hostName; hostname = mkDefault config.hostName;
@ -176,7 +179,10 @@ let
then head canonNetworkName' then head canonNetworkName'
else null; else null;
mkNetwork = network: nameValuePair (mkNetworkName network) (mkNetworkConf network); mkNetwork = network: nameValuePair (mkNetworkName network) (mkNetworkConf network);
mkNetworkName = network: if network != null then network else "fallback"; mkNetworkName = network:
if network != null
then network
else "fallback";
mkNetworkConf = network: let mkNetworkConf = network: let
needsProxy = network == "int" || (network == "local" && !access.local.enable); needsProxy = network == "int" || (network == "local" && !access.local.enable);
networkConf = { networkConf = {
@ -186,7 +192,8 @@ let
cfg.proxyJump cfg.proxyJump
))); )));
}; };
in networkConf; in
networkConf;
in in
mapListToAttrs mkNetwork networks; mapListToAttrs mkNetwork networks;
set = { set = {
@ -197,7 +204,8 @@ let
extraOptions = unmerged.mergeAttrs config.extraOptions; extraOptions = unmerged.mergeAttrs config.extraOptions;
}; };
extraSettings = unmerged.mergeAttrs config.extraSettings; extraSettings = unmerged.mergeAttrs config.extraSettings;
in mkMerge [ matchBlock extraSettings ]; in
mkMerge [matchBlock extraSettings];
matchBlocksSettings = let matchBlocksSettings = let
mkMatchBlock = _: network: let mkMatchBlock = _: network: let
matchBlockConf = mkMerge [ matchBlockConf = mkMerge [

View file

@ -23,7 +23,10 @@
}: let }: let
port = service.ports.${portName}; port = service.ports.${portName};
# TODO: this properly # TODO: this properly
getAddressFor = if port.status.gatus.client.network or "ip" == "ip4" then "getAddress4For" else "getAddressFor"; getAddressFor =
if port.status.gatus.client.network or "ip" == "ip4"
then "getAddress4For"
else "getAddressFor";
in "${mkAddress6 (access.${getAddressFor} system.name "lan")}:${toString port.port}"; in "${mkAddress6 (access.${getAddressFor} system.name "lan")}:${toString port.port}";
mkServiceConfig = system: serviceName: let mkServiceConfig = system: serviceName: let
inherit (service.prometheus) exporter; inherit (service.prometheus) exporter;

View file

@ -75,8 +75,10 @@ in {
allowedTCPPorts = map mkExporterPort exporters; allowedTCPPorts = map mkExporterPort exporters;
res = builtins.tryEval (any (enablePort true) exporters); res = builtins.tryEval (any (enablePort true) exporters);
cond = lib.warnIf (!res.success) "broken prometheus exporter: ${name}" res.value; cond = lib.warnIf (!res.success) "broken prometheus exporter: ${name}" res.value;
in mkIf cond allowedTCPPorts; in
mkIf cond allowedTCPPorts;
mkExporterPort = exporter: mkIf (enablePort false exporter) exporter.port; mkExporterPort = exporter: mkIf (enablePort false exporter) exporter.port;
in mkMerge (mapAttrsToList mkExporterPorts allExporters); in
mkMerge (mapAttrsToList mkExporterPorts allExporters);
}; };
} }

View file

@ -30,5 +30,6 @@ in {
''ENV{SYSTEMD_WANTS}="motion.service"'' ''ENV{SYSTEMD_WANTS}="motion.service"''
]; ];
rulesLine = concatStringsSep ", " rules; rulesLine = concatStringsSep ", " rules;
in rulesLine; in
rulesLine;
} }

View file

@ -1,7 +1,4 @@
{ {gensokyo-zone, ...}: let
gensokyo-zone,
...
}: let
inherit (gensokyo-zone.lib) mapDefaults; inherit (gensokyo-zone.lib) mapDefaults;
in { in {
services.motion.cameras.webcam.settings = mapDefaults { services.motion.cameras.webcam.settings = mapDefaults {

View file

@ -31,5 +31,6 @@ in {
''ENV{SYSTEMD_WANTS}="motion.service"'' ''ENV{SYSTEMD_WANTS}="motion.service"''
]; ];
rulesLine = concatStringsSep ", " rules; rulesLine = concatStringsSep ", " rules;
in rulesLine; in
rulesLine;
} }

View file

@ -15,20 +15,21 @@ in {
services.octoprint = { services.octoprint = {
enable = mkDefault true; enable = mkDefault true;
# host = mkIf config.networking.enableIPv6 "::"; # host = mkIf config.networking.enableIPv6 "::";
plugins = python3Packages: with python3Packages; [ plugins = python3Packages:
prometheus-exporter with python3Packages; [
octorant prometheus-exporter
queue octorant
abl-expert queue
bedlevelvisualizer abl-expert
#displayprogress / displaylayerprogress? bedlevelvisualizer
marlingcodedocumentation #displayprogress / displaylayerprogress?
printtimegenius marlingcodedocumentation
stlviewer printtimegenius
#octoklipper? stlviewer
#octolapse? #octoklipper?
#dashboard? #octolapse?
]; #dashboard?
];
extraConfig = mkMerge [ extraConfig = mkMerge [
# https://docs.octoprint.org/en/master/configuration/config_yaml.html # https://docs.octoprint.org/en/master/configuration/config_yaml.html
{ {
@ -167,12 +168,13 @@ in {
autologinHeadsupAcknowledged = true; autologinHeadsupAcknowledged = true;
#autologinAs = "guest"; #autologinAs = "guest";
autologinAs = "admin"; autologinAs = "admin";
localNetworks = access.cidrForNetwork.allLocal.all localNetworks =
++ [ access.cidrForNetwork.allLocal.all
# vouch protects it from the outside world so... ++ [
"0.0.0.0/0" # vouch protects it from the outside world so...
"::/0" "0.0.0.0/0"
]; "::/0"
];
}; };
}) })
(mkIf (vouchHeader != null) { (mkIf (vouchHeader != null) {

View file

@ -8,16 +8,23 @@ in {
freeipa = let freeipa = let
inherit (prev) freeipa; inherit (prev) freeipa;
python3 = final.python311; python3 = final.python311;
freeipa'py311 = (freeipa.override { freeipa'py311 =
inherit python3; (freeipa.override {
}).overrideAttrs (old: { inherit python3;
nativeBuildInputs = [ })
python3 .overrideAttrs (old: {
] ++ old.nativeBuildInputs; nativeBuildInputs =
}); [
python3
]
++ old.nativeBuildInputs;
});
isBroken = !(builtins.tryEval freeipa.outPath).success; isBroken = !(builtins.tryEval freeipa.outPath).success;
isUpdated = lib.versionAtLeast freeipa.version "4.12.2"; isUpdated = lib.versionAtLeast freeipa.version "4.12.2";
isPythonUpdated = lib.versionAtLeast final.python3.version "3.12"; isPythonUpdated = lib.versionAtLeast final.python3.version "3.12";
warnFixed = lib.warnIf isUpdated "freeipa python overlay fix probably no longer needed"; warnFixed = lib.warnIf isUpdated "freeipa python overlay fix probably no longer needed";
in if isPythonUpdated && (isBroken || !isUpdated) then freeipa'py311 else warnFixed freeipa; in
if isPythonUpdated && (isBroken || !isUpdated)
then freeipa'py311
else warnFixed freeipa;
} }

View file

@ -2,47 +2,58 @@ final: prev: let
inherit (final) lib; inherit (final) lib;
in { in {
cura-octoprint = final.cura.override { cura-octoprint = final.cura.override {
plugins = [ final.curaPlugins.octoprint ]; plugins = [final.curaPlugins.octoprint];
}; };
octoprint = let octoprint = let
mapPlugin = python3Packages: _: plugin: plugin.override { mapPlugin = python3Packages: _: plugin:
inherit python3Packages; plugin.override {
inherit (python3Packages) buildPlugin; inherit python3Packages;
}; inherit (python3Packages) buildPlugin;
packageOverrides = python3Packages: python3Packages'prev: lib.mapAttrs (mapPlugin python3Packages) { };
inherit (final.octoprintPlugins) prometheus-exporter octorant queue printtimegenius; packageOverrides = python3Packages: python3Packages'prev:
}; lib.mapAttrs (mapPlugin python3Packages) {
inherit (final.octoprintPlugins) prometheus-exporter octorant queue printtimegenius;
};
octoprint = prev.octoprint.override (old: { octoprint = prev.octoprint.override (old: {
packageOverrides = lib.composeExtensions old.packageOverrides or (_: _: {}) packageOverrides; packageOverrides = lib.composeExtensions old.packageOverrides or (_: _: {}) packageOverrides;
}); });
in octoprint; in
octoprint;
octoprintPlugins = let octoprintPlugins = let
pythonPackages = final.octoprint.python.pkgs; pythonPackages = final.octoprint.python.pkgs;
octoprintPlugins'overlay = final.callPackage (final.path + "/pkgs/applications/misc/octoprint/plugins.nix") { }; octoprintPlugins'overlay = final.callPackage (final.path + "/pkgs/applications/misc/octoprint/plugins.nix") {};
octoprintPlugins'nixpkgs = octoprintPlugins'overlay pythonPackages pythonPackages; octoprintPlugins'nixpkgs = octoprintPlugins'overlay pythonPackages pythonPackages;
octoprintPlugins = prev.octoprintPlugins or octoprintPlugins'nixpkgs; octoprintPlugins = prev.octoprintPlugins or octoprintPlugins'nixpkgs;
callPackage = final.newScope { callPackage = final.newScope {
inherit (final.octoprintPlugins) buildPlugin; inherit (final.octoprintPlugins) buildPlugin;
}; };
in octoprintPlugins // { in
callPackage = prev.octoprintPlugins.callPackage or callPackage; octoprintPlugins
// {
callPackage = prev.octoprintPlugins.callPackage or callPackage;
prometheus-exporter = callPackage ../packages/octoprint/prometheus-exporter.nix { }; prometheus-exporter = callPackage ../packages/octoprint/prometheus-exporter.nix {};
octorant = callPackage ../packages/octoprint/octorant.nix { }; octorant = callPackage ../packages/octoprint/octorant.nix {};
queue = callPackage ../packages/octoprint/queue.nix { }; queue = callPackage ../packages/octoprint/queue.nix {};
printtimegenius = let printtimegenius = let
printtimegenius = { fetchFromGitHub, python3Packages, buildPlugin }: octoprintPlugins.printtimegenius.overrideAttrs (old: rec { printtimegenius = {
version = lib.warnIf (lib.versionAtLeast old.version "2.3.2") "printtimegenius updated upstream" "2.3.3"; fetchFromGitHub,
src = fetchFromGitHub { python3Packages,
inherit (old.src) owner repo; buildPlugin,
rev = version; }:
sha256 = "sha256-hqm8RShCNpsVbrVXquat5VXqcVc7q5tn5+7Ipqmaw4U="; octoprintPlugins.printtimegenius.overrideAttrs (old: rec {
}; version = lib.warnIf (lib.versionAtLeast old.version "2.3.2") "printtimegenius updated upstream" "2.3.3";
}); src = fetchFromGitHub {
in callPackage printtimegenius { }; inherit (old.src) owner repo;
}; rev = version;
sha256 = "sha256-hqm8RShCNpsVbrVXquat5VXqcVc7q5tn5+7Ipqmaw4U=";
};
});
in
callPackage printtimegenius {};
};
# XXX: build broken upstream ugh... # XXX: build broken upstream ugh...
curaengine = prev.curaengine.override { curaengine = prev.curaengine.override {

View file

@ -6,7 +6,8 @@
# https://github.com/minecraft-linux/server-modloader/tree/master?tab=readme-ov-file#getting-mods-to-work-on-newer-versions-116 # https://github.com/minecraft-linux/server-modloader/tree/master?tab=readme-ov-file#getting-mods-to-work-on-newer-versions-116
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
python = python3.withPackages (p: [p.lief]); python = python3.withPackages (p: [p.lief]);
static_symbols = if lib.versionAtLeast python3.pkgs.lief.version "0.15.0" static_symbols =
if lib.versionAtLeast python3.pkgs.lief.version "0.15.0"
then "symtab_symbols" then "symtab_symbols"
else "static_symbols"; else "static_symbols";
script = '' script = ''

View file

@ -1,28 +1,30 @@
{ buildPlugin {
, python3Packages buildPlugin,
, fetchFromGitHub python3Packages,
fetchFromGitHub,
}: let }: let
pname = "OctoPrint-Octorant"; pname = "OctoPrint-Octorant";
version = "1.3.4"; version = "1.3.4";
in buildPlugin { in
inherit pname version; buildPlugin {
inherit pname version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "bchanudet"; owner = "bchanudet";
repo = pname; repo = pname;
rev = version; rev = version;
sha256 = "sha256-gP79zlJ8gdtpddXOJIMhouSbwXnrSf+c1bURkN/7jvw="; sha256 = "sha256-gP79zlJ8gdtpddXOJIMhouSbwXnrSf+c1bURkN/7jvw=";
}; };
patches = [ patches = [
./octorant-timelapse-uri.patch ./octorant-timelapse-uri.patch
]; ];
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = with python3Packages; [
pillow pillow
]; ];
meta = { meta = {
homepage = "https://github.com/bchanudet/OctoPrint-Octorant"; homepage = "https://github.com/bchanudet/OctoPrint-Octorant";
}; };
} }

View file

@ -1,28 +1,30 @@
{ buildPlugin {
, python3Packages buildPlugin,
, fetchFromGitHub python3Packages,
fetchFromGitHub,
}: let }: let
version = "0.2.3"; version = "0.2.3";
in buildPlugin { in
pname = "OctoPrint-Prometheus-Exporter"; buildPlugin {
inherit version; pname = "OctoPrint-Prometheus-Exporter";
inherit version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "tg44"; owner = "tg44";
repo = "OctoPrint-Prometheus-Exporter"; repo = "OctoPrint-Prometheus-Exporter";
rev = version; rev = version;
sha256 = "sha256-pw5JKMWQNAkFkUADR2ue6R4FOmFIeapw2k5FLqJ6NQg="; sha256 = "sha256-pw5JKMWQNAkFkUADR2ue6R4FOmFIeapw2k5FLqJ6NQg=";
}; };
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = with python3Packages; [
prometheus-client prometheus-client
]; ];
patches = [ patches = [
./prometheus-exporter-deregister.patch ./prometheus-exporter-deregister.patch
]; ];
meta = { meta = {
homepage = "https://github.com/tg44/OctoPrint-Prometheus-Exporter"; homepage = "https://github.com/tg44/OctoPrint-Prometheus-Exporter";
}; };
} }

View file

@ -1,23 +1,25 @@
{ buildPlugin {
, python3Packages buildPlugin,
, fetchFromGitHub python3Packages,
fetchFromGitHub,
}: let }: let
version = "2.0.0"; version = "2.0.0";
pname = "OctoPrint-Queue"; pname = "OctoPrint-Queue";
in buildPlugin { in
inherit pname version; buildPlugin {
inherit pname version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "chennes"; owner = "chennes";
repo = pname; repo = pname;
rev = "v${version}"; rev = "v${version}";
sha256 = "sha256-uAG6GrUKXUdUTtzmjKWPiHxMa3ekvoLpSIvFMiJI+/8="; sha256 = "sha256-uAG6GrUKXUdUTtzmjKWPiHxMa3ekvoLpSIvFMiJI+/8=";
}; };
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = with python3Packages; [
]; ];
meta = { meta = {
homepage = "https://github.com/chennes/OctoPrint-Queue"; homepage = "https://github.com/chennes/OctoPrint-Queue";
}; };
} }

View file

@ -51,7 +51,7 @@ in {
#jack.enable = true; #jack.enable = true;
}; };
environment.systemPackages = [ pkgs.cura-octoprint ]; environment.systemPackages = [pkgs.cura-octoprint];
users.users.logistics = { users.users.logistics = {
uid = 1000; uid = 1000;