Skip to content

Commit

Permalink
nix: remove XDG_DATA_DIR env reference
Browse files Browse the repository at this point in the history
using symlinkJoin instead
  • Loading branch information
Aylur committed Jan 20, 2025
1 parent 92bdcb2 commit 72befa8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
20 changes: 7 additions & 13 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ func init() {
f.MarkHidden("tsconfig")
}

func girDirectories() []string {
dataDirs := append([]string{
"/usr/local/share",
"/usr/share",
"/usr/share/*",
}, strings.Split(os.Getenv("NIX_GI_DIRS"), ":")...)

return lib.Map(dataDirs, func(dir string) string {
return filepath.Join(dir, "gir-1.0")
})
}

func spinner(stopChan chan bool) {
chars := []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}

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

for _, path := range girDirectories() {
dataDirs := append([]string{
"/usr/local/share/gir-1.0",
"/usr/share/gir-1.0",
"/usr/share/*/gir-1.0",
}, strings.Split(os.Getenv("EXTRA_GIR_DIRS"), ":")...)

for _, path := range dataDirs {
flags = append(flags, "-g", path)
}

Expand Down
48 changes: 27 additions & 21 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
symlinkJoin,
astal3,
astal4,
gtk4-layer-shell,
astal-io,
astal-gjs,
lib,
writers,
buildGoModule,
wrapGAppsHook,
gobject-introspection,
Expand All @@ -18,27 +18,42 @@
extraPackages ? [],
}: let
inherit (builtins) replaceStrings readFile;
version = replaceStrings ["\n"] [""] (readFile ../version);
pname = "ags";

datadirs = writers.writeNu "datadirs" ''
$env.XDG_DATA_DIRS
| split row ":"
| filter { $"($in)/gir-1.0" | path exists }
| str join ":"
'';
buildInputs =
extraPackages
++ [
glib
astal-io
astal3
astal4
gobject-introspection # needed for type generation
];

bins = [
gjs
nodejs
dart-sass
blueprint-compiler
astal-io # FIXME: should not be needed after the astal commends are properly implemented using dbus in astal.go
astal-io # FIXME: should not be needed after the astal commands are properly implemented using dbus in astal.go
];

version = replaceStrings ["\n"] [""] (readFile ../version);
pname = "ags";
girDirs = let
# gir files are usually in `dev` output.
# `propagatedBuildInputs` are also available in the gjs runtime
# so we also want to generate types for these.
depsOf = pkg:
[(pkg.dev or pkg)]
++ (map depsOf (pkg.propagatedBuildInputs or []));
in
symlinkJoin {
name = "gir-dirs";
paths = lib.flatten (map depsOf buildInputs);
};
in
buildGoModule {
inherit pname version;
inherit pname version buildInputs;

src = builtins.path {
name = "${pname}-${version}";
Expand All @@ -54,18 +69,9 @@ in
installShellFiles
];

buildInputs =
extraPackages
++ [
glib
astal-io
astal3
astal4
];

preFixup = ''
gappsWrapperArgs+=(
--prefix NIX_GI_DIRS : "$(${datadirs})"
--prefix EXTRA_GIR_DIRS : "${girDirs}/share/gir-1.0"
--prefix PATH : "${lib.makeBinPath (bins ++ extraPackages)}"
)
'';
Expand Down

0 comments on commit 72befa8

Please sign in to comment.