Skip to content

Conversation

andre4ik3
Copy link
Member

This PR contains a bunch of small tweaks and fixes to the Cockpit package and NixOS module that fix some NixOS-specific bugs and improve the experience of using it overall:

Add some small NixOS branding and logos

This matches the way Cockpit branding is done in other distros, e.g. Fedora, Arch, etc. It's just a logo, favicon, and the OS text "NixOS 12.34 (Whatever)".

Cockpit login page, with NixOS logo and version title

Patch condition paths to fix some apps not displaying

Before, it would be checking e.g. for the existence of /usr/share/... or /lib/systemd/... to determine whether to show some applets. This would lead to e.g. Network and Storage applets never showing, even if NetworkManager or udisks2 was installed, as they weren't in the FHS paths. I added a substituteInPlace call to rewrite those paths to their NixOS counterparts, so now they'll show up if the dependencies are installed:

Storage applet working

Fix missing hostname in cockpit issue file

Fixes cockpit-issue.service failing due to missing hostname command. Now /run/cockpit/issue will have the proper hostname.

Fix reference to Python at runtime, fixes SoS

Before, SoS (sosreport, "Diagnostic reports") would load forever even if it was installed. If you opened the browser console, there would be an error about trying to run a Python script to read SoS configuration, but it would fail, because it was trying to execute /usr/libexec/platform-python. To fix this, I rewrote the platform-python reference to point to the Python interpreter in the build inputs. (of course SoS still has to be installed and configured separately)

SoS/sosreport applet working

Allow connections to remote hosts

If the LoginTo option is not set, Cockpit does some auto-detection to decide whether to show the "Connect to:" prompt. But this would always fail, as SSH wasn't in its path. To fix this, programs.ssh.package is added to cockpit-ws's PATH if LoginTo is undefined or set to true (so if it's set to false, it won't be added, as it's unnecessary). So by default, LoginTo will be undefined, SSH will be added to its PATH, and the "Connect to:" field will show. (This matches other distro's behavior too)

"Connect to" field

Add setting to show Cockpit banner in issue and MOTD (enabled by default)

Matches behavior of other distros (e.g. Fedora). Can be disabled with services.cockpit.showBanner = false

Cockpit banner on login

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Maintainer ping: @lucasew


Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jun 1, 2025
@andre4ik3 andre4ik3 requested a review from lucasew June 1, 2025 20:52
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jun 1, 2025
"cockpit/cockpit.conf".source = settingsFormat.generate "cockpit.conf" cfg.settings;

# Add "Web console: ..." line to issue and MOTD
"issue.d/cockpit.issue" = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why both?

which service provides this functionality?

Copy link
Member Author

@andre4ik3 andre4ik3 Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue is mostly for agetty: printed before login on TTYs. In agetty(8) it lists /etc/issue.d as one of the places it looks for to print issue files (but they must have .issue extension)

MOTD (message of the day) is for other programs, e.g. those that use PAM for authentication, there is the option security.pam.services.<name>.showMotd to enable it. Then it will be shown after logging in -- for example if you enable it for the sshd PAM service, it'll show the Cockpit banner when you SSH into the machine. There is a man page pam_motd(8) that describes it in more detail.

AFAIK default NixOS behavior is to enable issue and disable MOTD. If MOTD is enabled, the banner will show there by default (unless disabled with showBanner = false).

@lucasew
Copy link
Contributor

lucasew commented Jun 2, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 413033 --package nixosTests.cockpit
Commit: aee7208fc4d9767b0893881e3d87446f1ec07e8d


x86_64-linux

✅ 1 test built:
  • nixosTests.cockpit

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 25, 2025
@andre4ik3
Copy link
Member Author

Rebased.

- Add some small NixOS branding and logos
- Patch condition paths to fix some apps not displaying
- Fix missing hostname in cockpit issue file
- Fix reference to Python at runtime, fixes SoS
- Allow connections to remote hosts
- Add setting to show Cockpit banner in issue and MOTD (enabled by
  default)
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants