Fundament-Software / scopes

Fundament fork of the Scopes language
Other
3 stars 1 forks source link

Add Nix functions to help set up include and library paths in downstream projects #17

Open LunNova opened 1 year ago

LunNova commented 1 year ago

https://github.com/Fundament-Software/feathergui/blob/9ff6331f9ad610d1bd9810e5283c3d6e688b9b4d/flake.nix#L33

        # TODO: investigate something in scopes flake to automate or abstract this
        featherDevSetupHook = ''
          export NIX_CFLAGS_COMPILE="''${NIX_CFLAGS_COMPILE:-} $(pkg-config --cflags libcjson libsail)"
          export LD_LIBRARY_PATH=${devshell-ldpath}:''${LD_LIBRARY_PATH:-}
        '';

The feathergui flake contains this hook which sets up paths for scopes. Scopes needs NIX_CFLAGS_COMPILE to contain the -I/nix/store/hash/include/lib paths and LD_LIBRARY_PATH to contain the paths to the .sos for each library to find them.

It's also possible to set up these paths in __env.sc instead of using the above env vars, and potentially generating one of those or suggesting a particular format for it which runs pkg-config would work. This would have the advantage of working with non-Nix build systems. NIX_CFLAGS_COMPILE is not portable.

Maybe it would be better if scopes supported pkg-config more directly in some way?