Skip to content

bug: programs.bash (genericLinux): reorders PATH/XDG_DATA_DIRS and introduces duplicates; this breaks some Flatpak behavior #8076

@Labaman

Description

@Labaman

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

  • Enabling programs.bash on non-NixOS (genericLinux) causes incorrect reordering and duplication of PATH and XDG_DATA_DIRS.
  • The module moves Nix paths ahead of system/Flatpak paths, which breaks certain Flatpak handlers/desktop entries.
  • Even when the user explicitly defines these variables (via let … in and home.sessionVariables/home.sessionPath), the reordering and duplicates still appear after enabling programs.bash.

envs.before_bash_enable.txt
envs.with_bash_enable.txt

Minimal repro
home.nix:

{ config, pkgs, lib, ... }:
{
  home.username = "deck";
  home.homeDirectory = "/home/deck";
  home.stateVersion = "25.05";

  targets.genericLinux.enable = true;
  xdg.enable = true;

  programs.bash.enable = true;   

  programs.home-manager.enable = true;
}

Steps:

  1. home-manager switch --flake .#deck -b hm-bak
  2. exec bash -l
  3. Inspect:
echo $XDG_DATA_DIRS
echo $PATH

Actual

  • XDG_DATA_DIRS: Nix paths end up before system/Flatpak, and duplicates appear.
  • PATH: multiple instances of ~/.nix-profile/bin and duplicated system paths — despite explicit user ordering.
  • Result: some Flatpaks fail to resolve system handlers/desktop entries correctly.

Expected
Enabling programs.bash should not reorder PATH/XDG_DATA_DIRS (expected order: Flatpak → system → Nix) and should not introduce duplicates, especially when the user has explicitly set these variables.

Maintainer CC

@rycee

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.11.11-valve24-2-neptune-611-gfd0dd251480d, SteamOS, noversion, 20250903.1`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Determinate Nix 3.11.3) 2.31.2`
 - nixpkgs: `not found`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageIssues or feature request that have not been triaged yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions