DISCLAIMER: I stopped reading the nix pills halfway through chapter 12 due to a hangup, so my knowledge about how nix works is likely incomplete.
I want to package lokke for personal use and don’t understand what I am doing wrong. These are my build files.
The first problem I run into is that git is unable to resolve github.com. The command I am executing is nix-build lokke.nix
these derivations will be built:
Cloning into '/nix/store/4h6b2fwapbqarfljnlv70ddkyhjnxyn6-lokke'...
fatal: unable to access 'https://github.com/lokke-org/lokke.git/': Could not resolve host: github.com
builder for '/nix/store/yw9r05x3vs3bqh9bgwgknaaym6is12wx-lokke.drv' failed with exit code 128
error: build of '/nix/store/yw9r05x3vs3bqh9bgwgknaaym6is12wx-lokke.drv' failed
Exception: nix-build exited with 100
[tty 15], line 1: nix-build lokke.nix
Thanks @NobbZ ! Your advice has resulted in strong progress.
These are the build files now. Can’t believe how much shorter it is.
I have several questions.
fetchGit removes the .git directory, which requires the build script to git init .. This is necessary b/c the setup script needs it in order to run. Can I instead somehow instruct fetchGit to leave the repo intact?
nix-build lokke.nix can’t seem to find setup.sh, so I am just using nix-shell lokke.nix for now. In a previous exercise I didn’t have to specify all of the build scripts in order for them to be copied into the store. Wat do?
nix-shell exits upon any failure. How do I tell it not to do this?
This is the important one. ./configure gives this error:
./configure: line 5590: syntax error near unexpected token `PCRE2,'
./configure: line 5590: `PKG_CHECK_MODULES(PCRE2, libpcre2-8 libpcre2-32)'
Exception: nix-shell exited with 2
[tty 10], line 1: nix-shell lokke.nix
As said, working with git mechanisms does not go well within nix. The fact that installation procedures want do all kind of weird side effects is just sad (albeit understandable in a world without more principled alternatives), and the quickest way to go is patching it out. Search for patchPhase in the nixpkgs manual (sorry, no keyboard right now, otherwise I’d just give you the link). In your case that should be fairly straightforward, since it’s just some path filtering and renaming. The correct, long-term-oriented, good-internet-citizen way to do it is of course talking to maintainers and develop a pure solution upstream. I feel your pain, recently I’ve been fighting a bunch of CMake builds that try to fetch their own dependencies with git…
The reason is that specifying ./builder.sh will copy that file to /nix/store and your relative path to ./setup.sh will point nowhere from there. I think it would be easiest to specify your custom build steps in the preConfigurePhase field for stdenv.mkDerivation, again please check the manual. You’re trying to do the same, technically, it’s just much more tedious since we already have all the convenience layers from nixpkgs.
I keep repeating it to newcomers, but the Nix Pills are absolutely unsuitable for beginners, as they are too low-level to do anything useful with that knowledge. The manuals are much better suited, but still need a lot of work. @daf it’s absolutely not your fault to be confused. You’ve invested significant amount of effort, and asked a highly informed question. Bad luck you picked a rocky path because it was on the front page.
Funnily all the information is somehow out there, it just takes tons of time to scrape it together and synthesize something coherent in your head. For example look at this person literally reading the manuals back to back trying to make sense of everything.
It’s an entertaining an informative read, but in a sense perpetuates the problem by being a more useful resource than the manual. So if anyone reading this wants to contribute to improving the manual, please drop me a message or ping me in your pull request. I’ll be glad to help with answering questions or reviewing. I didn’t manage to start out on my own in over a year, as there are only few itches to scratch left for myself, time is limited, and, you know, priorities…
Thanks, @NobbZ & @fricklerhandwerk. Based on your advice regarding the first question I have decided to go with the current approach. I could write a replacement script for git ls-files … probably, but tbh ls-files seems extremely harmless so…
The reason is that specifying ./builder.sh will copy that file to /nix/store and your relative path to ./setup.sh will point nowhere from there.
Thanks, @fricklerhandwerk. This explanation led me to assign ./setup to a key in the map passed to stdenv.mkDerivation.
How do you invoke the shell? Though are you sure you build the configure script correctly?
nix-shell lokke.nix. However, I have recently renamed the file to default.nix, so now I invoke the shell w/ simply nix-shell. I am following the build instructions on the README as closely as possible.
These are the build files now.
I discovered that pkg-config was needed for the PCRE2 config issue, but now I am seeing a similar issue with the configuration script.This is being invoked from within nix-shell by calling configurePhase, which is part of the stdenv.mkDerivation script.
./configure: line 14058: syntax error near unexpected token `3.0'
./configure: line 14058: `GUILE_PKG(3.0 2.2)'