2023-01-05 15:23:55 -03:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.cockpit;
|
2024-04-13 14:54:15 +02:00
|
|
|
inherit (lib) types mkEnableOption mkOption mkIf literalMD mkPackageOption;
|
2023-01-05 15:23:55 -03:00
|
|
|
settingsFormat = pkgs.formats.ini {};
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.cockpit = {
|
2024-04-13 14:54:15 +02:00
|
|
|
enable = mkEnableOption "Cockpit";
|
2023-01-05 15:23:55 -03:00
|
|
|
|
2023-11-30 19:03:14 +01:00
|
|
|
package = mkPackageOption pkgs "Cockpit" {
|
2023-01-05 15:23:55 -03:00
|
|
|
default = [ "cockpit" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
|
|
|
|
default = {};
|
|
|
|
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-01-05 15:23:55 -03:00
|
|
|
Settings for cockpit that will be saved in /etc/cockpit/cockpit.conf.
|
|
|
|
|
|
|
|
See the [documentation](https://cockpit-project.org/guide/latest/cockpit.conf.5.html), that is also available with `man cockpit.conf.5` for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Port where cockpit will listen.";
|
2023-01-05 15:23:55 -03:00
|
|
|
type = types.port;
|
|
|
|
default = 9090;
|
|
|
|
};
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Open port for cockpit.";
|
2023-01-05 15:23:55 -03:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
# expose cockpit-bridge system-wide
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
|
|
|
# allow cockpit to find its plugins
|
|
|
|
environment.pathsToLink = [ "/share/cockpit" ];
|
|
|
|
|
|
|
|
# generate cockpit settings
|
|
|
|
environment.etc."cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings;
|
|
|
|
|
|
|
|
security.pam.services.cockpit = {};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
|
|
|
|
|
2024-12-28 15:46:40 -03:00
|
|
|
systemd.packages = [ cfg.package ];
|
|
|
|
systemd.sockets.cockpit.wantedBy = [ "multi-user.target" ];
|
2023-01-05 15:23:55 -03:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [ # From $out/lib/tmpfiles.d/cockpit-tmpfiles.conf
|
|
|
|
"C /run/cockpit/inactive.motd 0640 root root - ${cfg.package}/share/cockpit/motd/inactive.motd"
|
|
|
|
"f /run/cockpit/active.motd 0640 root root -"
|
|
|
|
"L+ /run/cockpit/motd - - - - inactive.motd"
|
|
|
|
"d /etc/cockpit/ws-certs.d 0600 root root 0"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = pkgs.cockpit.meta.maintainers;
|
|
|
|
}
|