Open xrd opened 1 year ago
I think @andrewchambers might have some insight into the situation, but I don't know how available he is recently.
This is a common issue (I encounter it all the time on fresh installs).
The problem is that jpm looks at default-config.janet
to figure out where to pull janet.h
and janet.a
from.
As per configs/README.md
:
This directory contains some example configs for installing jpm for various platforms. Package maintainers or people writing scripts to install jpm may need to adopt (especially on windows!) if the default config does not work.
Specifically, if you look at the linking command, it's trying to link against /nix/store/hfimcza6af6qd1944ngf22xqbiayrrw6-jpm-0.0.2/lib/libjanet.a
, which matches the nix-store path of jpm (and not that of janet).
Since nix is treating them as separate packages, the packager should make sure to modify the nix-specific config to set :headerpath
, :libpath
and potentially :manpath
to refer to the janet version associated with the packaged jpm (or latest).
TL;DR in this specific case it's a packager issue, https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/janet/jpm.nix already depends on the default.nix
file so it should be fairly minor modifications.
I'd submit a patch but I know relatively little about nix(os) besides typical distrodev things, but hopefully I've helped narrow it down.
In the meanwhile, you can edit the default-config.janet
yourself to point the above to the janet
nix store path.
Looks like there are a couple of contributors to the jpm.nix
file: bhankas and peterhoeg. May be if an issue is filed at the nixpkgs repository, it might be worth contacting them.
I worked around this (and a few other related items) in my project's shell.nix
by including this in my shell's buildInputs
.
(pkgs.jpm.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [ pkgs.makeWrapper ];
postInstall = "wrapProgram $out/bin/jpm --add-flags '--libpath=${pkgs.janet}/lib --ldflags=-L${pkgs.glibc}/lib --local'";
}))
@xrd Is this still an issue for you? If so, did you try mattchrist's work-around?
@xrd and @mattchrist ,
I just put together an initial version of janet2nix.
Its pretty rough right now, but it provides a flake with a working janet and jpm packages (some recent commit). It also provides helper functions for compiling a janet executable and including jpm packages.
@mattchrist , I based the jpm build on your suggestion here.
There are a lot of missing features, and my knowledge of both nix and janet is pretty shallow, but I would love to collaborate in some way to improve it if either of y'all are up for it. If so, feel free to message me on the janet zulip or open an issue to start discussing something in the janet2nix repo.
I have janet and jpm installed on nix. I'm trying to build the example program from
https://github.com/bakpakin/littleserver
I think there is an issue where the root where jpm is installed thinks it should use a janet relative to jpm, rather than the janet binary. I cannot figure out the right combination of switches to tell jpm to use janet. And, it cannot find janet.h, as is obvious from the deps/build commands below. For example, I see this as an include path, which does not exist:
-I/nix/store/hfimcza6af6qd1944ngf22xqbiayrrw6-jpm-0.0.2/include/janet
. I thought I could use some combination of--janet-cflags
or--cflags
but I'm unclear whether I use the janet one or the regular c flags. And, I wonder if there is a better way (perhaps a top level environment variable) which better configures jpm.This command needs janet.h:
So, adding
--cflags
with a correct janet include path:But, then
jpm build
does not work. I assume I need to add the correct--ldflags
or--lflags
but is there a simpler way to get all this?