Loading nixos/modules/services/monitoring/cockpit.nix +42 −8 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ in ''; }; showBanner = mkOption { description = "Whether to add the Cockpit banner to the issue and motd files."; type = types.bool; default = true; example = false; }; port = mkOption { description = "Port where cockpit will listen."; type = types.port; Loading @@ -62,16 +69,28 @@ in }; }; }; config = mkIf cfg.enable { config = mkIf cfg.enable { # expose cockpit-bridge system-wide environment.systemPackages = [ cfg.package ]; # allow cockpit to find its plugins environment.pathsToLink = [ "/share/cockpit" ]; environment.etc = { # generate cockpit settings environment.etc."cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings; "cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings; # Add "Web console: ..." line to issue and MOTD "issue.d/cockpit.issue" = { enable = cfg.showBanner; source = "/run/cockpit/issue"; }; "motd.d/cockpit" = { enable = cfg.showBanner; source = "/run/cockpit/issue"; }; }; security.pam.services.cockpit = { startSession = true; Loading @@ -80,11 +99,26 @@ in networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; systemd.packages = [ cfg.package ]; systemd.sockets.cockpit.wantedBy = [ "multi-user.target" ]; systemd.sockets.cockpit.listenStreams = [ systemd.sockets.cockpit = { wantedBy = [ "multi-user.target" ]; listenStreams = [ "" # workaround so it doesn't listen on both ports caused by the runtime merging (toString cfg.port) ]; }; # Enable connecting to remote hosts from the login page systemd.services = mkIf (cfg.settings ? LoginTo -> cfg.settings.LoginTo) { "cockpit-wsinstance-http".path = [ config.programs.ssh.package cfg.package ]; "cockpit-wsinstance-https@".path = [ config.programs.ssh.package cfg.package ]; }; systemd.tmpfiles.rules = [ # From $out/lib/tmpfiles.d/cockpit-tmpfiles.conf Loading pkgs/by-name/co/cockpit/branding.css 0 → 100644 +11 −0 Original line number Diff line number Diff line #badge { inline-size: 225px; block-size: 80px; background-image: url("logo.png"); background-size: contain; background-repeat: no-repeat; } #brand::before { content: "${PRETTY_NAME}"; } pkgs/by-name/co/cockpit/package.nix +32 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ systemd, udev, xmlto, # Enables lightweight NixOS branding, replacing the default Cockpit icons withBranding ? true, nixos-icons, }: stdenv.mkDerivation (finalAttrs: { Loading Loading @@ -148,6 +151,17 @@ stdenv.mkDerivation (finalAttrs: { # hardcode libexecdir, I am assuming that cockpit only use it to find it's binaries printf 'def get_libexecdir() -> str:\n\treturn "%s"' "$out/libexec" >> src/cockpit/packages.py # patch paths used as visibility conditions in apps substituteInPlace pkg/*/manifest.json \ --replace-warn '"/usr/bin' '"/run/current-system/sw/bin' \ --replace-warn '"/usr/sbin' '"/run/current-system/sw/bin' \ --replace-warn '"/usr/share' '"/run/current-system/sw/share' \ --replace-warn '"/lib/systemd' '"/run/current-system/sw/lib/systemd' # replace reference to system python interpreter, used for e.g. sosreport substituteInPlace pkg/lib/python.ts \ --replace-fail /usr/libexec/platform-python ${python3Packages.python.interpreter} ''; configureFlags = [ Loading Loading @@ -200,6 +214,19 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace $out/lib/systemd/*/* \ --replace-warn /bin /run/current-system/sw/bin ${lib.optionalString withBranding '' mkdir -p "$out/share/cockpit/branding/nixos" pushd "$out/share/cockpit/branding/nixos" icons="${nixos-icons}/share/icons/hicolor" ln -s "$icons/16x16/apps/nix-snowflake.png" favicon.ico ln -s "$icons/256x256/apps/nix-snowflake.png" logo.png ln -s "$icons/256x256/apps/nix-snowflake.png" apple-touch-icon.png cp "${./branding.css}" branding.css popd ''} runHook postFixup ''; Loading Loading @@ -235,6 +262,9 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://cockpit-project.org/"; changelog = "https://cockpit-project.org/blog/cockpit-${finalAttrs.version}.html"; license = lib.licenses.lgpl21; maintainers = [ lib.maintainers.lucasew ]; maintainers = with lib.maintainers; [ lucasew andre4ik3 ]; }; }) Loading
nixos/modules/services/monitoring/cockpit.nix +42 −8 Original line number Diff line number Diff line Loading @@ -49,6 +49,13 @@ in ''; }; showBanner = mkOption { description = "Whether to add the Cockpit banner to the issue and motd files."; type = types.bool; default = true; example = false; }; port = mkOption { description = "Port where cockpit will listen."; type = types.port; Loading @@ -62,16 +69,28 @@ in }; }; }; config = mkIf cfg.enable { config = mkIf cfg.enable { # expose cockpit-bridge system-wide environment.systemPackages = [ cfg.package ]; # allow cockpit to find its plugins environment.pathsToLink = [ "/share/cockpit" ]; environment.etc = { # generate cockpit settings environment.etc."cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings; "cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings; # Add "Web console: ..." line to issue and MOTD "issue.d/cockpit.issue" = { enable = cfg.showBanner; source = "/run/cockpit/issue"; }; "motd.d/cockpit" = { enable = cfg.showBanner; source = "/run/cockpit/issue"; }; }; security.pam.services.cockpit = { startSession = true; Loading @@ -80,11 +99,26 @@ in networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; systemd.packages = [ cfg.package ]; systemd.sockets.cockpit.wantedBy = [ "multi-user.target" ]; systemd.sockets.cockpit.listenStreams = [ systemd.sockets.cockpit = { wantedBy = [ "multi-user.target" ]; listenStreams = [ "" # workaround so it doesn't listen on both ports caused by the runtime merging (toString cfg.port) ]; }; # Enable connecting to remote hosts from the login page systemd.services = mkIf (cfg.settings ? LoginTo -> cfg.settings.LoginTo) { "cockpit-wsinstance-http".path = [ config.programs.ssh.package cfg.package ]; "cockpit-wsinstance-https@".path = [ config.programs.ssh.package cfg.package ]; }; systemd.tmpfiles.rules = [ # From $out/lib/tmpfiles.d/cockpit-tmpfiles.conf Loading
pkgs/by-name/co/cockpit/branding.css 0 → 100644 +11 −0 Original line number Diff line number Diff line #badge { inline-size: 225px; block-size: 80px; background-image: url("logo.png"); background-size: contain; background-repeat: no-repeat; } #brand::before { content: "${PRETTY_NAME}"; }
pkgs/by-name/co/cockpit/package.nix +32 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ systemd, udev, xmlto, # Enables lightweight NixOS branding, replacing the default Cockpit icons withBranding ? true, nixos-icons, }: stdenv.mkDerivation (finalAttrs: { Loading Loading @@ -148,6 +151,17 @@ stdenv.mkDerivation (finalAttrs: { # hardcode libexecdir, I am assuming that cockpit only use it to find it's binaries printf 'def get_libexecdir() -> str:\n\treturn "%s"' "$out/libexec" >> src/cockpit/packages.py # patch paths used as visibility conditions in apps substituteInPlace pkg/*/manifest.json \ --replace-warn '"/usr/bin' '"/run/current-system/sw/bin' \ --replace-warn '"/usr/sbin' '"/run/current-system/sw/bin' \ --replace-warn '"/usr/share' '"/run/current-system/sw/share' \ --replace-warn '"/lib/systemd' '"/run/current-system/sw/lib/systemd' # replace reference to system python interpreter, used for e.g. sosreport substituteInPlace pkg/lib/python.ts \ --replace-fail /usr/libexec/platform-python ${python3Packages.python.interpreter} ''; configureFlags = [ Loading Loading @@ -200,6 +214,19 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace $out/lib/systemd/*/* \ --replace-warn /bin /run/current-system/sw/bin ${lib.optionalString withBranding '' mkdir -p "$out/share/cockpit/branding/nixos" pushd "$out/share/cockpit/branding/nixos" icons="${nixos-icons}/share/icons/hicolor" ln -s "$icons/16x16/apps/nix-snowflake.png" favicon.ico ln -s "$icons/256x256/apps/nix-snowflake.png" logo.png ln -s "$icons/256x256/apps/nix-snowflake.png" apple-touch-icon.png cp "${./branding.css}" branding.css popd ''} runHook postFixup ''; Loading Loading @@ -235,6 +262,9 @@ stdenv.mkDerivation (finalAttrs: { homepage = "https://cockpit-project.org/"; changelog = "https://cockpit-project.org/blog/cockpit-${finalAttrs.version}.html"; license = lib.licenses.lgpl21; maintainers = [ lib.maintainers.lucasew ]; maintainers = with lib.maintainers; [ lucasew andre4ik3 ]; }; })