nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.97k stars 1.8k forks source link

bug: Home manager not correctly setting session variables. #5177

Closed ErinaInit closed 6 months ago

ErinaInit commented 7 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I have enabled the fcitx5 package with the config written in the wiki, setting i18n.inputMethod.enabled="fcitx5", and adding a couple of addons.

However, the session variables are not correctly set, which rendered the package not usable.

Even adding the settings in home.sessionVariables as indicated by the Arch wiki didn't work as planned.

Running env | grep IM showed nothing.

Interestingly enough, when I mistyped GLFW_IM_MODULE to "fcitx", it erred me for clashing config with the fcitx file.

How to solve this?

Maintainer CC

No response

System information

copying path '/nix/store/88hr9j7a1r9qrvv7xnfyjmd1ww459krl-nix-info' from 'https://mirrors.ustc.edu.cn/nix-channels/store'...
copying path '/nix/store/c8dj731bkcdzhgrpawhc8qvdgls4xfjv-stdenv-linux' from 'https://mirrors.ustc.edu.cn/nix-channels/store'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.82, NixOS, 23.11 (Tapir), 23.11.5511.f091af045dff`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"home-manager, nixos-23.11"`
 - nixpkgs: `/home/erina/.nix-defexpr/channels/nixpkgs`
teto commented 7 months ago

Even adding the settings in home.sessionVariables as indicated by the Arch wiki didn't work as planned.

you need to logout/relogin to see those or source ~/.profile. I have fcitx5 working (I think) and I mostly see export QT_IM_MODULE="fcitx" there

ErinaInit commented 6 months ago

Even adding the settings in home.sessionVariables as indicated by the Arch wiki didn't work as planned.

you need to logout/relogin to see those or source ~/.profile. I have fcitx5 working (I think) and I mostly see export QT_IM_MODULE="fcitx" there

That's weird...... I don't have a .profile under my home directory......

I also wrote the EDITOR="emacs", but it was still nano......

Something must have been wrong......

spikespaz commented 6 months ago

I have tried all of the following:

  # qt.enable = true;
  # qt.platformTheme = "qtct";
  # qt.style.name = "kvantum";
  home.packages = [ pkgs.kdePackages.qt6ct ];

  # The HM module seems to be broken when it sets this.
  # Variables are `at5ct` for backwards-compatibility.
  home.sessionVariables.QT_STYLE_OVERRIDE = lib.mkForce "kvantum";
  systemd.user.sessionVariables.QT_STYLE_OVERRIDE = lib.mkForce "kvantum";
  home.sessionVariables.QT_QPA_PLATFORMTHEME = lib.mkForce "qt5ct";
  systemd.user.sessionVariables.QT_QPA_PLATFORMTHEME = lib.mkForce "qt5ct";

Even messing about with Hyprland's config.

It would seem that my environment can't open KDE programs which read this variable; when I launch qt6ct, it claims:

The QT_QPA_PLATFORMTHEME environment variable is not set (required values: qt6ct or qt5ct).

When launching programs from the terminal, the correct theme is applied.

ErinaInit commented 6 months ago

I have tried all of the following:

  # qt.enable = true;
  # qt.platformTheme = "qtct";
  # qt.style.name = "kvantum";
  home.packages = [ pkgs.kdePackages.qt6ct ];

  # The HM module seems to be broken when it sets this.
  # Variables are `at5ct` for backwards-compatibility.
  home.sessionVariables.QT_STYLE_OVERRIDE = lib.mkForce "kvantum";
  systemd.user.sessionVariables.QT_STYLE_OVERRIDE = lib.mkForce "kvantum";
  home.sessionVariables.QT_QPA_PLATFORMTHEME = lib.mkForce "qt5ct";
  systemd.user.sessionVariables.QT_QPA_PLATFORMTHEME = lib.mkForce "qt5ct";

Even messing about with Hyprland's config.

It would seem that my environment can't open KDE programs which read this variable; when I launch qt6ct, it claims:

The QT_QPA_PLATFORMTHEME environment variable is not set (required values: qt6ct or qt5ct).

When launching programs from the terminal, the correct theme is applied.

I'm curious if you have a ~/.profile? From my guess you may have one, but hyprland didn't source it.

ErinaInit commented 6 months ago

I see what's happening.

I manager my X session with the system configuration.nix, which didn't respect the variables generated by home-manager automatically.

spikespaz commented 6 months ago

I see what's happening.

I manager my X session with the system configuration.nix, which didn't respect the variables generated by home-manager automatically.

Is it because the greeter needs these variables?

spikespaz commented 6 months ago

I think this issue should be re-opened because it still affects those who do not use NixOS to manage their desktop sessions. I believe that HM setting Qt's theming options should work when the desktop session is in no part defined by the NixOS config.

ErinaInit commented 6 months ago

Maybe I should have stated I sourced the file manually in my ~/.profile, which can be applied to systems other than NixOS.

spikespaz commented 6 months ago

@ErinaInit I don't understand all this talk about .profile, NixOS + HM doesn't have a .profile so far as I have seen.

ErinaInit commented 6 months ago

@ErinaInit I don't understand all this talk about .profile, NixOS + HM doesn't have a .profile so far as I have seen.

You are right. I saw that home-manager added something to my .zshrc and thought that it is managing my shell environment, but in fact it is not. I'll have to source it in my ~/.profile

spikespaz commented 6 months ago

@ErinaInit You shouldn't be sourcing .zshrc from .profile...

ErinaInit commented 6 months ago

@ErinaInit You shouldn't be sourcing .zshrc from .profile...

You missed what I want to express...... Let me be really clear by splitting what I want to express into points.

  1. home-manager IS managing my .zshrc
  2. home-manager DIDN'T set the variables in my .zshrc, but in ~/.nix-profile/etc/../hm-session-vars.sh, and DIDN't source it in ~/.zshrc
  3. I sourced hm-session-vars.sh in ~/.profile and ~/.zprofile

Actually this is kind of weird, as home-manager is taking care of my shell configuration but didn't source the files as I would expect. As the installation manual says:

If you do not plan on having Home Manager manage your shell configuration then you must source the

$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh

file in your shell configuration. Alternatively source

/etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh

when managing home configuration together with system configuration.

I expected home-manager to do the job for me since I do manage my shell configuration with it.

Maybe we'll have to change the directions on the site?

spikespaz commented 5 months ago

@ErinaInit

I sourced hm-session-vars.sh in ~/.profile and ~/.zprofile

Where does your .profile come from? Did you create it? Did NixOS create it? Did Home Manager create it?