mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-16 17:14:00 +00:00
nixos/smokeping: use nginx instead of thttpd
Motivation: fixes #265953 Changes: - deprecate `services.smokeping.port` in favor of the niginx native option - mention in release notes
This commit is contained in:
parent
8949291221
commit
0b6c484848
@ -399,6 +399,10 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
|
|||||||
|
|
||||||
- `halloy` package was updated past 2024.5 which introduced a breaking change by switching the config format from YAML to TOML. See https://github.com/squidowl/halloy/releases/tag/2024.5 for details.
|
- `halloy` package was updated past 2024.5 which introduced a breaking change by switching the config format from YAML to TOML. See https://github.com/squidowl/halloy/releases/tag/2024.5 for details.
|
||||||
|
|
||||||
|
- If `services.smokeping.webService` was enabled, smokeping is now served via nginx instead of thttpd. This change brings the following consequences:
|
||||||
|
- The default port for smokeping is now the nginx default port 80 instead of 8081.
|
||||||
|
- The option `services.smokeping.port` has been removed. To customize the port, use `services.nginx.virtualHosts.smokeping.listen.*.port`.
|
||||||
|
|
||||||
- The `wpaperd` package has a breaking change moving to 1.0.1, previous version 0.3.0 had 2 different configuration files, one for wpaperd and one for the wallpapers. Remove the former and move the latter (`wallpaper.toml`) to `config.toml`.
|
- The `wpaperd` package has a breaking change moving to 1.0.1, previous version 0.3.0 had 2 different configuration files, one for wpaperd and one for the wallpapers. Remove the former and move the latter (`wallpaper.toml`) to `config.toml`.
|
||||||
|
|
||||||
- Ada packages (libraries and tools) have been moved into the `gnatPackages` scope. `gnatPackages` uses the default GNAT compiler, `gnat12Packages` and `gnat13Packages` use the respective matching compiler version.
|
- Ada packages (libraries and tools) have been moved into the `gnatPackages` scope. `gnatPackages` uses the default GNAT compiler, `gnat12Packages` and `gnat13Packages` use the respective matching compiler version.
|
||||||
|
@ -47,6 +47,13 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule [ "services" "smokeping" "port" ] ''
|
||||||
|
The smokeping web service is now served by nginx.
|
||||||
|
In order to change the port, you need to change the nginx configuration under `services.nginx.virtualHosts.smokeping.listen.*.port`.
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.smokeping = {
|
services.smokeping = {
|
||||||
enable = mkEnableOption "smokeping service";
|
enable = mkEnableOption "smokeping service";
|
||||||
@ -71,8 +78,8 @@ in
|
|||||||
};
|
};
|
||||||
cgiUrl = mkOption {
|
cgiUrl = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "http://${cfg.hostName}:${toString cfg.port}/smokeping.cgi";
|
default = "http://${cfg.hostName}/smokeping.cgi";
|
||||||
defaultText = literalExpression ''"http://''${hostName}:''${toString port}/smokeping.cgi"'';
|
defaultText = literalExpression ''"http://''${hostName}/smokeping.cgi"'';
|
||||||
example = "https://somewhere.example.com/smokeping.cgi";
|
example = "https://somewhere.example.com/smokeping.cgi";
|
||||||
description = "URL to the smokeping cgi.";
|
description = "URL to the smokeping cgi.";
|
||||||
};
|
};
|
||||||
@ -177,11 +184,6 @@ in
|
|||||||
which makes it bind to all interfaces.
|
which makes it bind to all interfaces.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
port = mkOption {
|
|
||||||
type = types.port;
|
|
||||||
default = 8081;
|
|
||||||
description = "TCP port to use for the web server.";
|
|
||||||
};
|
|
||||||
presentationConfig = mkOption {
|
presentationConfig = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = ''
|
default = ''
|
||||||
@ -312,17 +314,8 @@ in
|
|||||||
description = "smokeping daemon user";
|
description = "smokeping daemon user";
|
||||||
home = smokepingHome;
|
home = smokepingHome;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
# When `cfg.webService` is enabled, `thttpd` makes SmokePing available
|
# When `cfg.webService` is enabled, `nginx` requires read permissions on the home directory.
|
||||||
# under `${cfg.host}:${cfg.port}/smokeping.fcgi` as per the `ln -s` below.
|
homeMode = "711";
|
||||||
# We also want that going to `${cfg.host}:${cfg.port}` without `smokeping.fcgi`
|
|
||||||
# makes it easy for the user to find SmokePing.
|
|
||||||
# However `thttpd` does not seem to support easy redirections from `/` to `smokeping.fcgi`
|
|
||||||
# and only allows directory listings or `/` -> `index.html` resolution if the directory
|
|
||||||
# has `chmod 755` (see https://acme.com/software/thttpd/thttpd_man.html#PERMISSIONS,
|
|
||||||
# " directories should be 755 if you want to allow indexing").
|
|
||||||
# Otherwise it shows `403 Forbidden` on `/`.
|
|
||||||
# Thus, we need to make `smokepingHome` (which is given to `thttpd -d` below) `755`.
|
|
||||||
homeMode = "755";
|
|
||||||
};
|
};
|
||||||
users.groups.${cfg.user} = { };
|
users.groups.${cfg.user} = { };
|
||||||
systemd.services.smokeping = {
|
systemd.services.smokeping = {
|
||||||
@ -342,21 +335,25 @@ in
|
|||||||
${cfg.package}/bin/smokeping --static --config=${configPath}
|
${cfg.package}/bin/smokeping --static --config=${configPath}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
systemd.services.thttpd = mkIf cfg.webService {
|
|
||||||
requiredBy = [ "multi-user.target" ];
|
# use nginx to serve the smokeping web service
|
||||||
requires = [ "smokeping.service" ];
|
services.fcgiwrap.enable = mkIf cfg.webService true;
|
||||||
path = with pkgs; [ bash rrdtool smokeping thttpd ];
|
services.nginx = mkIf cfg.webService {
|
||||||
serviceConfig = {
|
enable = true;
|
||||||
Restart = "always";
|
virtualHosts."smokeping" = {
|
||||||
ExecStart = lib.concatStringsSep " " (lib.concatLists [
|
serverName = mkDefault cfg.host;
|
||||||
[ "${pkgs.thttpd}/bin/thttpd" ]
|
locations."/" = {
|
||||||
[ "-u ${cfg.user}" ]
|
root = smokepingHome;
|
||||||
[ ''-c "**.fcgi"'' ]
|
index = "smokeping.fcgi";
|
||||||
[ "-d ${smokepingHome}" ]
|
};
|
||||||
(lib.optional (cfg.host != null) "-h ${cfg.host}")
|
locations."/smokeping.fcgi" = {
|
||||||
[ "-p ${builtins.toString cfg.port}" ]
|
extraConfig = ''
|
||||||
[ "-D -nos" ]
|
include ${config.services.nginx.package}/conf/fastcgi_params;
|
||||||
]);
|
fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
|
||||||
|
fastcgi_param SCRIPT_FILENAME ${smokepingHome}/smokeping.fcgi;
|
||||||
|
fastcgi_param DOCUMENT_ROOT ${smokepingHome};
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,6 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
networking.domain = "example.com"; # FQDN: sm.example.com
|
networking.domain = "example.com"; # FQDN: sm.example.com
|
||||||
services.smokeping = {
|
services.smokeping = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 8081;
|
|
||||||
mailHost = "127.0.0.2";
|
mailHost = "127.0.0.2";
|
||||||
probeConfig = ''
|
probeConfig = ''
|
||||||
+ FPing
|
+ FPing
|
||||||
@ -25,12 +24,19 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
start_all()
|
||||||
sm.wait_for_unit("smokeping")
|
sm.wait_for_unit("smokeping")
|
||||||
sm.wait_for_unit("thttpd")
|
sm.wait_for_unit("nginx")
|
||||||
sm.wait_for_file("/var/lib/smokeping/data/Local/LocalMachine.rrd")
|
sm.wait_for_file("/var/lib/smokeping/data/Local/LocalMachine.rrd")
|
||||||
sm.succeed("curl -s -f localhost:8081/smokeping.fcgi?target=Local")
|
sm.succeed("curl -s -f localhost/smokeping.fcgi?target=Local")
|
||||||
# Check that there's a helpful page without explicit path as well.
|
# Check that there's a helpful page without explicit path as well.
|
||||||
sm.succeed("curl -s -f localhost:8081")
|
sm.succeed("curl -s -f localhost")
|
||||||
sm.succeed("ls /var/lib/smokeping/cache/Local/LocalMachine_mini.png")
|
sm.succeed("ls /var/lib/smokeping/cache/Local/LocalMachine_mini.png")
|
||||||
sm.succeed("ls /var/lib/smokeping/cache/index.html")
|
sm.succeed("ls /var/lib/smokeping/cache/index.html")
|
||||||
|
|
||||||
|
# stop and start the service like nixos-rebuild would do
|
||||||
|
# see https://github.com/NixOS/nixpkgs/issues/265953)
|
||||||
|
sm.succeed("systemctl stop smokeping")
|
||||||
|
sm.succeed("systemctl start smokeping")
|
||||||
|
# ensure all services restarted properly
|
||||||
|
sm.succeed("systemctl --failed | grep -q '0 loaded units listed'")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user