Update from update-inputs-2024-09-30-14-11

This commit is contained in:
Update Bot 2024-09-30 14:12:06 +02:00
commit f5869f9b14
No known key found for this signature in database
2 changed files with 44 additions and 13 deletions

View file

@ -743,11 +743,11 @@
}, },
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1727613673, "lastModified": 1727665282,
"narHash": "sha256-qqIffTQfxMYo3MKQ9BoY2s2mdKZNnUiksdnxv81js9U=", "narHash": "sha256-oKtfbQB1MBypqIyzkC8QCQcVGOa1soaXaGgcBIoh14o=",
"owner": "nixos", "owner": "nixos",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "f5c239fa9acb27f0a5326ba2949c00fada89ca9f", "rev": "11c43c830e533dad1be527ecce379fcf994fbbb5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -71,12 +71,27 @@ in {
useNginx = mkOption { useNginx = mkOption {
description = '' description = ''
Configure nginx for the LibreSpeed frontend. Configure nginx for the LibreSpeed frontend.
This will only create a virtual host for the frontend and won't proxy all requests, This will only create a virtual host for the frontend and won't proxy all requests because,
because the reported upload and download speeds are inaccurate if proxied. the reported upload and download speeds are inaccurate if proxied.
''; '';
default = cfg.domain != null; default = cfg.domain != null;
type = types.bool; type = types.bool;
}; };
settings = mkOption {
description = ''
Override default test parameters.
See [speedtest_worker.js][link] for a list of possible values.
[link]: https://github.com/librespeed/speedtest/blob/master/speedtest_worker.js#L39
'';
default = {};
type = with types; nullOr (attrsOf (oneOf [
bool
int
str
float
]));
};
servers = mkOption { servers = mkOption {
description = "LibreSpeed servers that should apper in the server list."; description = "LibreSpeed servers that should apper in the server list.";
type = types.listOf (types.submodule { type = types.listOf (types.submodule {
@ -129,19 +144,36 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable (let config = lib.mkIf cfg.enable (let
librespeedAssets = pkgs.runCommand "librespeed-assets" { librespeedAssets = pkgs.runCommand "librespeed-assets" (let
mapValue = arg: if (lib.isBool arg) then
lib.boolToString arg
else if ((lib.isInt arg) || (lib.isFloat arg)) then
toString arg
else
"\"${lib.escape [ "\"" ] (toString arg)}\"";
mapSettings = lib.pipe cfg.frontend.settings [
(lib.mapAttrs (name: val: " s.setParameter(\"${lib.escape [ "\"" ] name}\",${mapValue val});"))
(lib.attrValues)
(lib.concatLines)
];
in {
preferLocal = true; preferLocal = true;
serversList = '' serversList = ''
function get_servers() { function get_servers() {
return ${builtins.toJSON cfg.frontend.servers} return ${builtins.toJSON cfg.frontend.servers}
} }
function override_settings () {
${mapSettings}
}
''; '';
} '' }) ''
cp -r ${pkgs.librespeed-rust}/assets $out cp -r ${pkgs.librespeed-rust}/assets $out
chmod 666 $out/servers_list.js chmod 666 $out/servers_list.js
cat >$out/servers_list.js <<<"$serversList" cat >$out/servers_list.js <<<"$serversList"
substitute ${pkgs.librespeed-rust}/assets/index.html $out/index.html \ substitute ${pkgs.librespeed-rust}/assets/index.html $out/index.html \
--replace-fail "s.setParameter(\"telemetry_level\",\"basic\"); //enable telemetry" "override_settings();" \
--replace-fail "LibreSpeed Example" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.pageTitle)} \ --replace-fail "LibreSpeed Example" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.pageTitle)} \
--replace-fail "PUT@YOUR_EMAIL.HERE" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.contactEmail)} \ --replace-fail "PUT@YOUR_EMAIL.HERE" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.contactEmail)} \
--replace-fail "TO BE FILLED BY DEVELOPER" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.contactEmail)} --replace-fail "TO BE FILLED BY DEVELOPER" ${lib.escapeShellArg (lib.escapeXML cfg.frontend.contactEmail)}
@ -180,15 +212,15 @@ in {
server = "//${cfg.domain}:${toString cfg.settings.listen_port}"; server = "//${cfg.domain}:${toString cfg.settings.listen_port}";
} }
]; ];
services.librespeed.frontend.settings = lib.mkIf cfg.frontend.enable {
telemetry_level = lib.mkDefault "basic";
};
services.librespeed.settings = let services.librespeed.settings = let
inherit (lib) mkDefault mkIf; inherit (lib) mkDefault mkIf;
in { in {
assets_path = if (cfg.frontend.enable && !cfg.frontend.useNginx) then librespeedAssets assets_path = if (cfg.frontend.enable && !cfg.frontend.useNginx) then librespeedAssets
else pkgs.writeTextDir "index.html" '' else pkgs.writeTextDir "index.html" "";
<!DOCTYPE html>
<html>
</html>
'';
bind_address = mkDefault "::"; bind_address = mkDefault "::";
listen_port = mkDefault 8989; listen_port = mkDefault 8989;
@ -205,7 +237,6 @@ in {
tls_key_file = if (cfg.domain != null) then (mkDefault "/run/credentials/librespeed.service/key.pem") else (mkDefault ""); tls_key_file = if (cfg.domain != null) then (mkDefault "/run/credentials/librespeed.service/key.pem") else (mkDefault "");
enable_tls = mkDefault (cfg.domain != null); enable_tls = mkDefault (cfg.domain != null);
}; };
systemd.services = let systemd.services = let