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

add support for git+https sources #24

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

matdibu
Copy link

@matdibu matdibu commented Oct 10, 2024

fixes #11

@matdibu
Copy link
Author

matdibu commented Nov 16, 2024

is there anything else I should do to make this mergeable?

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

@figsoda are you still available to review/maintain this repo?

@Ciflire
Copy link

Ciflire commented Nov 27, 2024

i really have no knowledge of zig tbh
i tried you branch, built it with nix build
and i tied to zon2nix the fancy-cat and got the following output, which is the exact same output i'm getting with the version in the nixpkgs

fancy-cat on  master [✘!?] via ↯ 
➜ ../zon2nix/result/bin/zon2nix 
error: unexpected fragment '1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1' in flake reference 'tarball+https://github.com/rockorager/libvaxis#1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1'
error: unexpected fragment '3bfba44545042f00cc908890a652da00dc3d7670' in flake reference 'tarball+https://github.com/freref/fastb64z#3bfba44545042f00cc908890a652da00dc3d7670'
error: UnexpectedEndOfInput
???:?:?: 0x24edc6 in ??? ()
???:?:?: 0x24ea54 in ??? ()
???:?:?: 0x24ea5c in ??? ()
???:?:?: 0x21bcba in ??? ()
???:?:?: 0x21bcca in ??? ()
???:?:?: 0x21bc47 in ??? ()
???:?:?: 0x21c7ab in ??? ()
???:?:?: 0x21f510 in ??? ()
error: writing to file: Broken pipe

also i tried to test parse, it does work BUT using it directly on the fixtures/basic.zon

thread 206958 panic: integer overflow
Unwind information for `:0x26beb7` was not available, trace may be incomplete

Error: nu::shell::core_dumped

  × External command core dumped
   ╭─[entry #40:1:1]
 1 │ ./result/bin/zon2nix fixtures/basic.zon
   · ──────────┬─────────
   ·           ╰── core dumped with SIGABRT (6)
   ╰────

gives this

Again i don't anything about zig and i'm sorry if this not helpful, or not intended to be used this way.

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

@Ciflire thank you for testing!
I tried it locally now and I'm getting

error:
       … while fetching the input 'git+https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz?rev=1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1'

1fd92... is the commit of the previous dependency, rockorager/libvaxis
so it looks like it's reusing that value
I'll try to write a fix now

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

it looks like it's failing when it recursively gets to https://github.com/zigimg/zigimg
which is a project without dependencies

more specifically, const dep_init = ast.fullStructInit(&buf, dep_idx) fails

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

in src/parse.zig:43, replacing

const dep_init = ast.fullStructInit(&buf, dep_idx) orelse {
    return error.ParseError;
};

with

const dep_init = ast.fullStructInit(&buf, dep_idx) orelse {
    continue;
};

does work, but I need to look into it further

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

interestingly enough, this works (in a nix shell nixpkgs#zig_0_11):

[mateidibu@precision5560:~/git/personal/fancy-cat]$ (cd ../zon2nix-matdibu && zig build) && ../zon2nix-matdibu/zig-out/bin/zon2nix 
warning: failed to get dependencies
# generated by zon2nix (https://github.com/nix-community/zon2nix)

{ linkFarm, fetchzip, fetchgit }:

linkFarm "zig-packages" [
  {
    name = "12206695fbabe2c3f981ea79d97afe8d4fdb7790773a4153543c63ac7e0d11e564c7";
    path = fetchgit {
      url = "https://github.com/freref/fastb64z";
      rev = "3bfba44545042f00cc908890a652da00dc3d7670";
      hash = "sha256-XGgUphhI983eF8dBKOx4G3eR1uLVdLLd5ZfPqLhs4Kk=";
    };
  }
  {
    name = "1220b0c4f4a5f3df2b1268a9da04bc901ede4f8bd2938e846ee1e88783ed57cee79a";
    path = fetchzip {
      url = "https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz";
      hash = "sha256-U0MxoKnCBN6WCP6yqC3Qv9nnoQXtV+RcXtVEjCm7Puk=";
    };
  }
  {
    name = "1220dd654ef941fc76fd96f9ec6adadf83f69b9887a0d3f4ee5ac0a1a3e11be35cf5";
    path = fetchgit {
      url = "https://github.com/zigimg/zigimg";
      rev = "3a667bdb3d7f0955a5a51c8468eac83210c1439e";
      hash = "sha256-oLf3YH3yeg4ikVO/GahMCDRMTU31AHkfSnF4rt7xTKo=";
    };
  }
  {
    name = "1220feaa655e14cbb4baf59fe746f09a17fc6949be46ad64dd5044982f4fc1bb57c7";
    path = fetchgit {
      url = "https://github.com/rockorager/libvaxis";
      rev = "1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1";
      hash = "sha256-a9FWBDRn6/Wf1vekrzWBR+J3chySDEv++O8Iwewsdzs=";
    };
  }
]

but this doesn't

[mateidibu@precision5560:~/git/personal/fancy-cat]$ (cd ../zon2nix-matdibu && nix build) && ../zon2nix-matdibu/result/bin/zon2nix
Segmentation fault at address 0x41
???:?:?: 0x27917c in ??? ()
Unwind information for `:0x27917c` was not available, trace may be incomplete

Aborted (core dumped)

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

running this works with -Doptimize=Debug and -Doptimize=ReleaseFast

[mateidibu@precision5560:~/git/personal/fancy-cat]$ ../zon2nix-matdibu/zig-out/bin/zon2nix 

but not -Doptimize=ReleaseSafe

Segmentation fault at address 0x41
/nix/store/nxbcz7qxcb8379r3gx5kayyp680xzmhd-zig-0.11.0/lib/zig/compiler_rt/memcpy.zig:19:21: 0x27872c in memcpy (compiler_rt)
            d[0] = s[0];
                    ^
/nix/store/nxbcz7qxcb8379r3gx5kayyp680xzmhd-zig-0.11.0/lib/zig/std/io/fixed_buffer_stream.zig:70:57: 0x261abc in write (zon2nix)
            @memcpy(self.buffer[self.pos..][0..n], bytes[0..n]);
                                                        ^
/nix/store/nxbcz7qxcb8379r3gx5kayyp680xzmhd-zig-0.11.0/lib/zig/std/io/writer.zig:17:27: 0x25a752 in formatBuf__anon_12832 (zon2nix)
            return writeFn(self.context, bytes);
                          ^
/home/mateidibu/git/personal/zon2nix-matdibu/src/fetch.zig:0:0: 0x21aad2 in fetch (zon2nix)
/home/mateidibu/git/personal/zon2nix-matdibu/src/main.zig:33:14: 0x21d7a3 in main (zon2nix)
    try fetch(alloc, &deps);
             ^
/nix/store/nxbcz7qxcb8379r3gx5kayyp680xzmhd-zig-0.11.0/lib/zig/std/start.zig:574:37: 0x21fda5 in main (zon2nix)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7fd119eee27d in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7fd119eee27d` was not available, trace may be incomplete

Aborted (core dumped)

error: writing to file: Broken pipe
error: writing to file: Broken pipe

or -Doptimize=ReleaseSmall

remote: Not Found
fatal: repository 'https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz/' not found
warning: could not read HEAD ref from repo at 'https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz', using 'master'
remote: Not Found
fatal: repository 'https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz/' not found
fatal: Refusing to point HEAD outside of refs/
warning: could not update cached head 'master' for 'https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz'
error:
       … while fetching the input 'git+https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz?rev=1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1'

       error: Cannot find Git revision '1fd920a7aea1bb040c7c028f4bbf0af2ea58e1d1' in ref 'master' of repository 'https://github.com/freref/fzwatch/archive/refs/tags/v0.2.0.tar.gz'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.
error: UnexpectedEndOfInput

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

and as a note, zig build uses Debug by default
and nixpkgs uses ReleaseSafe for zig 0.11:
https://github.com/NixOS/nixpkgs/blob/078f1251c02e162844fe42e9fcc65fd4fe3e3bce/pkgs/development/compilers/zig/hook.nix#L37-L38

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

and guess what, it works if I cherry-pick #21

@matdibu
Copy link
Author

matdibu commented Nov 27, 2024

@Ciflire all in all, I think that's a different issue (dependencies without any dependecies)
but I included a fix anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support git+ dependencies.
2 participants