mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore: nf-fmt-nix
This commit is contained in:
parent
e4bbddb004
commit
32ff0a8e0c
7 changed files with 152 additions and 138 deletions
11
lib.nix
11
lib.nix
|
|
@ -19,16 +19,21 @@
|
||||||
nibble0 = Str.index part 0;
|
nibble0 = Str.index part 0;
|
||||||
in
|
in
|
||||||
nibble0 + UInt.toHexLower nibble1;
|
nibble0 + UInt.toHexLower nibble1;
|
||||||
in trimAddress6 "${part0 (part 0)}${part 1}:${part 2}ff:fe${part 3}:${part 4}${part 5}";
|
in
|
||||||
|
trimAddress6 "${part0 (part 0)}${part 1}:${part 2}ff:fe${part 3}:${part 4}${part 5}";
|
||||||
|
|
||||||
trimAddress6 = let
|
trimAddress6 = let
|
||||||
matcher = match ''(^|.*:)(0+)([0-9a-fA-F].*)'';
|
matcher = match ''(^|.*:)(0+)([0-9a-fA-F].*)'';
|
||||||
in addr: let
|
in
|
||||||
|
addr: let
|
||||||
matched = matcher addr;
|
matched = matcher addr;
|
||||||
prefix = elemAt matched 0;
|
prefix = elemAt matched 0;
|
||||||
postfix = elemAt matched 2;
|
postfix = elemAt matched 2;
|
||||||
addrReplaced = prefix + postfix;
|
addrReplaced = prefix + postfix;
|
||||||
in if matched == null then addr else trimAddress6 addrReplaced;
|
in
|
||||||
|
if matched == null
|
||||||
|
then addr
|
||||||
|
else trimAddress6 addrReplaced;
|
||||||
|
|
||||||
parseUrl = url: let
|
parseUrl = url: let
|
||||||
parts' = Regex.match ''^([^:]+)://(\[[0-9a-fA-F:]+]|[^/:\[]+)(|:[0-9]+)(|/.*)$'' url;
|
parts' = Regex.match ''^([^:]+)://(\[[0-9a-fA-F:]+]|[^/:\[]+)(|:[0-9]+)(|/.*)$'' url;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
let
|
let
|
||||||
deviceModule = {config, lib, ...}: let
|
deviceModule = {
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
in {
|
in {
|
||||||
options = with lib.types; {
|
options = with lib.types; {
|
||||||
enable = mkEnableOption "adb device" // {
|
enable =
|
||||||
|
mkEnableOption "adb device"
|
||||||
|
// {
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
uphold = mkOption {
|
uphold = mkOption {
|
||||||
|
|
@ -15,7 +21,8 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
config,
|
config,
|
||||||
gensokyo-zone,
|
gensokyo-zone,
|
||||||
utils,
|
utils,
|
||||||
|
|
@ -75,7 +82,8 @@ in {
|
||||||
conf.systemd.services.adb = {
|
conf.systemd.services.adb = {
|
||||||
upholds = let
|
upholds = let
|
||||||
upheldDevices = filterAttrs (_: device: device.uphold) enabledDevices;
|
upheldDevices = filterAttrs (_: device: device.uphold) enabledDevices;
|
||||||
in mapAttrsToList (_: device: "adb-device@${escapeSystemdPath device.serial}.service") upheldDevices;
|
in
|
||||||
|
mapAttrsToList (_: device: "adb-device@${escapeSystemdPath device.serial}.service") upheldDevices;
|
||||||
after = ["network.target"];
|
after = ["network.target"];
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
|
|
||||||
|
|
@ -295,14 +295,12 @@ in {
|
||||||
hasService = system: system.exports.services.${service}.enable;
|
hasService = system: system.exports.services.${service}.enable;
|
||||||
notFound = throw "no system found serving ${service}";
|
notFound = throw "no system found serving ${service}";
|
||||||
multiple = throw "multiple systems found serving ${service}";
|
multiple = throw "multiple systems found serving ${service}";
|
||||||
in
|
in (findSingle hasService notFound multiple (attrValues systems));
|
||||||
(findSingle hasService notFound multiple (attrValues systems));
|
|
||||||
systemForServiceId = serviceId: let
|
systemForServiceId = serviceId: let
|
||||||
hasService = system: findSingle (service: service.id == serviceId && service.enable) null multiple (attrValues system.exports.services) != null;
|
hasService = system: findSingle (service: service.id == serviceId && service.enable) null multiple (attrValues system.exports.services) != null;
|
||||||
notFound = throw "no system found serving ${serviceId}";
|
notFound = throw "no system found serving ${serviceId}";
|
||||||
multiple = throw "multiple systems found serving ${serviceId}";
|
multiple = throw "multiple systems found serving ${serviceId}";
|
||||||
in
|
in (findSingle hasService notFound multiple (attrValues systems));
|
||||||
(findSingle hasService notFound multiple (attrValues systems));
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,12 @@ in {
|
||||||
settings.fail_timeout = mkDefault timeout;
|
settings.fail_timeout = mkDefault timeout;
|
||||||
addr = mkDefault "10.1.1.67";
|
addr = mkDefault "10.1.1.67";
|
||||||
port = mkDefault nfandroidtv.ports.default.port;
|
port = mkDefault nfandroidtv.ports.default.port;
|
||||||
/*accessService = {
|
/*
|
||||||
|
accessService = {
|
||||||
system = "bedroomtv";
|
system = "bedroomtv";
|
||||||
name = "nfandroidtv";
|
name = "nfandroidtv";
|
||||||
};*/
|
};
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
fallback = let
|
fallback = let
|
||||||
virtualHost = nginx.virtualHosts.nfandroidtv'fallback;
|
virtualHost = nginx.virtualHosts.nfandroidtv'fallback;
|
||||||
|
|
@ -70,7 +72,8 @@ in {
|
||||||
config.networking.firewall.interfaces.lan = let
|
config.networking.firewall.interfaces.lan = let
|
||||||
virtualHost = nginx.virtualHosts.nfandroidtv'local;
|
virtualHost = nginx.virtualHosts.nfandroidtv'local;
|
||||||
listen = virtualHost.listen'.nfandroidtv;
|
listen = virtualHost.listen'.nfandroidtv;
|
||||||
in mkIf (virtualHost.enable && listen.enable) {
|
in
|
||||||
|
mkIf (virtualHost.enable && listen.enable) {
|
||||||
allowedTCPPorts = [listen.port];
|
allowedTCPPorts = [listen.port];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue