Skip to content

Add environment PATH in home-manager module.#1389

Closed
luis-agm wants to merge 3 commits intoAvengeMedia:masterfrom
luis-agm:feat/nix-env-for-systemd-hm
Closed

Add environment PATH in home-manager module.#1389
luis-agm wants to merge 3 commits intoAvengeMedia:masterfrom
luis-agm:feat/nix-env-for-systemd-hm

Conversation

@luis-agm
Copy link
Contributor

Motivation

In the case when a user overrides the quickshell package, the service fails to start since it can't find the qs executable.

Proposed changes

Add the quickshell package to the Environment configuration for the service.

I've tested this by overriding the property in my home-manager configuration and it restored the desired behavior of the shell activating after login.

ExecStart = lib.getExe dmsPkgs.dms-shell + " run --session";
Restart = "on-failure";
Environment = [
"PATH=${lib.makeBinPath [ dmsPkgs.dms-shell cfg.quickshell.package ]}:$PATH"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that if we're adding this here, common.packages could be used instead for adding all deps. Also, have you checked if this $PATH substitution really works here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I've added the quickshell package to the common.packages. Also I tested the end result and the $PATH indeed didn't work, so I've removed it.

Copy link
Collaborator

@LuckShiba LuckShiba Jan 17, 2026

Choose a reason for hiding this comment

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

If we can't have the "normal" PATH then, this is a problem. Some cases are:

  • DMS checks for application binaries for generating themes (e.g. check if the vesktop command is present for generating a vesktop theme);
  • Plugins may also want to use a binary not defined in the service's PATH, such as the terminal desktop widget plugin that needs python in order to work.

Of course, being NixOS, the user could add themselves these binaries to the service's PATH, but this is less practical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, I haven't found a way to expand the PATH into the service's environment. But doing this directly in the dms flake and loading it locally seems to work (up to a point, some errors with theme generation).

        Environment = [
          "PATH=${lib.makeBinPath common.packages}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
        ];

The errors I see are:

Jan 18 12:20:46 fedora dms[133871]: error: unexpected argument '--import-json-string' found
Jan 18 12:20:46 fedora dms[133871]:   tip: to pass '--import-json-string' as a value, use '-- --import-json-string'
Jan 18 12:20:46 fedora dms[133871]: Usage: matugen color hex --mode <MODE> --type <TYPE> --config <FILE> <STRING>
Jan 18 12:20:46 fedora dms[133871]: For more information, try '--help'.
Jan 18 12:20:46 fedora dms[133565]:  ERROR  go: DMS API Error: id=1 error=exit status 2
Jan 18 12:20:46 fedora dms[133578]:   WARN qml: Theme worker:  FATAL  go: Theme generation failed: server error: exit status 2
Jan 18 12:20:46 fedora dms[133578]:   WARN qml: Theme: Matugen worker failed with exit code: 1
Jan 18 12:20:46 fedora dms[133578]:   INFO qml: HyprlandService: Generated layout config at /home/<user>/.config/hypr/dms/layout.conf
Jan 18 12:20:46 fedora dms[133578]:   INFO qml: CompositorService: Detected Hyprland
Jan 18 12:20:46 fedora dms[133578]:   INFO qml: HyprlandService: Generated layout config at /home/<user>/.config/hypr/dms/layout.conf
Jan 18 12:20:46 fedora dms[133578]:   INFO qml: SessionService: Native inhibitor available: true

These look solvable. However, you were right, several processes that failed before in the logs don't fail with this approach, meaning the process has access to stuff it needs. Open to suggestions on how to make this work.
Also keep in mind this is a home-manager module, not a NixOs module, so the service is created as a user service. Maybe that sheds some light on alternatives.

The errors that appeared previously (some of them) point to the process not being able to find some very basic essential tools.

Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("sh", "-c", "command -v dsearch")
Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("which", "wtype")
Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("cat", "/etc/os-release")
Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("which", "dgop")
Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("which", "matugen")
Jan 18 11:55:08 fedora dms[97078]:   WARN: Process failed to start, likely because the binary could not be found. Command: QList("sh", "-c", "gsettings get org.gnome.desktop.sound theme-name 2>/dev/null")

Copy link
Collaborator

@LuckShiba LuckShiba Jan 18, 2026

Choose a reason for hiding this comment

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

Maybe you can instead of setting in Environment= setting them in a prefix in the run command? For example sh -c "PATH=${dmsPath}:$PATH dms run" (or even using coreutils' env)

Please try it out.

Copy link
Contributor Author

@luis-agm luis-agm Jan 18, 2026

Choose a reason for hiding this comment

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

using sh -c ... works but swallows all the logs. Setting the env like this works fine:

Environment = [
      "PATH=${lib.makeBinPath common.packages}:/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/bin"
];

And it shows all the logs from the service.

Copy link
Collaborator

@LuckShiba LuckShiba Jan 18, 2026

Choose a reason for hiding this comment

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

It may work but is not complete... We can't really guess what the final user's path will be. I'll see if I can find an alternative

@luis-agm luis-agm requested a review from LuckShiba January 17, 2026 10:24
@Purian23
Copy link
Collaborator

Purian23 commented Mar 1, 2026

Feel free to re-open in the future. Closing out.

@Purian23 Purian23 closed this Mar 1, 2026
@LuckShiba LuckShiba mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants