Closed Mikilio closed 1 month ago
Are you running home-manager?
To my knowledge, something similar is already handled for those running HM: https://github.com/hyprwm/Hyprland/blob/main/nix/hm-module.nix#L138
I think I remember seeing that. However it still still is not enough.
Important variables for xdg are missing like XDG_DATA_DIRS and PATH. If
there isn't any security issue I would just shorten the line by using the
flag --all
.
On Tue, Jul 25, 2023, 08:22 Patrick Shaw @.***> wrote:
Are you running home-manager?
To my knowledge, something similar is already handled for those running HM: https://github.com/hyprwm/Hyprland/blob/main/nix/hm-module.nix#L138
— Reply to this email directly, view it on GitHub https://github.com/hyprwm/Hyprland/issues/2800#issuecomment-1649195432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUQFFF4Y53X72GHIW3B3DFDXR5Q4DANCNFSM6AAAAAA2V5XKLI . You are receiving this because you authored the thread.Message ID: @.***>
Are you sure we want to import all environment variables when starting the session? I don't have info on this so I just kept the var list small so as not to potentially conflict with other things.
I wasn't too concerned about any side effects because greetd is started by a greetd user anyways. I agree, in general it might be better to import only the ones you need. However right now some seems to be missing. I actually based my config off of yours (@fufexan) and I still encountered the 25sec issue when regreet starts.
Are you sure we want to import all environment variables when starting the session? I don't have info on this so I just kept the var list small so as not to potentially conflict with other things.
I have been deliberating this with myself as well. I think maybe it would be the most painless way to go. Many programs started from systemd expect these variables to be present.
If we do import all environment variables, programs started from waybar click handlers would actually use my QT_QPA_PLATFORMTHEME
. Right now they don't, and I haven't found an easy way to handle this without carefully wrapping each individual program (or having waybar be wrapped and pass along the environment).
Considering that most distros would have every variable imported, it wouldn't be unreasonable to do. However, I know that this isn't "the NixOS way".
I really don't know of reasons to not have every environment variable imported. It would certainly increase compatibility, in ways that most programs expect. Let me check what Sway does.
This seems to be it. I don't use Sway, so I don't know if anything else works as I expect or if it has the same problems I do on HL. https://github.com/nix-community/home-manager/blob/master/modules/services/window-managers/i3-sway/sway.nix#L311
DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL
Worth looking at KDE also.
This seems to be it. I don't use Sway, so I don't know if anything else works as I expect or if it has the same problems I do on HL. https://github.com/nix-community/home-manager/blob/master/modules/services/window-managers/i3-sway/sway.nix#L311
DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL Unfortunately the above link again is intended for a sway session started by systemd with a proper user. The sway session I launch is before any login and just to run regreet for greetd. While I don't know why, in this particular use-case those variables are not enough (it's actually one of the first things I tried).
I am sorry for the confusion in my last two comments for some reason I was thinking about this issue rharish101/ReGreet#34 which had a very similar workaround, as again environment variables where missing.
Another option is to allow us to specify a list of variables to import.
(I'm a total newbie at Nix so bear with me here.)
systemdIntegration.enable = lib.mkEnableOption "Hyprland wayland compositor";
systemdIntegration.variables = lib.mkOption {
type = with lib.types; listOf (string);
default = [ "DISPLAY" "HYPRLAND_INSTANCE_SIGNATURE" "WAYLAND_DISPLAY" "XDG_CURRENT_DESKTOP" ];
};
systemdIntegration.extraVariables = lib.mkOption {
type = with lib.types; listOf (string);
default = [ ];
};
xdg.configFile."hypr/hyprland.conf" = let
# ...
systemdVars = cfg.systemdIntegration.variables ++ cfg.systemdIntegration.extraVariables;
updateEnvironment = "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${lib.concatStrings systemdVars " "}";
in lib.mkIf shouldGenerate {
text = lib.optionalString cfg.systemdIntegration.enable ''
exec-once = ${updateEnvironment} && systemctl --user start hyprland-session.target
'' + lib.optionalString (combinedSettings != { })
(toHyprconf combinedSettings 0)
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
# ...
};
Then users can configure it like this:
wayland.windowManager.hyprland = {
enable = true;
systemdIntegration = {
enable = true;
extraVars = [ "PATH" "QT_QPA_PLATFORMTHEME" ];
};
};
Another option is to allow us to specify a list of variables to import. ...
This is totally viable and definitely something that we should do. However, this can already be accomplished by another config.exec_start
, if you need it now.
I think the goal of this issue is to get the defaults correct, not to offload that responsibility to the user (which is what we would effectively do if we allowed extraVars
without getting the defaults correct).
Since then options seem to have been created and I can't reproduce the issues anymore, so closing for now.
Description
Issue
Frankly speaking, using the nixos modules without modification is a XDG-"nightmare".
This is because almost all XDG/GIO calls happen through portals. The problem being that the portals are being started as a user session service by systemd. This means that important environment variables like PATH and XDG_DATA_DIRS are not accessible. Then again there are many applications that ignore default mime applications completely and look at Well-known Message Bus Instances instead.
To bring order into this situation I personally did 2 things:
.../share/dbus-1/
) . To select a default I will symlink the corrects one the most dominant name (usually something like org.freedesktop.BasicFoo1).Proposal
I would like to:
Related Issues
NixOS/nixpkgs