Skip to content

Instantly share code, notes, and snippets.

@BohdanTkachenko
Created October 7, 2025 02:15
Show Gist options
  • Select an option

  • Save BohdanTkachenko/6ba2730ff54ecbb2d7aed22dec3507d5 to your computer and use it in GitHub Desktop.

Select an option

Save BohdanTkachenko/6ba2730ff54ecbb2d7aed22dec3507d5 to your computer and use it in GitHub Desktop.
Nix Home Manager systemd user environment generator for session variables
{ config, pkgs, ... }:
let
nixPkg = if config.nix.package == null then pkgs.nix else config.nix.package;
profileDirectory = config.home.profileDirectory;
in
{
# TODO: remove when/if https://github.com/nix-community/home-manager/pull/7949 is merged.
xdg.configFile."systemd/user-environment-generators/05-home-manager.sh" = {
text = ''
. "${nixPkg}/etc/profile.d/nix.sh"
. "${profileDirectory}/etc/profile.d/hm-session-vars.sh"
'';
executable = true;
force = true;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment