Gnome does not source .profile

I have some session variables set with home.sessionsVariables = { ... }; (with home manager).

They are supposed to be exported in ~/.nix-profile/etc/profile.d/, which is in turn sourced by .profile, which is supposed to be sourced upon login, and then the environment should be inherited by every terminal. However, when I run echo $EDITOR in a terminal, I don’t see the value I have put but a default one.

This is very strange, as I have two computers that have the exact same nix configuration, but this problem occurs only on one of them…

let me guess: one of your mostly-identical computers is running a Wayland Gnome session, and the other is running an XOrg one?

there is a bit of code in gnome-session that takes care of sourcing .profile, but only under Wayland. I think the underlying assumption there is that some other script takes care of that under XOrg, but for whatever reason this does not hold for NixOS.

I guess just make sure you use Wayland everywhere, if that works for you?

Bingo, this is a difference between my computers! However, using wayland is not an option as the computer that runs XOrg does run wayland for driver-compatibility reasons (aah, Nvidia…).

Any hints on how to patch that?

this is what I carry in my configuration:

  • the overlay (add to your nixpkgs.overlays or however you organize things):
    (self: super: {
      gnome = super.gnome // {
        gnome-session = super.gnome.gnome-session.overrideAttrs (old: {
          patches = old.patches ++ [ ./gnome-session-type.patch ];
  • and this is gnome-session-type.patch:
diff -rU0 gnome-session-3.36.0/gnome-session/ gnome-session-3.36.0.patched/gnome-session/
--- gnome-session-3.36.0/gnome-session/	2020-03-08 22:04:15.000000000 +0200
+++ gnome-session-3.36.0.patched/gnome-session/	2021-04-20 00:53:05.750600504 +0300
@@ -3 +3 @@
-if [ "x$XDG_SESSION_TYPE" = "xwayland" ] &&
+if ([ "x$XDG_SESSION_TYPE" = "xwayland" ] || [ "x$XDG_SESSION_TYPE" = "xx11" ]) &&

Should really open a bug about this, but not sure how deep the rabbit hole leads and what’s the actual root cause…

1 Like