summary refs log tree commit diff
path: root/pkgs/applications/misc/ulauncher/0001-Adjust-get_data_path-for-NixOS.patch
blob: f14d7f7180271d7f0856141556d67ef5665806d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 86cc27022015697a61d1ec1b13e52f9dbe7f6c57 Mon Sep 17 00:00:00 2001
From: worldofpeace <worldofpeace@protonmail.ch>
Date: Mon, 23 Mar 2020 18:34:00 -0400
Subject: [PATCH] Adjust get_data_path for NixOS

We construct the ulauncher data path from xdg_data_dirs
and prevent it from being a nix store path or being xdg_data_home.
We do this to prevent /nix/store paths being hardcoded to shortcuts.json.
On NixOS this path will either be /run/current-system/sw/share/ulauncher
or $HOME/.nix-profile/share/ulauncher if the user used nix-env.
---
 ulauncher/config.py | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/ulauncher/config.py b/ulauncher/config.py
index f21014e..cc636e1 100644
--- a/ulauncher/config.py
+++ b/ulauncher/config.py
@@ -50,15 +50,24 @@ def get_data_path():
     is specified at installation time.
     """
 
-    # Get pathname absolute or relative.
-    path = os.path.join(
-        os.path.dirname(__file__), __ulauncher_data_directory__)
-
-    abs_data_path = os.path.abspath(path)
-    if not os.path.exists(abs_data_path):
-        raise ProjectPathNotFoundError(abs_data_path)
-
-    return abs_data_path
+    paths = list(
+        filter(
+            os.path.exists,
+            [
+                os.path.join(dir, "ulauncher")
+                for dir in xdg_data_dirs
+                # Get path that isn't in the /nix/store so they don't get hardcoded into configs
+                if not dir.startswith("/nix/store/")
+                # Exclude .local/share/ulauncher which isn't what we want
+                if not dir.startswith(xdg_data_home)
+            ],
+        )
+    )
+
+    try:
+        return paths[0]
+    except:
+        raise ProjectPathNotFoundError()
 
 
 def is_wayland():
-- 
2.25.1