Skip to content

Commit 17df94c

Browse files
authored
nix: remove XDG_DATA_DIR env reference (#673)
using symlinkJoin instead
1 parent cbe373f commit 17df94c

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

cmd/types.go

+7-13
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ func init() {
5959
f.MarkHidden("tsconfig")
6060
}
6161

62-
func girDirectories() []string {
63-
dataDirs := append([]string{
64-
"/usr/local/share",
65-
"/usr/share",
66-
"/usr/share/*",
67-
}, strings.Split(os.Getenv("NIX_GI_DIRS"), ":")...)
68-
69-
return lib.Map(dataDirs, func(dir string) string {
70-
return filepath.Join(dir, "gir-1.0")
71-
})
72-
}
73-
7462
func spinner(stopChan chan bool) {
7563
chars := []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}
7664

@@ -110,7 +98,13 @@ func genTypes(configDir, pattern string, verbose bool) {
11098
"--outdir", filepath.Join(configDir, "@girs"),
11199
}
112100

113-
for _, path := range girDirectories() {
101+
dataDirs := append([]string{
102+
"/usr/local/share/gir-1.0",
103+
"/usr/share/gir-1.0",
104+
"/usr/share/*/gir-1.0",
105+
}, strings.Split(os.Getenv("EXTRA_GIR_DIRS"), ":")...)
106+
107+
for _, path := range dataDirs {
114108
flags = append(flags, "-g", path)
115109
}
116110

nix/default.nix

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2+
symlinkJoin,
23
astal3,
34
astal4,
45
gtk4-layer-shell,
56
astal-io,
67
astal-gjs,
78
lib,
8-
writers,
99
buildGoModule,
1010
wrapGAppsHook,
1111
gobject-introspection,
@@ -18,27 +18,42 @@
1818
extraPackages ? [],
1919
}: let
2020
inherit (builtins) replaceStrings readFile;
21+
version = replaceStrings ["\n"] [""] (readFile ../version);
22+
pname = "ags";
2123

22-
datadirs = writers.writeNu "datadirs" ''
23-
$env.XDG_DATA_DIRS
24-
| split row ":"
25-
| filter { $"($in)/gir-1.0" | path exists }
26-
| str join ":"
27-
'';
24+
buildInputs =
25+
extraPackages
26+
++ [
27+
glib
28+
astal-io
29+
astal3
30+
astal4
31+
gobject-introspection # needed for type generation
32+
];
2833

2934
bins = [
3035
gjs
3136
nodejs
3237
dart-sass
3338
blueprint-compiler
34-
astal-io # FIXME: should not be needed after the astal commends are properly implemented using dbus in astal.go
39+
astal-io # FIXME: should not be needed after the astal commands are properly implemented using dbus in astal.go
3540
];
3641

37-
version = replaceStrings ["\n"] [""] (readFile ../version);
38-
pname = "ags";
42+
girDirs = let
43+
# gir files are usually in `dev` output.
44+
# `propagatedBuildInputs` are also available in the gjs runtime
45+
# so we also want to generate types for these.
46+
depsOf = pkg:
47+
[(pkg.dev or pkg)]
48+
++ (map depsOf (pkg.propagatedBuildInputs or []));
49+
in
50+
symlinkJoin {
51+
name = "gir-dirs";
52+
paths = lib.flatten (map depsOf buildInputs);
53+
};
3954
in
4055
buildGoModule {
41-
inherit pname version;
56+
inherit pname version buildInputs;
4257

4358
src = builtins.path {
4459
name = "${pname}-${version}";
@@ -54,18 +69,9 @@ in
5469
installShellFiles
5570
];
5671

57-
buildInputs =
58-
extraPackages
59-
++ [
60-
glib
61-
astal-io
62-
astal3
63-
astal4
64-
];
65-
6672
preFixup = ''
6773
gappsWrapperArgs+=(
68-
--prefix NIX_GI_DIRS : "$(${datadirs})"
74+
--prefix EXTRA_GIR_DIRS : "${girDirs}/share/gir-1.0"
6975
--prefix PATH : "${lib.makeBinPath (bins ++ extraPackages)}"
7076
)
7177
'';

0 commit comments

Comments
 (0)