Skip to content

mise-nix breaks XDG_DATA_DIRS if a nix package has /share path #51

Description

@pasha-kuznetsov

Steps to reproduce

mise use -g nix:most
mise activate fish | source

Observed behavior

XDG_DATA_DIRS only includes the nix-most /share dir:

> echo $XDG_DATA_DIRS
~/.local/share/mise/installs/nix-most/5.2.0/share

Expected behavior

XDG_DATA_DIRS to include both the prior dirs, and the nix-most /share dir, something along these lines:

> echo $XDG_DATA_DIRS
~/.local/share/flatpak/exports/share ~/exports/share /usr/local/share /usr/share ~/.nix-profile/share /nix/var/nix/profiles/default/share ~/.local/share/mise/installs/nix-most/5.2.0/share

Why

This is critical for most applications to continue working.

What's broken

mise hook-env -s fish contains the following lines:

set -gx PATH ...
set -gx XDG_DATA_DIRS ~/.local/share/mise/installs/nix-most/5.2.0/share
set -gx HOST_PATH '/nix/store...

And the culprit appears to be this code:

table.insert(env_vars, { key = "XDG_DATA_DIRS", value = share_path })

  -- XDG_DATA_DIRS
  local share_path = real_path .. "/share"
  local has_share = cmd.exec("test -d '" .. share_path .. "' && echo yes || echo no"):match("yes")
  if has_share then
    table.insert(env_vars, { key = "XDG_DATA_DIRS", value = share_path })
  end

  return env_vars

Which is eventually returned from PLUGIN:BackendExecEnv, resulting in mise resetting XDG_DATA_DIRS.

Fix

mise-nix should collect the pre-existing XDG_DATA_DIRS value, and append the package /share path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions