Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / misc / ulauncher / 0001-Adjust-get_data_path-for-NixOS.patch
blobf14d7f7180271d7f0856141556d67ef5665806d1
1 From 86cc27022015697a61d1ec1b13e52f9dbe7f6c57 Mon Sep 17 00:00:00 2001
2 From: worldofpeace <worldofpeace@protonmail.ch>
3 Date: Mon, 23 Mar 2020 18:34:00 -0400
4 Subject: [PATCH] Adjust get_data_path for NixOS
6 We construct the ulauncher data path from xdg_data_dirs
7 and prevent it from being a nix store path or being xdg_data_home.
8 We do this to prevent /nix/store paths being hardcoded to shortcuts.json.
9 On NixOS this path will either be /run/current-system/sw/share/ulauncher
10 or $HOME/.nix-profile/share/ulauncher if the user used nix-env.
11 ---
12 ulauncher/config.py | 27 ++++++++++++++++++---------
13 1 file changed, 18 insertions(+), 9 deletions(-)
15 diff --git a/ulauncher/config.py b/ulauncher/config.py
16 index f21014e..cc636e1 100644
17 --- a/ulauncher/config.py
18 +++ b/ulauncher/config.py
19 @@ -50,15 +50,24 @@ def get_data_path():
20 is specified at installation time.
21 """
23 - # Get pathname absolute or relative.
24 - path = os.path.join(
25 - os.path.dirname(__file__), __ulauncher_data_directory__)
27 - abs_data_path = os.path.abspath(path)
28 - if not os.path.exists(abs_data_path):
29 - raise ProjectPathNotFoundError(abs_data_path)
31 - return abs_data_path
32 + paths = list(
33 + filter(
34 + os.path.exists,
35 + [
36 + os.path.join(dir, "ulauncher")
37 + for dir in xdg_data_dirs
38 + # Get path that isn't in the /nix/store so they don't get hardcoded into configs
39 + if not dir.startswith("/nix/store/")
40 + # Exclude .local/share/ulauncher which isn't what we want
41 + if not dir.startswith(xdg_data_home)
42 + ],
43 + )
44 + )
46 + try:
47 + return paths[0]
48 + except:
49 + raise ProjectPathNotFoundError()
52 def is_wayland():
53 --
54 2.25.1