Skip to content

Improve COSMIC support on NixOS#369113

Closed
thefossguy wants to merge 5 commits intoNixOS:masterfrom
thefossguy:fix-cosmic
Closed

Improve COSMIC support on NixOS#369113
thefossguy wants to merge 5 commits intoNixOS:masterfrom
thefossguy:fix-cosmic

Conversation

@thefossguy
Copy link
Copy Markdown
Member

@thefossguy thefossguy commented Dec 29, 2024

I noticed that COSMIC from nixpkgs was not working well on my rock-5b and in x86 and aarch64 VMs. The screen would stay grey. I switched from COSMIC using Lily Foster's flake and it worked perfectly. This is my effort in upstreaming Lily's out of tree code into nixpkgs.

cc: @nyabinary @a-kenji @ahoneybun @alyssais

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

Add a 👍 reaction to pull requests you find important.

 - Switch from `makeBinaryWrapper` to `libcosmicAppHook`
 - Bump version of all cosmic packages to 'epoch-1.0.0-alpha.4'
 - Add 'thefossguy' to the maintainer for every updated package
 - Initialize `cosmic-idle`, `cosmic-player` and `cosmic-reader`
@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 Dec 29, 2024
@nix-owners nix-owners bot requested a review from Ericson2314 December 29, 2024 13:09
@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes labels Dec 29, 2024
@SigmaSquadron
Copy link
Copy Markdown
Contributor

SigmaSquadron commented Dec 29, 2024

I'm pretty sure that the COSMIC upstreaming effort is being coordinated by the COSMIC team. This is a massive PR and it'll be really hard to review this, especially since it seems to be a spur of the moment thing.

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Dec 29, 2024
@thefossguy
Copy link
Copy Markdown
Member Author

Not exactly a spur of the moment thing. I have been working this since the 4th alpha dropped. I couldn't work before because I didn't have a spare machine to test my changes on. There have been some refactors too.

On your second point, yes this is a big PR. I understand that this is quite some work but I would really appreciate some time for a good review in hopes of merging it into nixpkgs.

@SigmaSquadron
Copy link
Copy Markdown
Contributor

SigmaSquadron commented Dec 29, 2024

By spur of the moment I meant that you worked on this without the COSMIC people. (Notably, Lily, since this is based on her work primarily.)

I'm sure that the COSMIC team had a very good reason to not upstream the flake yet.

@emilazy
Copy link
Copy Markdown
Member

emilazy commented Dec 29, 2024

Neither the files nor the commits contain any attribution to the original authors of this code, which is a copyright issue; you’ll at least need Co-authored-by: trailers on the commits. The central mega‐commit also doesn’t follow our commit message guidelines; it would need to be split up into many more commits.

I would strongly suggest this kind of work proceed incrementally rather than in one huge PR; there’s little chance it will be reviewed and merged in its current state.

cc @lilyinstarlight

@thefossguy
Copy link
Copy Markdown
Member Author

That I admit, this was very much done without Lily. The reason why this isn't merged in nixpkgs by Lily is because she is no longer interacting with nixpkgs after the nix drama. She is maintaining her out-of-tree flake for that reason.

@SigmaSquadron
Copy link
Copy Markdown
Contributor

@thefossguy
Copy link
Copy Markdown
Member Author

@emilazy Noted. I'll talk to Lily about getting her approval on a Co-authored-by in the commits. As for splitting the commits, that's what I wanted to do but thought a single commit with the same description would be a better way forward. I'll split them.

Marking current PR as a draft for now.

@thefossguy thefossguy marked this pull request as draft December 29, 2024 13:29
Copy link
Copy Markdown
Contributor

@SigmaSquadron SigmaSquadron left a comment

Choose a reason for hiding this comment

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

This diff is really hard to read. (Did you reorder attributes for some reason?)

You should really split this in separate PRs to facilitate merging. (Broken stuff won't block working stuff)

Comment on lines +52 to +53
- [COSMIC DE](https://system76.com/cosmic/), the COSMIC desktop environment by Pop!_OS.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feel free to bump this to highlights. A new desktop environment is very notable.


options = {
services.desktopManager.cosmic = {
enable = lib.mkEnableOption "COSMIC desktop environment";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
enable = lib.mkEnableOption "COSMIC desktop environment";
enable = lib.mkEnableOption "the COSMIC desktop environment";

mkEnableOption doesn't add the article.

services.desktopManager.cosmic = {
enable = lib.mkEnableOption "COSMIC desktop environment";

unstable.protocols.enable = lib.mkEnableOption "Enable the [currently unstable] cosmic-protocols" // {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
unstable.protocols.enable = lib.mkEnableOption "Enable the [currently unstable] cosmic-protocols" // {
unstable.protocols.enable = lib.mkEnableOption "Enable the currently unstable `cosmic-protocols`" // {

enable = lib.mkEnableOption "COSMIC desktop environment";

unstable.protocols.enable = lib.mkEnableOption "Enable the [currently unstable] cosmic-protocols" // {
default = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
default = false;

mkEnableOption options are false by default.

default = false;
};

xwayland.enable = lib.mkEnableOption "Xwayland support for cosmic-comp" // {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
xwayland.enable = lib.mkEnableOption "Xwayland support for cosmic-comp" // {
xwayland.enable = lib.mkEnableOption "Xwayland support for `cosmic-comp`" // {

};

environment.cosmic.excludePackages = lib.mkOption {
description = "List of COSMIC packages to exclude from the default environment";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
description = "List of COSMIC packages to exclude from the default environment";
description = "List of COSMIC packages to exclude from the default environment.";

Comment on lines +140 to +162
assertions = [
{
assertion = lib.elem "libcosmic-app-hook" (
lib.map (
drv: lib.optionalString (lib.isDerivation drv) (lib.getName drv)
) pkgs.cosmic-comp.nativeBuildInputs
);
message = ''
It looks like the provided `pkgs` to the NixOS COSMIC module is not usable for a working COSMIC
desktop environment.

If you are erroneously passing in `pkgs` to `specialArgs` somewhere in your system configuration,
this is is often unnecessary and has unintended consequences for all NixOS modules. Please either
remove that in favor of configuring the NixOS `pkgs` instance via `nixpkgs.config` and
`nixpkgs.overlays`.

If you must instantiate your own `pkgs`, then please include the overlay from the NixOS COSMIC flake
when instantiating `pkgs` and be aware that the `nixpkgs.config` and `nixpkgs.overlays` options will
not function for any NixOS modules.

Note that the COSMIC packages in Nixpkgs are still largely broken as of 2024-10-16 and will not be
usable for having a fully functional COSMIC desktop environment. The overlay is therefore necessary.
'';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertions = [
{
assertion = lib.elem "libcosmic-app-hook" (
lib.map (
drv: lib.optionalString (lib.isDerivation drv) (lib.getName drv)
) pkgs.cosmic-comp.nativeBuildInputs
);
message = ''
It looks like the provided `pkgs` to the NixOS COSMIC module is not usable for a working COSMIC
desktop environment.
If you are erroneously passing in `pkgs` to `specialArgs` somewhere in your system configuration,
this is is often unnecessary and has unintended consequences for all NixOS modules. Please either
remove that in favor of configuring the NixOS `pkgs` instance via `nixpkgs.config` and
`nixpkgs.overlays`.
If you must instantiate your own `pkgs`, then please include the overlay from the NixOS COSMIC flake
when instantiating `pkgs` and be aware that the `nixpkgs.config` and `nixpkgs.overlays` options will
not function for any NixOS modules.
Note that the COSMIC packages in Nixpkgs are still largely broken as of 2024-10-16 and will not be
usable for having a fully functional COSMIC desktop environment. The overlay is therefore necessary.
'';

This isn't applicable in Nixpkgs. It's also up to you to fix the bugs that this assertion tries to warn users about.

);
};

meta = with lib; {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
meta = with lib; {
meta = {

For every other package as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should go to by-name.

owner = "pop-os";
repo = "cosmic-icons";
rev = "epoch-1.0.0-alpha.3";
rev = "refs/tags/epoch-1.0.0-alpha.4";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
rev = "refs/tags/epoch-1.0.0-alpha.4";
tag = "epoch-1.0.0-alpha.4";

Ditto for every other package.

@SigmaSquadron SigmaSquadron added 9.needs: clean-up Somebody please clean up this mess! 9.needs: community feedback This needs feedback from more community members. and removed 9.needs: community feedback This needs feedback from more community members. labels Dec 29, 2024
Copy link
Copy Markdown
Member

@lilyinstarlight lilyinstarlight left a comment

Choose a reason for hiding this comment

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

This needs to follow terms of MIT license if you're going to be copy-pasting this code

It would help to have much more assurance of anyone here's intent and ability to maintain the copy-pasted code and work with COSMIC upstream on stuff, because as far as I know mostly me and @alyssais and @ahoneybun (who works for sys76) have bothered with that

xdg-user-dirs
]
++ lib.optionals cfg.unstable.protocols.enable [
cosmic-protocols
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does not do anything useful as far as I know...?


xdg.portal = {
enable = true;
extraPortals = lib.mkBefore [ pkgs.xdg-desktop-portal-cosmic ];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the mkBefore fixing here?

xdg.portal = {
enable = true;
extraPortals = lib.mkBefore [ pkgs.xdg-desktop-portal-cosmic ];
configPackages = lib.mkDefault ([ pkgs.xdg-desktop-portal-cosmic ]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is mkDefault solving here? It should be matching the prio level of other DEs

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Dec 29, 2024
@ofborg ofborg bot requested a review from nyabinary December 29, 2024 18:49
@ofborg ofborg bot added the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label Dec 29, 2024
@ahoneybun
Copy link
Copy Markdown
Contributor

This needs to follow terms of MIT license if you're going to be copy-pasting this code

It would help to have much more assurance of anyone here's intent and ability to maintain the copy-pasted code and work with COSMIC upstream on stuff, because as far as I know mostly me and @alyssais and @ahoneybun (who works for sys76) have bothered with that.

Thank you for helping with this review!

Copy link
Copy Markdown
Member

@Pandapip1 Pandapip1 Dec 29, 2024

Choose a reason for hiding this comment

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

Please revert the changes to this file, except for the maintainer list update if you want to be added. The current derivation functions as expected and has some improvements over the one in the flake. If you'd like to make specific changes, we can discuss them, but don't blindly paste the code from lily's flake, especially since she explicitly asked for me to rewrite it myself.

@nyabinary
Copy link
Copy Markdown
Contributor

Supersedes #339287 #292601

@a-kenji a-kenji removed their request for review December 31, 2024 00:43
@nyabinary nyabinary mentioned this pull request Jan 1, 2025
13 tasks
@nyabinary
Copy link
Copy Markdown
Contributor

@thefossguy Are you still working on this?

@thefossguy
Copy link
Copy Markdown
Member Author

@nyabinary Given that the cosmic greeter from nixpkgs doesn't work, I intend to. I'm not sure if I should rebase this branch with requested changes or individual PRs for each commit.

@Pandapip1
Copy link
Copy Markdown
Member

Pandapip1 commented Feb 8, 2025

Individual PRs for each package is probably the best way to go. This will also encourage making your own changes as you go (e.g. changing ref to tag, using the new cargo fetcher, etc...) and will help avoid you making incorrect changes like removing my patch.

@thefossguy thefossguy mentioned this pull request Feb 8, 2025
13 tasks
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 15, 2025
@wrenix
Copy link
Copy Markdown
Contributor

wrenix commented Mar 17, 2025

What is left over (after merge of e.g. #380312 ) of this MR? Could you rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 9.needs: clean-up Somebody please clean up this mess! 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants