New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sway: deterministic .desktop file #89179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff LGTM.
This is a bit of an interesting case as this should only work with a login/display manager since they use only the desktop entries from the NixOS configuration. Luckily this is, apart from very special edge-cases, the only situation we care about.
(For normal desktop entries this shouldn't make a difference in this use-case since the user is already logged in the desktop file from ~/.nix-profile/share/applications/
should take precedence over the one in /run/current-system/sw/share/applications/
.)
However, the big issue I see here is that, in theory, this should fix your use case but "break" the home-manager
module. This is because the home-manager
module also implements the options from the NixOS module link (including e.g. extraSessionCommands
). And then we should use Sway from the user's path (home-manager
) instead of the NixOS module. But please note that I didn't actually test my theory, so I might have missed something.
I think we should resolve this issue together with the home-manager
maintainers. I believe the correct solution would be to enable Sway system-wide (programs.sway.enable
- see #89019 (comment)) and configure the rest though the home-manager
module. If the home-manager
maintainers agree with this we should document it in the enable
option of the home-manager
module.
cc @alexarice, @cole-h, @nurelin (module) @rycee (home-manager): What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(forgot to switch to request changes - at least until we resolve the discussion)
Tbh I'm not sure I've fully grasped what the problem is here, but I'm am using |
Any systemd parts of the home manager config are the bits I was least sure of. If you have any suggestions that would improve it (especially with respect to login managers), then I would be happy with it, if home manager maintainers are happy with it |
@alexarice the relevant part for
|
To me, there are 2 ways to install sway with home-manager:
services.xserver.desktopManager.session = [
{
name = "home-manager";
start = ''
${pkgs.runtimeShell} $HOME/.hm-session &
waitPID=$!
'';
}
]; and this in your home-manager config: xsession.enable = true;
xsession.scriptPath = ".hm-session";
xsession.windowManager.command = mySwayPackage; 2 notes: @alexarice To my understanding, systemd is not involve in this, I don't have any suggestions to improve the systemd part, it looks good to me :) programs.sway = {
enable = true;
extraSessionCommands =
''
export MYVAR=nixos
'';
}; and this on your home-manager config: wayland.windowmanager.sway = {
enable = true;
extraSessionCommands =
''
export MYVAR=home-manager
'';
}; after login, |
I think the difficulty is that |
Right, I didn't considered that case |
This might be similar to what has already been suggested, but I think the necessary changes for home-manager are:
Would this fix all the issues? |
@alexarice I think so, that 2 changes should solve it. But I think it still makes sense to merge this PR |
I'll make a PR on home-manager then, I think this pr is probably a good idea too |
Even with nix-community/home-manager#1298 one (theoretical) issue remains: When Sway is launched via a login/display manager the following options from the If that's ok for the maintainers of the |
Ah I see the issue now, though I don't see a way round it other than putting a big warning somewhere that this overwrite exists. The home-manager module will say that setting |
The home-manager change went through, was there any decision on what to do with this? |
@alexarice no, not really. AFAIK @jlesquembre is still in favor of this PR while I'm more against it due to the problem explained in #89179 (comment) and also the resulting inconsistent behaviour between a login via a display manager or tty. I also looked at the desktop entries on my system and most files don't use absolute paths. I don't have a strong opinion on this though and I don't use a display manager anyway. @jlesquembre if you still want this PR to get merged it would be good if you could ping a few other maintainers familiar with desktop entries and display manager (you can e.g. check the Git history). I think |
I think I'm going to close this PR since now it is possible to set the sway package in home-manager to null. |
I don't know much about Sway but it seems to me that if a user chooses to set up Sway in Home Manager then they don't really want a This is sort of how the HM Edit: It might be worth mentioning that to do this property one would need to use the system |
I guess this is a matter of definition. I'd e.g. still consider this perfectly deterministic. A reference without the absolute path is just more like a global and mutable variable in a programming language while a reference with an absolute path is of course immutable as the referenced content in the Nix store is immutable (and depending on what we'd like to achieve both behaviours can make sense).
HM can generate a |
That should be possible with the I'm closing this PR. IMO the new option added to home-manager by @alexarice is good enough and solves the problem I had. Feel free to reopen if you think otherwise. Thanks @primeos , @alexarice and @rycee for all your comments, it was a really interesting conversation |
Motivation for this change
If I use the sway.desktop from this derivation, I'd expect to use the sway binary generated by the derivation, not the one in my path.
I was bitten by this because I'm installing sway with the NixOS option
programs.sway.enable
andprograms.sway.extraSessionCommands
, but to manage the sway config file (on~/.config/sway/config
), I usehome-manager
. Sincehome-manager
is also installing sway in your nix profile, this version has preference, and the commands I specified on theprograms.sway.extraSessionCommands
were ignoredThings done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)