Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: remove XDG_DATA_DIR env reference #673

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading