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

collision: init at 3.5.0 #242681

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

sund3RRR
Copy link
Contributor

Description of changes

Collision - small but useful application, that check hashes for files.
https://github.com/GeopJr/Collision

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

maintainers/maintainer-list.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
@@ -485,6 +485,8 @@ with pkgs;

colorpicker = callPackage ../tools/misc/colorpicker { };

collision = callPackage ../applications/misc/collision { };
Copy link
Contributor

Choose a reason for hiding this comment

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

move this above colmena for alphabetical order

@eclairevoyant
Copy link
Contributor

Also just FYI, as I see you used the github interface to accept the review changes, you will need to squash and force-push the commits for this PR at the end before it gets approved (see https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#writing-good-commit-messages)

Copy link
Contributor

@NobbZ NobbZ left a comment

Choose a reason for hiding this comment

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

Please make also sure, that before merging you squash everything together into exactly 2 commits:

  1. add yourself as maintainer, message: "maintainers: Add sund3RRR as a maintainer"
  2. everything related to the package: "collision: init at 3.5.0"

You also might want to add a meta.mainProgram.

maintainers/maintainer-list.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
};

# project dependencies
dependencies = [
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can see while skimming other usages of crystal.buildCrystalPackage, they seem to provide a generated shardsFile, which seems to be responsible for the deps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to build this package with the dependencies generated by shards.nix, but the gi-crystal dependency needs to be built. There is no documentation for crystal.buildCrystalPackage and I don't know how to specify a dependency building phase for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case it might make sense to make that its completely own derivation, which you use as a nativeBuildInputs, as from what I get now from rereading the comments and your reply here, it seems to be some kind of build tool that needs to run on the build host natively, and does not necessarily need to be ran on the target host?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is a good way.

Copy link
Contributor Author

@sund3RRR sund3RRR Jul 11, 2023

Choose a reason for hiding this comment

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

Fixed this issue in 1de87e0, take a look at this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copy not only the gi-crystal, but also all other dependencies for the gi-crystal itself.

crystal.buildCrystalPackage collect dependencies specified in shards.nix into a separated drv and symlinks it from lib/ directory. But when i run gi-crystal it cannot see dependencies linked by symlink. Perhaps there is a check for a directory, and since the file is a link to the directory, and not the directory itself, gi-crystal generates bindings without these dependencies, especially without libadwaita, which is needed for Collision.

I would pack the gi-crystal before packing the collision, but I don’t know how to solve the problem of generating bindings, because the gi-crystal does not see the dependencies attached by a symbolic link.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, gi-crystal searches for binding files in the project root (including its dependencies) and generates bindings for them based on their gir files. By default it searches for gir files under /usr/share/gir-1.0/ but you can pass : separated paths to the GI_TYPELIB_PATH env var. From a quick look, I do not see anything about not following symlinks (File#exists? is used but it follows symlinks)

Copy link
Contributor Author

@sund3RRR sund3RRR Jul 14, 2023

Choose a reason for hiding this comment

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

Thank you for your help, @GeopJr. It seems that there are no problems with the detection of typelibs, the main problem is to find binding.yml
I write a simple bash script, that find and print all binding.yml files in directory.

ls -la
start_directory="./"
found_files=$(find "$start_directory" -type f -name "binding.yml" 2>/dev/null)

And it prints

lrwxrwxrwx 1 nixbld nixbld   59 Jul 14 13:24 gio -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/gio
lrwxrwxrwx 1 nixbld nixbld   60 Jul 14 13:24 gtk4 -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/gtk4
lrwxrwxrwx 1 nixbld nixbld   64 Jul 14 13:24 harfbuzz -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/harfbuzz
lrwxrwxrwx 1 nixbld nixbld   66 Jul 14 13:24 libadwaita -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/libadwaita
lrwxrwxrwx 1 nixbld nixbld   61 Jul 14 13:24 pango -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/pango
Found files:
./src/bindings/g_lib/binding.yml
./src/bindings/g_object/binding.yml

Only if i specify directory like start_directory="lib/gio/src", it will find gio's binding.yml

lrwxrwxrwx 1 nixbld nixbld   59 Jul 14 13:25 gio -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/gio
lrwxrwxrwx 1 nixbld nixbld   60 Jul 14 13:25 gtk4 -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/gtk4
lrwxrwxrwx 1 nixbld nixbld   64 Jul 14 13:25 harfbuzz -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/harfbuzz
lrwxrwxrwx 1 nixbld nixbld   66 Jul 14 13:25 libadwaita -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/libadwaita
lrwxrwxrwx 1 nixbld nixbld   61 Jul 14 13:25 pango -> /nix/store/dkwc4p77z9aw9fkgi6z6gcc4sbrxdjh6-crystal-lib/pango
Found files:
lib/gio/src/bindings/gio/binding.yml

I looked at the gi-crystal sources and it looks like it is looking for these files in some similar way, so it cannot find them.

private def find_bindings : Array(String)
  find_pattern = Path.new(project_dir, "**/binding.yml").normalize
  Dir[find_pattern]
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just look at how many bindings gi-crystal finds when i copy dependencies manually

Dependencies are satisfied
Building: gi-crystal
Resolving dependencies
Writing shard.lock
info - Starting at 2023-07-14 13:42:33 UTC, project dir: /build/source
info - Gi-Crystal version 0.16.0, built with Crystal 1.8.2.
info - Generating bindings at /build/source/src/auto
info - Using binding config at /build/source/lib/pango/src/bindings/pango/binding.yml
info - Using binding config at /build/source/lib/harfbuzz/src/bindings/harfbuzz/binding.yml
info - Using binding config at /build/source/lib/gio/src/bindings/gio/binding.yml
info - Using binding config at /build/source/lib/gtk4/src/bindings/gdk/binding.yml
info - Using binding config at /build/source/lib/gtk4/src/bindings/gtk/binding.yml
info - Using binding config at /build/source/lib/gtk4/src/bindings/gsk/binding.yml
info - Using binding config at /build/source/lib/libadwaita/src/bindings/binding.yml
info - Using binding config at /build/source/src/bindings/g_lib/binding.yml
info - Using binding config at /build/source/src/bindings/g_object/binding.yml...

And how many without it:

Dependencies are satisfied
Building: gi-crystal
Resolving dependencies
Writing shard.lock
info - Starting at 2023-07-14 13:24:41 UTC, project dir: /build/source
info - Gi-Crystal version 0.16.0, built with Crystal 1.8.2.
info - Generating bindings at /build/source/src/auto
info - Using binding config at /build/source/src/bindings/g_lib/binding.yml
info - Using binding config at /build/source/src/bindings/g_object/binding.yml
glibPreInstallPhase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And of course i get compiler error:

In src/collision.cr:2:1

 2 | require "libadwaita"
     ^
Error: Bindings for Adw-1 not yet generated, run ./bin/gi-crystal first.

@NobbZ
Copy link
Contributor

NobbZ commented Jul 11, 2023

\cc @peterhoeg @manveru and @Br1ght0ne

You are randomly choosen samples of maintainers with a crytalpackage and I'd like to see your review as well.

@sund3RRR sund3RRR changed the title Added Collision (GNOME circle app) to nixpkgs Collision: init at 3.5.0 Jul 12, 2023

test: test-binding
- ./bin/spec $(RSPEC_OPTS)
+ sh bin/spec $(RSPEC_OPTS)
Copy link
Member

Choose a reason for hiding this comment

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

Why not patch the shebang instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This patch was removed in 9c1cd51

, wrapGAppsHook4
}:
let
gi_crystal = crystal.buildCrystalPackage {
Copy link
Member

Choose a reason for hiding this comment

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

Why not move that into gi-crystal/default.nix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, fixed in 9c1cd51

Comment on lines 14 to 19
name = "gi-crystal";

src = fetchFromGitHub {
owner = "hugopl";
repo = "gi-crystal";
rev = "refs/tags/v0.16.0";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name = "gi-crystal";
src = fetchFromGitHub {
owner = "hugopl";
repo = "gi-crystal";
rev = "refs/tags/v0.16.0";
pname = "gi-crystal";
version = "0.16.0";
src = fetchFromGitHub {
owner = "hugopl";
repo = "gi-crystal";
rev = "refs/tags/v${version}";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

error: undefined variable 'version'

       at /home/sunder/repos/nixpkgs/pkgs/applications/misc/collision/default.nix:20:27:

           19|       repo = "gi-crystal";
           20|       rev = "refs/tags/v${version}";
             |                           ^
           21|       hash = "sha256-ij4U8BoSNHpkh5SmvoH5anGB/ZdvmC5zDwJCusR/s/c=";

maybe if move this into gi-crystal/default.nix, it might work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it works

Comment on lines 31 to 32
doCheck = false;
doInstallCheck = false;
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to disable both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without doCheck = false;:

> info - Using binding config at /build/source/src/bindings/g_object/binding.yml
       > info - Using binding config at /build/source/spec/libtest_binding.yml
       > fatal - Typelib file for namespace 'Pango', version '1.0' not found
       > make: *** [Makefile:13: test-binding] Error 1

This happens because make test-binding set GI_TYPELIB_PATH="./spec/build" for binding generator

test-binding: libtest generator
	GI_TYPELIB_PATH="./spec/build" LIBRARY_PATH="./spec/build" LD_LIBRARY_PATH="./spec/build" ./bin/gi-crystal spec/libtest_binding.yml -o src/auto --doc

Without doInstallCheck = false;:

> In /nix/store/3ba2q00y5jpjxbwcg6m9fnr3ixj3y2kx-gi-crystal/bin/compare-api:90:14
       >
       >  90 | if Process.fork
       >                  ^---
       > Warning: Deprecated Process.fork. Fork is no longer supported.
       >
       > A total of 1 warnings were found.
       > /nix/store/blpvf60m29q02c0lc5fyhim30ma4y1vv-stdenv-linux/setup: line 1597: [: /nix/store/3ba2q00y5jpjxbwcg6m9fnr3ixj3y2kx-gi-crystal/bin/format: unary operator expected
       > /nix/store/3ba2q00y5jpjxbwcg6m9fnr3ixj3y2kx-gi-crystal/bin/format: line 4: clang-format: not found

I don't know what is it and just disable doInstallCheck....

Copy link
Member

Choose a reason for hiding this comment

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

This happens because make test-binding set GI_TYPELIB_PATH="./spec/build" for binding generator

Just remove this and see if it works.

Comment on lines 36 to 37
for dep in *; do
if [ -d "$dep" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for dep in *; do
if [ -d "$dep" ]; then
for dep in */; do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 9c1cd51

@sund3RRR
Copy link
Contributor Author

@GeopJr if you'd like, can you help with review from a crystal perspective?

@sund3RRR sund3RRR requested a review from NobbZ July 13, 2023 15:55
@drupol drupol changed the title Collision: init at 3.5.0 collision: init at 3.5.0 Jul 14, 2023
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Hi !

I made a few comments, let me know if you need help implementing them.
I also set the PR in draft, please, remove the draft status as soon as you think everything is fixed so I can give it another review.

Thanks in advance!

pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/gi-crystal/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/gi-crystal/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/gi-crystal/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/gi-crystal/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/collision/default.nix Outdated Show resolved Hide resolved
@drupol drupol marked this pull request as draft July 14, 2023 08:07
@sund3RRR sund3RRR requested a review from drupol July 14, 2023 11:30
@sund3RRR
Copy link
Contributor Author

Hi, @drupol!
Thank you for the review, it was interesting to know why I shouldn't use pname in repo= field.
I fixed everything you mentioned, please do another review as soon as you can.

@sund3RRR sund3RRR marked this pull request as ready for review July 14, 2023 11:31
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the remarks!

@drupol
Copy link
Contributor

drupol commented Jul 14, 2023

I notice that the Darwin build is failing...

> xml-stripblanks preprocessing requested, but XMLLINT is not set, and xmllint is not in PATH
       > ld: library not found for -ladwaita-1.3 (this usually means you need to install the development package for libadwaita-1.3)
       > clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
       > Error: execution of command failed with exit status 1: clang "${@}" -o /private/tmp/nix-build-Collision-3.5.0.drv-0/source/bin/collision  -rdynamic -L/nix/store/3iqhlr8s45mna8lr6ak70m6ahmmxl622-boehm-gc-8.2.2/lib -L/nix/store/6wdqgqsy9mw0h2a654ak1spbl317d9n0-pcre2-10.42/lib -L/nix/store/kcigkasqrzkwv2jzl691a7gjnx0fimmh-libevent-2.1.12/lib -L/nix/store/ck4y4f5hyya9cgnf5k00dvh3lc07snna-libyaml-0.2.5/lib -L/nix/store/zjvf5s5mj7vk7bclm6ygvszqhv3c3rhy-zlib-1.2.13/lib -L/nix/store/iafvmgzmv0i2xjkjrn4jy1bqjnpip8sf-libxml2-2.10.4/lib -L/nix/store/vzxmmsd27cjx7ac9hlyhc2p8s9p6f928-openssl-3.0.9/lib -L/nix/store/5xpnv5p68vksd9crxpffzx8m31lmh2xz-libiconv-50/lib `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -ladwaita-1.3 -lgtk-4 -lgtk-4 -l-2.76 -l-2.76 -l-2.76 -lpcre2-8 -lgc -levent_pthreads -levent -liconv
       For full logs, run 'nix log /nix/store/zvaiaky3ikg45k8yam875zhmhi9dawjx-Collision-3.5.0.drv'.

Is it an expected behavior?

@sund3RRR
Copy link
Contributor Author

I haven't tested on Darwin yet. I think I won't test on darwin because I don't have a macbook :(

@reckenrode
Copy link
Contributor

reckenrode commented Jul 14, 2023

It’s failing to link on Darwin because gi-crystal is mangling the library names for pkg-config (e.g., gio should be gio-2.0, but it’s just -2.76). If I manually fix those to see if it links, it does, but the app doesn’t work.

Before marking it broken, I want to see if I can fix the generator and add desktopToDarwinBundle as nativeBuildInput.

@reckenrode
Copy link
Contributor

gi-crystal needs patched to work correctly with libraries in the nix store. I’m surprised this builds on Linux.

https://github.com/hugopl/gi-crystal/blob/1a76f758be74cb712148f609fc94c611b3d19057/src/generator/lib_gen.cr#L13

If the package name starts with lib, that regex will match the package name and version in the store path rather than on the dylib name.

For example, libadwaita is installed in this path on my system:

/nix/store/clygv0n6kfbahq5dyfidwzyym5z3nm27-libadwaita-1.3.3/lib/libadwaita-1.0.dylib

What it should be finding is libadwaita-1. What it gets is libadwaita-1.3, which is incorrect.

rev = "v${version}";
hash = "sha256-ij4U8BoSNHpkh5SmvoH5anGB/ZdvmC5zDwJCusR/s/c=";
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Make sure gi-crystal picks up the name of the so or dylib and not the leading nix store path
# when the package name happens to start with “lib”.
patches = [ ./store-friendly-library-name.patch ];

Copy link
Contributor

Choose a reason for hiding this comment

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

The contents of the patch:

diff -ur a/src/generator/lib_gen.cr b/src/generator/lib_gen.cr
--- a/src/generator/lib_gen.cr	1969-12-31 17:00:01.000000000 -0700
+++ b/src/generator/lib_gen.cr	2023-07-14 11:48:41.509397114 -0600
@@ -10,7 +10,7 @@
 
     private def libraries : Array(String)
       namespace.shared_libraries.map do |library|
-        library[/lib([^\/]+)\.(?:so|.+?\.dylib).*/, 1]
+        library[/(?:\/[^\/]*)+\/lib([^\/]+)\.(?:so|.+?\.dylib).*/, 1]
       end
     end
 

# There is an explanation for this https://danilafe.com/blog/crystal_nix_revisited/
# Shortly, adding pkg-config to buildInputs along with openssl fixes the issue.

nativeBuildInputs = [ wrapGAppsHook4 pkg-config ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
nativeBuildInputs = [ wrapGAppsHook4 pkg-config ];
nativeBuildInputs = [ wrapGAppsHook4 pkg-config ]
++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];

@@ -0,0 +1,70 @@
{ lib
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ lib
{ stdenv
, lib

@reckenrode
Copy link
Contributor

With those suggested changes, Collision builds for me. It even has a nice .app bundle on Darwin with an icon.

@sund3RRR
Copy link
Contributor Author

I made a gi-crystal source patch, it's almost usable in nix. (Warning: build is broken on this commit) 99939f5
I added symlink check in find_bindings function, now gi-crystal can find binding.yml files in symlinked dirs.

Dir.glob(File.join(current_directory, "**/*")).each do |path|
    if File.symlink?(path)
      bindings += find_bindings_yml(path)
    end
end

Another fix is to set project dir outside of gi-crystal binary. Just set project_dir to current working directory.

current_directory = Dir.current

Now we can call gi-crystal binary and generate bindings easily without copying. But there is one problem. gi-crystal require paths is hard-coded in sources.
require {{ "gi-crystal/src/auto/#{namespace.underscore.id}-#{version.id}/#{namespace.underscore.id}" }}
This means, that bindings must be placed in lib/gi-crystal/src/auto directory. But all dependencies is a separated derivations, gi-crystal folder is read-only. That's why we get

Unhandled exception: Unable to create directory: '/build/source/lib/gi-crystal/src/auto/pango-1.0': Permission denied (File::AccessDeniedError)

and now i'm stuck at this point.
I can't patch this because this dependency was collected by shards.nix in a separated derivation.

@sund3RRR
Copy link
Contributor Author

I tried different methods and came to the conclusion that in the current version, without copying gi-crystal drv, it is impossible to generate bindings normally without hard injection in src. However, at the moment gi-crystal sees symlinked dependencies and generally works well.

If you remove the gi-crystal from shards.nix, then you can just manually copy the gi-crystal from its derivation:

mkdir lib/gi-crystal
cp -r ${gi-crystal}/* lib/gi-crystal

And then generate all bindings that you need:

chmod +w lib/gi-crystal/src/auto
${gi-crystal}/bin/gi-crystal -o lib/gi-crystal/src/auto

I don't think there is any other way to do it better.

@GeopJr, can you review gi-crystal source patches?

I can split this PR into gi-crystal: init and collision: init if everyone likes the way it works.

@sund3RRR
Copy link
Contributor Author

I packed the gi-crystal.
#243914
If this PR is approved, the collision issue is resolved

@sund3RRR sund3RRR mentioned this pull request Jul 17, 2023
31 tasks
, desktopToDarwinBundle
}:
let
gi-crystal = callPackage gi-crystal/default.nix { };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
gi-crystal = callPackage gi-crystal/default.nix { };
gi-crystal = callPackage ./gi-crystal/default.nix { };

cp -r ${gi-crystal}/* lib/gi-crystal

chmod +w lib/gi-crystal/src/auto
${gi-crystal}/bin/gi-crystal -o lib/gi-crystal/src/auto
Copy link
Member

Choose a reason for hiding this comment

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

That should be added to nativeBuildInputs instead

Comment on lines 19 to 21
# Make sure gi-crystal picks up the name of the so or dylib and not the leading nix store path
# when the package name happens to start with “lib”.
patches = [ ./store-friendly-library-name.patch ./find_bindings.patch];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Make sure gi-crystal picks up the name of the so or dylib and not the leading nix store path
# when the package name happens to start with “lib”.
patches = [ ./store-friendly-library-name.patch ./find_bindings.patch];
patches = [
# Make sure gi-crystal picks up the name of the so or dylib and not the leading nix store path
# when the package name happens to start with “lib”.
./store-friendly-library-name.patch
./find_bindings.patch
];

@sund3RRR
Copy link
Contributor Author

That's all! After packing the gi-crystal, it became much easier.

@SuperSandro2000 SuperSandro2000 merged commit f119d4c into NixOS:master Jul 19, 2023
7 of 8 checks passed
@auroraanna auroraanna mentioned this pull request Jul 25, 2023
13 tasks
@sund3RRR sund3RRR mentioned this pull request Jul 29, 2023
12 tasks
@sund3RRR sund3RRR deleted the collision-package-branch branch August 3, 2023 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants