Compare commits
2 commits
3848274e0b
...
e64b2c705f
Author | SHA1 | Date | |
---|---|---|---|
e64b2c705f | |||
emily | 7b65cce048 |
|
@ -1,6 +1,7 @@
|
||||||
{ ... }: {
|
{ pkgs, ... }: {
|
||||||
services.librespeed = {
|
services.librespeed = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = pkgs.librespeed-go;
|
||||||
domain = "speed.kyouma.net";
|
domain = "speed.kyouma.net";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
36
flake.lock
36
flake.lock
|
@ -155,11 +155,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727249977,
|
"lastModified": 1727359191,
|
||||||
"narHash": "sha256-lAqOCDI4B6hA+t+KHSm/Go8hQF/Ob5sgXaIRtMAnMKw=",
|
"narHash": "sha256-5PltTychnExFwzpEnY3WhOywaMV/M6NxYI/y3oXuUtw=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "c1c472f4cd91e4b0703e02810a8c7ed30186b6fa",
|
"rev": "67dc29be3036cc888f0b9d4f0a788ee0f6768700",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -521,11 +521,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727246346,
|
"lastModified": 1727383923,
|
||||||
"narHash": "sha256-TcUaKtya339Asu+g6KTJ8h7KiKcKXKp2V+At+7tksyY=",
|
"narHash": "sha256-4/vacp3CwdGoPf8U4e/N8OsGYtO09WTcQK5FqYfJbKs=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "1e22ef1518fb175d762006f9cae7f6312b8caedb",
|
"rev": "ffe2d07e771580a005e675108212597e5b367d2d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -874,11 +874,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726937504,
|
"lastModified": 1727122398,
|
||||||
"narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
|
"narHash": "sha256-o8VBeCWHBxGd4kVMceIayf5GApqTavJbTa44Xcg5Rrk=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9357f4f23713673f310988025d9dc261c20e70c6",
|
"rev": "30439d93eb8b19861ccbe3e581abf97bdc91b093",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -905,11 +905,11 @@
|
||||||
"treefmt-nix": "treefmt-nix_2"
|
"treefmt-nix": "treefmt-nix_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727286212,
|
"lastModified": 1727402188,
|
||||||
"narHash": "sha256-iab+k8m6+MBkwQoyqMcMYggwILHCkMSkgNYd1GN0FbM=",
|
"narHash": "sha256-AxZVGgsWBDbhO1JVrYoHWG2IW5Se8JjJhC93Yfst4AM=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixvim",
|
"repo": "nixvim",
|
||||||
"rev": "7bda0f1ce49e9da252bcee20b5f700e6dcd3cf8d",
|
"rev": "cb2b76c1a9ec067ed0c449080f4973fecf8532ef",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1019,11 +1019,11 @@
|
||||||
"tinted-tmux": "tinted-tmux"
|
"tinted-tmux": "tinted-tmux"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727218376,
|
"lastModified": 1727362643,
|
||||||
"narHash": "sha256-vRYd45uOqzXDaSt8M50hLcsBqIWbEMsflfHk/a1nYA8=",
|
"narHash": "sha256-Ceiq/aYjRlRBU677lBaemn8ZU2Jpr08Iso6UlBc9nFc=",
|
||||||
"owner": "danth",
|
"owner": "danth",
|
||||||
"repo": "stylix",
|
"repo": "stylix",
|
||||||
"rev": "cf8b6e2d4e8aca8ef14b839a906ab5eb98b08561",
|
"rev": "e3eb7fdf8d129ff3676dfbc84ee1262322ca6fb4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1170,11 +1170,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726734507,
|
"lastModified": 1727252110,
|
||||||
"narHash": "sha256-VUH5O5AcOSxb0uL/m34dDkxFKP6WLQ6y4I1B4+N3L2w=",
|
"narHash": "sha256-3O7RWiXpvqBcCl84Mvqa8dXudZ1Bol1ubNdSmQt7nF4=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "ee41a466c2255a3abe6bc50fc6be927cdee57a9f",
|
"rev": "1bff2ba6ec22bc90e9ad3f7e94cca0d37870afa3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
#"eDP-1, 2560x1600@60, 0x0, 1, bitdepth, 10"
|
#"eDP-1, 2560x1600@60, 0x0, 1, bitdepth, 10"
|
||||||
#"eDP-1, 1920x1200@60, 0x0, 1, bitdepth, 10"
|
#"eDP-1, 1920x1200@60, 0x0, 1, bitdepth, 10"
|
||||||
"desc:Dell Inc. AW3225QF FXK2YZ3, 3840x2160@240,5280x0,1, bitdepth,10, vrr,2"
|
"desc:Dell Inc. AW3225QF FXK2YZ3, 3840x2160@240,5280x0,1, bitdepth,10, vrr,2"
|
||||||
"desc:GIGA-BYTE TECHNOLOGY CO. LTD. AORUS AD27QD 19320B000455, 2560x1440@144,3840x-350,1, bitdepth,10, transform,1"
|
"desc:GIGA-BYTE TECHNOLOGY CO. LTD. AORUS AD27QD 19320B000455, 2560x1440@144,3840x-280,1, bitdepth,10, transform,1"
|
||||||
",preferred,auto,1"
|
",preferred,auto,1"
|
||||||
];
|
];
|
||||||
workspace = [
|
workspace = [
|
||||||
|
|
|
@ -107,10 +107,10 @@ in {
|
||||||
'';
|
'';
|
||||||
default = {};
|
default = {};
|
||||||
type = with types; nullOr (attrsOf (oneOf [
|
type = with types; nullOr (attrsOf (oneOf [
|
||||||
bool
|
(nullOr bool)
|
||||||
int
|
int
|
||||||
str
|
str
|
||||||
null
|
package
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -130,11 +130,19 @@ in {
|
||||||
services.nginx.virtualHosts = lib.mkIf cfg.configureNginx {
|
services.nginx.virtualHosts = lib.mkIf cfg.configureNginx {
|
||||||
${cfg.domain} = {
|
${cfg.domain} = {
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://${cfg.settings.bind_address}:${toString cfg.settings.listen_port}";
|
proxyPass = "http://[::1]:${toString cfg.settings.listen_port}";
|
||||||
recommendedProxySettings = true;
|
recommendedProxySettings = true;
|
||||||
|
extraConfig = ''
|
||||||
|
proxy_cache off;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_request_buffering off;
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
|
extraConfig = ''
|
||||||
|
gzip off;
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
security.acme.certs = lib.mkIf cfg.configureNginx {
|
security.acme.certs = lib.mkIf cfg.configureNginx {
|
||||||
|
@ -144,7 +152,7 @@ in {
|
||||||
services.librespeed.servers = lib.mkIf (cfg.domain != null) [
|
services.librespeed.servers = lib.mkIf (cfg.domain != null) [
|
||||||
{
|
{
|
||||||
name = cfg.domain;
|
name = cfg.domain;
|
||||||
server = "https://${cfg.domain}";
|
server = "//${cfg.domain}${lib.optionalString (!cfg.configureNginx) ":${toString cfg.settings.listen_port}"}";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
services.librespeed.settings = let
|
services.librespeed.settings = let
|
||||||
|
@ -153,41 +161,48 @@ in {
|
||||||
assets = pkgs.runCommand "librespeed-assets" {
|
assets = pkgs.runCommand "librespeed-assets" {
|
||||||
preferLocal = true;
|
preferLocal = true;
|
||||||
|
|
||||||
serverList = ''
|
serversList = ''
|
||||||
function get_servers() {
|
function get_servers() {
|
||||||
return ${builtins.toJSON cfg.servers}
|
return ${builtins.toJSON cfg.servers}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
} ''
|
} ''
|
||||||
cp -r ${pkgs.librespeed-rust}/assets $out
|
cp -r ${pkgs.librespeed-rust}/assets $out
|
||||||
cat >$out/server_list.js <<<"$serverList"
|
chmod 666 $out/servers_list.js
|
||||||
|
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 "LibreSpeed Example" ${lib.escapeShellArg (lib.escapeXML cfg.pageTitle)} \
|
--replace-fail "LibreSpeed Example" ${lib.escapeShellArg (lib.escapeXML cfg.pageTitle)} \
|
||||||
--replace-fail "PUT@YOUR_EMAIL.HERE" ${lib.escapeShellArg (lib.escapeXML cfg.contactEmail)} \
|
--replace-fail "PUT@YOUR_EMAIL.HERE" ${lib.escapeShellArg (lib.escapeXML cfg.contactEmail)} \
|
||||||
--replace-fail "TO BE FILLED BY DEVELOPER" ${lib.escapeShellArg (lib.escapeXML cfg.contactEmail)}
|
--replace-fail "TO BE FILLED BY DEVELOPER" ${lib.escapeShellArg (lib.escapeXML cfg.contactEmail)}
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
speed_test_dir = assets;
|
#speed_test_dir = assets;
|
||||||
bind_address = mkDefault (if cfg.configureNginx then "127.0.0.1" else "0.0.0.0");
|
assets_path = assets;
|
||||||
|
bind_address = mkDefault (if cfg.configureNginx then "::1" else "::");
|
||||||
listen_port = mkDefault 8989;
|
listen_port = mkDefault 8989;
|
||||||
base_url = mkDefault "backend";
|
#base_url = mkDefault "backend";
|
||||||
worker_threads = mkDefault "auto";
|
#worker_threads = mkDefault "auto";
|
||||||
|
|
||||||
database_type = mkDefault "none";
|
server_lat = 0;
|
||||||
database_file = mkIf (cfg.settings.database_type == "sqlite") mkDefault "/var/lib/librespeed/speedtest.sqlite";
|
server_lng = 0;
|
||||||
|
proxyprotocol_port = 0;
|
||||||
|
redact_ip_addresses = false;
|
||||||
|
|
||||||
#librespeed-rust will fail to start if the following config parameters are omitted.
|
#librespeed-rust will fail to start if the following config parameters are omitted.
|
||||||
ipinfo_api_key = mkIf (!cfg.secrets ? "ipinfo_api_key") "";
|
ipinfo_api_key = mkIf (!cfg.secrets ? "ipinfo_api_key") "";
|
||||||
stats_password = mkIf (!cfg.secrets ? "stats_password") "";
|
stats_password = mkIf (!cfg.secrets ? "stats_password") "";
|
||||||
tls_key_file = mkDefault "";
|
#tls_key_file = mkDefault "";
|
||||||
tls_cet_file = mkDefault "";
|
#tls_cet_file = mkDefault "";
|
||||||
|
|
||||||
enable_tls = mkDefault false;
|
enable_tls = mkDefault false;
|
||||||
|
} // rec {
|
||||||
|
database_type = mkDefault "none";
|
||||||
|
database_file = mkIf (database_type == "sqlite") (mkDefault "/var/lib/librespeed/speedtest.sqlite");
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = let
|
systemd.services = let
|
||||||
configFile = let
|
configFile = let
|
||||||
anyToString = arg: if (lib.isBool arg) then
|
mapValue = arg: if (lib.isBool arg) then
|
||||||
lib.boolToString arg
|
lib.boolToString arg
|
||||||
else if (lib.isInt arg) then
|
else if (lib.isInt arg) then
|
||||||
toString arg
|
toString arg
|
||||||
|
@ -195,8 +210,9 @@ in {
|
||||||
in
|
in
|
||||||
with lib; pipe cfg.settings [
|
with lib; pipe cfg.settings [
|
||||||
(filterAttrs (_: val: val != null))
|
(filterAttrs (_: val: val != null))
|
||||||
(mapAttrs (name: val: "${path}=${anyToString val}"))
|
(mapAttrs (name: val: "${name}=${mapValue val}"))
|
||||||
(concatLines attrValues)
|
(attrValues)
|
||||||
|
(concatLines)
|
||||||
(pkgs.writeText "${cfg.package.name}-config.toml")
|
(pkgs.writeText "${cfg.package.name}-config.toml")
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
|
@ -239,7 +255,7 @@ in {
|
||||||
|
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
|
|
||||||
ExecStartPre = lib.mkIf (!cfg.secrets ? "ipinfo_api_key") "${lib.getExe cfg.package} --update-ipdb";
|
#ExecStartPre = lib.mkIf (!cfg.secrets ? "ipinfo_api_key") "${lib.getExe cfg.package} --update-ipdb";
|
||||||
ExecStart = "${lib.getExe cfg.package} -c ${if (cfg.secrets == {}) then configFile else "\${RUNTIME_DIRECTORY%%:*}/config.toml"}";
|
ExecStart = "${lib.getExe cfg.package} -c ${if (cfg.secrets == {}) then configFile else "\${RUNTIME_DIRECTORY%%:*}/config.toml"}";
|
||||||
WorkingDirectory = "/var/cache/librespeed";
|
WorkingDirectory = "/var/cache/librespeed";
|
||||||
RuntimeDirectory = "librespeed";
|
RuntimeDirectory = "librespeed";
|
||||||
|
|
34
pkgs/librespeed-go/default.nix
Normal file
34
pkgs/librespeed-go/default.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
fetchFromGitHub,
|
||||||
|
buildGoModule,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
version = "1.1.5";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "librespeed";
|
||||||
|
repo = "speedtest-go";
|
||||||
|
rev = "refs/tags/v${version}";
|
||||||
|
hash = "sha256-ywGrodl/mj/WB25F0TKVvaV0PV4lgc+KEj0x/ix9HT8=";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
buildGoModule {
|
||||||
|
pname = "librespeed-go";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
vendorHash = "sha256-ev5TEv8u+tx7xIvNaK8b5iq2XXF6I37Fnrr8mb+N2WM=";
|
||||||
|
|
||||||
|
ldflags = [ "-w" "-s" ];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
cp -r web/assets $out/
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "A very lightweight speed test implementation in Go.";
|
||||||
|
homepage = "https://github.com/librespeed/speedtest-go";
|
||||||
|
license = lib.licenses.lgpl3Plus;
|
||||||
|
maintainers = with lib.maintainers; [ snaki ];
|
||||||
|
mainProgram = "speedtest";
|
||||||
|
};
|
||||||
|
}
|
|
@ -32,5 +32,6 @@ rustPlatform.buildRustPackage {
|
||||||
homepage = "https://github.com/librespeed/speedtest-rust";
|
homepage = "https://github.com/librespeed/speedtest-rust";
|
||||||
license = lib.licenses.lgpl3Plus;
|
license = lib.licenses.lgpl3Plus;
|
||||||
maintainers = with lib.maintainers; [ snaki ];
|
maintainers = with lib.maintainers; [ snaki ];
|
||||||
|
mainProgram = "librespeed-rs";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@ final: prev: {
|
||||||
update-nixfiles = final.callPackage ./update-nixfiles/default.nix {};
|
update-nixfiles = final.callPackage ./update-nixfiles/default.nix {};
|
||||||
build-worker-oci = final.callPackage ./build-worker-oci/default.nix {};
|
build-worker-oci = final.callPackage ./build-worker-oci/default.nix {};
|
||||||
librespeed-rust = final.callPackage ./librespeed-rust/default.nix {};
|
librespeed-rust = final.callPackage ./librespeed-rust/default.nix {};
|
||||||
|
librespeed-go = final.callPackage ./librespeed-go/default.nix {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue