Hi everyone, I have the following issue:
I made a program using Odinlang, which can be found at GitHub - Vonixxx/Search.
The build.sh file consists of the following:
odin build Source -file -out:search -o:aggressive -microarch:native
In order to build it on NixOS (I use the unstable branch, recently updated), the following flake.nix file is provided, to be used with nix develop:
1 │ {
2 │ inputs = {
3 │ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
4 │ };
5 │
6 │ outputs = {
7 │ nixpkgs
8 │ , ...
9 │ }:
10 │
11 │ let
12 │ pkgs = import nixpkgs {
13 │ system = "x86_64-linux";
14 │ };
15 │ in with pkgs; {
16 │ devShells.x86_64-linux.default = mkShell {
17 │ LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${
18 │ lib.makeLibraryPath [
19 │ libGL
20 │ xorg.libX11
21 │ ]
22 │ }";
23 │
24 │ buildInputs = [
25 │ libGL
26 │ odin
27 │ xorg.libX11
28 │ ];
29 │
30 │ shellHook = ''
31 │ alias run='odin run .'
32 │ alias build='odin build .'
33 │ '';
34 │ };
35 │ };
36 │ }
Running nix develop and then ./build.sh successfully builds the program and works as intended when executed.
But now I am trying to test it by packaging it for nixpkgs, so I can use it on my system. I have cloned the nixpkgs repository and done the usual, i.e. placing the callPackage at the top-level and placing the corresponding package.nix in the appropriate by-name directory, which is the following:
1 │ { lib
2 │ , odin
3 │ , xorg
4 │ , libGL
5 │ , stdenv
6 │ , fetchFromGitHub
7 │ , ...
8 │ }:
9 │
10 │ stdenv.mkDerivation {
11 │ version = "1.0";
12 │ pname = "search";
13 │
14 │ src = fetchFromGitHub {
15 │ repo = "Search";
16 │ owner = "Vonixxx";
17 │ rev = "96658de77432ea2106ea49224efee365e4601a99";
18 │ hash = "sha256-I3vE9eaRNuz6ADcz65TWt7nY5B/NKFD446SqNX1FGq8=";
19 │ };
20 │
21 │ LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${
22 │ lib.makeLibraryPath [
23 │ libGL
24 │ xorg.libX11
25 │ ]
26 │ }";
27 │
28 │ buildInputs = [
29 │ odin
30 │ libGL
31 │ xorg.libX11
32 │ ];
33 │
34 │ postPatch = ''
35 │ patchShebangs build.sh
36 │ '';
37 │
38 │ buildPhase = ''
39 │ runHook preBuild
40 │
41 │ ./build.sh
42 │
43 │ runHook postBuild
44 │ '';
45 │
46 │ installPhase = ''
47 │ runHook preInstall
48 │
49 │ install -Dm755 search $out/bin/search
50 │
51 │ runHook postInstall
52 │ '';
53 │
54 │ meta = {
55 │ inherit (odin.meta) platforms;
56 │
57 │ mainProgram = "search";
58 │ license = lib.licenses.mit;
59 │ description = "Simple Search Program";
60 │ homepage = "https://github.com/Vonixxx/Search";
61 │
62 │ maintainers = with lib.maintainers; [
63 │ vonixxx
64 │ ];
65 │ };
66 │ }
Attempting to build it with nix-build -A search, I get the following error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: builder for '/nix/store/msbwyhz3wmys734qvndswbxipk77fxsw-search-1.0.drv' failed with exit code 1;
last 10 log lines:
> patching script interpreter paths in build.sh
> build.sh: interpreter directive changed from "#!/usr/bin/env bash" to "/nix/store/i1x9sidnvhhbbha2zhgpxkhpysw6ajmr-bash-5.2p26/bin/bash"
> Running phase: updateAutotoolsGnuConfigScriptsPhase
> Running phase: configurePhase
> calling 'preConfigure' function hook '_multioutConfig'
> no configure script, doing nothing
> Running phase: buildPhase
> /nix/store/qsx2xqqm0lp6d8hi86r4y0rz5v9m62wn-binutils-2.42/bin/ld: cannot find -l:/nix/store/dq6mlgndxymscnhxfyb38k5pn5i1cixf-odin-dev-2024-07/share/vendor/raylib/linux/libraygui.a: No such file or directory
> /nix/store/qsx2xqqm0lp6d8hi86r4y0rz5v9m62wn-binutils-2.42/bin/ld: cannot find -l:/nix/store/dq6mlgndxymscnhxfyb38k5pn5i1cixf-odin-dev-2024-07/share/vendor/raylib/linux/libraylib.a: No such file or directory
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
For full logs, run 'nix log /nix/store/msbwyhz3wmys734qvndswbxipk77fxsw-search-1.0.drv'.
When I look at the respective directories, I can see that the files are there:
┌ nixpkgs master [⇡] 2s
└❮ ls /nix/store/dq6mlgndxymscnhxfyb38k5pn5i1cixf-odin-dev-2024-07/share/vendor/raylib/linux
linux/
├── libraygui.a
├── libraygui.so
├── libraylib.a
├── libraylib.so@ ⇒ libraylib.so.500
├── libraylib.so.5.0.0*
└── libraylib.so.500@ ⇒ libraylib.so.5.0.0
So what gives? I’d appreciate it if anyone could help.