Skip to content

Conversation

mobid
Copy link

@mobid mobid commented May 23, 2025

Guile library for GTK.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` label May 23, 2025
@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label May 23, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 23, 2025
@acid-bong
Copy link
Contributor

Also read CONTRIBUTING.md and pkgs/README.md

@mobid mobid force-pushed the guile-g-golf branch 2 times, most recently from 1a4960a to be1e1ef Compare May 23, 2025 21:05
@mobid
Copy link
Author

mobid commented May 23, 2025

Thank you for review. A have applied your suggestions.

@mobid mobid force-pushed the guile-g-golf branch 3 times, most recently from 9a52a36 to 2d8eaba Compare May 25, 2025 17:33
@mobid mobid changed the title g-golf: init at 0.8.1 g-golf: init at 0.8.2 Jun 18, 2025
@Aleksanaa
Copy link
Member

Sorry, I forgot this PR. I've pushed a commit to your branch, please see if it works.

@Aleksanaa
Copy link
Member

Don't know if that means you don't like the solution or you didn't read it. Anyway the patch is here:

diff --git a/pkgs/by-name/g-/g-golf-adw-1-examples/package.nix b/pkgs/by-name/g-/g-golf-adw-1-examples/package.nix
deleted file mode 100644
index 77c90a6e4c07..000000000000
--- a/pkgs/by-name/g-/g-golf-adw-1-examples/package.nix
+++ /dev/null
@@ -1,68 +0,0 @@
-{
-  stdenv,
-  lib,
-  fetchurl,
-  makeWrapper,
-  wrapGAppsHook4,
-  pkg-config,
-  guile,
-  guile-cairo,
-  glib,
-  gobject-introspection,
-  libadwaita,
-  callPackage,
-  g-golf,
-  texinfo,
-}:
-stdenv.mkDerivation (finalAttrs: {
-
-  inherit (g-golf) version src;
-
-  pname = "g-golf-adw-1-examples";
-
-  nativeBuildInputs = [
-    pkg-config
-    texinfo
-    makeWrapper
-    wrapGAppsHook4
-    glib
-  ];
-
-  buildInputs = [
-    guile
-    g-golf
-    guile-cairo
-    gobject-introspection
-    libadwaita
-  ];
-
-  sourceRoot = "g-golf-${finalAttrs.version}/examples/adw-1/demo";
-
-  postBuild = ''
-    glib-compile-resources --target g-resources g-resources.xml
-  '';
-
-  installPhase = ''
-    mkdir -p $out/bin $out/share/doc/g-golf/examples
-    cp -rf .. $out/share/doc/g-golf/examples/
-
-    find $out/share -type f -executable | while read file; do
-      name=g-golf-adw-1-$(basename $file)
-      makeWrapper $file $out/bin/$name \
-        --chdir $(dirname $file) \
-        --prefix PATH : "${guile}/bin" \
-        --prefix GUILE_LOAD_PATH : "$GUILE_LOAD_PATH" \
-        --prefix GUILE_LOAD_COMPILED_PATH : "$GUILE_LOAD_COMPILED_PATH" \
-        --prefix LD_LIBRARY_PATH : "${g-golf}/lib:${guile-cairo}/lib" \
-        --set GUILE_AUTO_COMPILE 0
-    done
-  '';
-
-  meta = {
-    description = "G-Golf adwaita-1 examples";
-    homepage = "https://www.gnu.org/software/g-golf/";
-    license = lib.licenses.lgpl3Plus;
-    maintainers = with lib.maintainers; [ mobid ];
-    platforms = lib.platforms.unix;
-  };
-})
diff --git a/pkgs/by-name/g-/g-golf-gtk-4-examples/package.nix b/pkgs/by-name/g-/g-golf-gtk-4-examples/package.nix
index f926933eebdb..bf6968a91180 100644
--- a/pkgs/by-name/g-/g-golf-gtk-4-examples/package.nix
+++ b/pkgs/by-name/g-/g-golf-gtk-4-examples/package.nix
@@ -1,7 +1,6 @@
 {
-  stdenv,
   lib,
-  fetchurl,
+  stdenv,
   makeWrapper,
   wrapGAppsHook4,
   pkg-config,
@@ -12,15 +11,20 @@
   gtk4,
   which,
   adwaita-icon-theme,
-  callPackage,
+  libadwaita,
   g-golf,
   texinfo,
+  g-golf-adw-1-examples,
+  useLibadwaita ? false,
 }:
+
 stdenv.mkDerivation (finalAttrs: {
 
   inherit (g-golf) version src;
 
-  pname = "g-golf-gtk-4-examples";
+  pname = "g-golf-${finalAttrs.variant}-examples";
+
+  variant = if useLibadwaita then "adw-1" else "gtk-4";
 
   nativeBuildInputs = [
     pkg-config
@@ -38,16 +42,18 @@ stdenv.mkDerivation (finalAttrs: {
     gobject-introspection
     gtk4
     adwaita-icon-theme
-  ];
+  ] ++ lib.optionals useLibadwaita [ libadwaita ];
 
-  sourceRoot = "g-golf-${finalAttrs.version}/examples/gtk-4/demos";
+  sourceRoot = "g-golf-${finalAttrs.version}/examples/${finalAttrs.variant}/demos";
 
   installPhase = ''
+    runHook preInstall
+
     mkdir -p $out/bin $out/share/doc/g-golf/examples
     cp -rf .. $out/share/doc/g-golf/examples/
 
     find $out/share -type f -executable | while read file; do
-      name=g-golf-gtk-4-$(basename $file)
+      name=g-golf-${finalAttrs.variant}-$(basename $file)
       makeWrapper $file $out/bin/$name \
         --chdir $(dirname $file) \
         --prefix PATH : "${guile}/bin" \
@@ -56,10 +62,14 @@ stdenv.mkDerivation (finalAttrs: {
         --prefix LD_LIBRARY_PATH : "${g-golf}/lib:${guile-cairo}/lib" \
         --set GUILE_AUTO_COMPILE 0
     done
+
+    runHook postInstall
   '';
 
+  passthru.tests = { inherit g-golf-adw-1-examples; };
+
   meta = {
-    description = "G-Golf gtk-4 examples";
+    description = "G-Golf ${finalAttrs.variant} examples";
     homepage = "https://www.gnu.org/software/g-golf/";
     license = lib.licenses.lgpl3Plus;
     maintainers = with lib.maintainers; [ mobid ];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index d196b6c1f469..34385faed8fd 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -3028,6 +3028,10 @@ with pkgs;
 
   uniscribe = callPackage ../tools/text/uniscribe { };
 
+  g-golf-adw-1-examples = callPackage ../by-name/g-/g-golf-gtk-4-examples/package.nix {
+    useLibadwaita = true;
+  };
+
   gandi-cli = python3Packages.callPackage ../tools/networking/gandi-cli { };
 
   gaphor = python3Packages.callPackage ../tools/misc/gaphor { };

@mobid
Copy link
Author

mobid commented Jun 18, 2025

Sorry, I force-pushed before saw your commit.
I will check your suggestion now.

@Aleksanaa
Copy link
Member

@ofborg build g-golf-gtk-4-examples g-golf-adw-1-examples

@Aleksanaa
Copy link
Member

g-golf-gtk-4-animated-paintable

=> ./results/g-golf-gtk-4-examples-x86_64-linux/bin/g-golf-gtk-4-animated-paintable 
Backtrace:
In ice-9/boot-9.scm:
  1755:12 11 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
          10 (apply-smob/0 #<thunk 7f9e9cf14300>)
In ice-9/boot-9.scm:
    724:2  9 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  8 (_ #(#(#<directory (guile-user) 7f9e9cf18c80>)))
   293:34  7 (_ #(#(#(#<directory (guile-user) 7f9e9cf18c80>) (#)) #))
In g-golf/hl-api/function.scm:
    91:22  6 (_ . _)
In unknown file:
Exception thrown while printing backtrace:
In procedure primitive-call-ip: Wrong type argument in position 1 (expecting PRIMITIVE_P): #<procedure 7f9e941056a0 (_ _ _ _ _ _ _)>

ERROR: In procedure %resolve-variable:
Unbound variable: cairo-pointer->context

g-golf-gtk-4-clipboard

missing icon:

image

g-golf-gtk-4-peg-solitaire

Can't interact with? I don't know how to use it tbf

g-golf-gtk-4-simple-paintable

=> ./results/g-golf-gtk-4-examples-x86_64-linux/bin/g-golf-gtk-4-simple-paintable 
Backtrace:
In ice-9/boot-9.scm:
  1755:12 11 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
          10 (apply-smob/0 #<thunk 7fbdf7514300>)
In ice-9/boot-9.scm:
    724:2  9 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  8 (_ #(#(#<directory (guile-user) 7fbdf7518c80>)))
   293:34  7 (_ #(#(#(#<directory (guile-user) 7fbdf7518c80>) (#)) #))
In g-golf/hl-api/function.scm:
    91:22  6 (_ . _)
In unknown file:
Exception thrown while printing backtrace:
In procedure primitive-call-ip: Wrong type argument in position 1 (expecting PRIMITIVE_P): #<procedure 7fbdee738300 (_ _ _ _ _ _ _)>

ERROR: In procedure %resolve-variable:
Unbound variable: cairo-pointer->context

@mobid
Copy link
Author

mobid commented Jun 19, 2025

For peg-solitaire and clipboard is this correct behaviour. I will ask package maintainer for sure.

About other two: I forget that g-golf (if you use cairo) need last version of guile-cairo [1] to work. I have this version in overlay so it was working for me:

guile-cairo.overrideAttrs (s: {
  src = fetchgit {
    url = "https://git.savannah.gnu.org/git/guile-cairo.git";
    rev = "fa2ff12e5e01966d5dcd8cfb7d5f29324b814223";
    hash = "sha256-yrI4VjMSFVvtxtY+JLrDXAYfCUAM3UkAFBSW5p8F5g8=";
  };
  nativeBuildInputs = [ autoconf automake texinfo ]
                      ++ s.nativeBuildInputs;

  preConfigure = ''
    autoreconf -fvi
  '';
})

How can we deal with this. Can I put last version into all-packages.nix under name guile-cairo-next?

[1] https://cgit.git.savannah.gnu.org/cgit/guile-cairo.git/ (last few commits are needed)

@mobid
Copy link
Author

mobid commented Jun 20, 2025

g-golf-gtk-4-peg-solitaire

Can't interact with? I don't know how to use it tbf

It's a drag and drop example.

@mobid
Copy link
Author

mobid commented Jul 4, 2025

@Aleksanaa Check the last commit, WDYT?

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Jul 4, 2025
@Aleksanaa
Copy link
Member

See #421201

@mobid
Copy link
Author

mobid commented Jul 8, 2025

See #421201

Ok. I copy package. It will become deprecated when new version of guile-cairo will be released.

Comment on lines +59 to +61
sed -i 's|libgirepository-1.0|${gobject-introspection}/lib/libgirepository-1.0.so|' g-golf/init.scm
sed -i "s|libglib-2.0|${glib.out}/lib/libglib-2.0.so|" g-golf/init.scm
sed -i "s|libgobject-2.0|${glib.out}/lib/libgobject-2.0.so|" g-golf/init.scm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get the equivalent working with

env.LD_LIBRARY_PATH = lib.makeLibraryPath [
    gobject-introspection
    glib
];

If you also want to support cross-compilation, these libraries probably need to be retrieved from buildPackages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do this, the examples stop working.

Copy link
Contributor

@Kiskae Kiskae Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the way this is supposed to work is with GUILE_EXTENSIONS_PATH.

But since this needs to be propagated (as you found by the broken examples), this would probably need to be added to the guile package itself, and then have this package use propagatedBuildInputs to make dependencies available downstream.

Not sure who maintains this interpreter though.

@mobid
Copy link
Author

mobid commented Jul 24, 2025

@Aleksanaa Is now ok?

@mobid mobid requested a review from acid-bong August 13, 2025 18:49
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 13, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants