Compare commits

..

3 commits

Author SHA1 Message Date
Update Bot f5869f9b14
Update from update-inputs-2024-09-30-14-11 2024-09-30 14:12:06 +02:00
Update Bot 2d87dc9c69
flake.lock: Update
Flake lock file updates:

• Updated input 'disko':
    'github:nix-community/disko/67dc29be3036cc888f0b9d4f0a788ee0f6768700' (2024-09-26)
  → 'github:nix-community/disko/b709e1cc33fcde71c7db43850a55ebe6449d0959' (2024-09-28)
• Updated input 'nixos-hardware':
    'github:nixos/nixos-hardware/d830ad47cc992b4a46b342bbc79694cbd0e980b2' (2024-09-27)
  → 'github:nixos/nixos-hardware/11c43c830e533dad1be527ecce379fcf994fbbb5' (2024-09-30)
• Updated input 'nixvim':
    'github:nix-community/nixvim/b5c19b6abb0fb0156b1cb76793b363e430e2cb47' (2024-09-27)
  → 'github:nix-community/nixvim/5f4a4b47597d3b9ac26c41ff4e8da28fa662f200' (2024-09-29)
• Updated input 'nixvim/git-hooks':
    'github:cachix/git-hooks.nix/4e743a6920eab45e8ba0fbe49dc459f1423a4b74' (2024-09-19)
  → 'github:cachix/git-hooks.nix/85f7a7177c678de68224af3402ab8ee1bcee25c8' (2024-09-28)
• Updated input 'nixvim/nix-darwin':
    'github:lnl7/nix-darwin/bd7d1e3912d40f799c5c0f7e5820ec950f1e0b3d' (2024-09-22)
  → 'github:lnl7/nix-darwin/f2e1c4aa29fc211947c3a7113cba1dd707433b70' (2024-09-28)
• Updated input 'nixvim/nuschtosSearch':
    'github:NuschtOS/search/3b7dd61b365ca45380707453758a45f2e9977be3' (2024-09-22)
  → 'github:NuschtOS/search/9f7426e532ef8dfc839c4a3fcc567b13a20a70d3' (2024-09-27)
• Updated input 'nixvim/treefmt-nix':
    'github:numtide/treefmt-nix/1bff2ba6ec22bc90e9ad3f7e94cca0d37870afa3' (2024-09-25)
  → 'github:numtide/treefmt-nix/879b29ae9a0378904fbbefe0dadaed43c8905754' (2024-09-27)
• Updated input 'stylix':
    'github:danth/stylix/e3eb7fdf8d129ff3676dfbc84ee1262322ca6fb4' (2024-09-26)
  → 'github:danth/stylix/0eea8bcb0f9c3c7638e7ee64f98ed9b4ec716830' (2024-09-29)
2024-09-30 14:12:03 +02:00
emily 7042efb4cb
librespeed: Fixes 2024-09-30 13:23:17 +02:00
2 changed files with 44 additions and 13 deletions

View file

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

View file

@ -71,12 +71,27 @@ in {
useNginx = mkOption {
description = ''
Configure nginx for the LibreSpeed frontend.
This will only create a virtual host for the frontend and won't proxy all requests,
because the reported upload and download speeds are inaccurate if proxied.
This will only create a virtual host for the frontend and won't proxy all requests because,
the reported upload and download speeds are inaccurate if proxied.
'';
default = cfg.domain != null;
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 {
description = "LibreSpeed servers that should apper in the server list.";
type = types.listOf (types.submodule {
@ -129,19 +144,36 @@ in {
};
};
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;
serversList = ''
function get_servers() {
return ${builtins.toJSON cfg.frontend.servers}
}
function override_settings () {
${mapSettings}
}
'';
} ''
}) ''
cp -r ${pkgs.librespeed-rust}/assets $out
chmod 666 $out/servers_list.js
cat >$out/servers_list.js <<<"$serversList"
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 "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)}
@ -180,15 +212,15 @@ in {
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
inherit (lib) mkDefault mkIf;
in {
assets_path = if (cfg.frontend.enable && !cfg.frontend.useNginx) then librespeedAssets
else pkgs.writeTextDir "index.html" ''
<!DOCTYPE html>
<html>
</html>
'';
else pkgs.writeTextDir "index.html" "";
bind_address = mkDefault "::";
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 "");
enable_tls = mkDefault (cfg.domain != null);
};
systemd.services = let