How to override source?
The other day I spotted this question on Nix Discourse and thought I might help, also to learn more about node2nix. Turns out I have no idea how to do this though. What the original poster is trying to do is build umami. The normal install instructions are
git clone https://github.com/mikecao/umami.git
cd umami
npm install
The node2nix equivalent is to replace npm install with just node2nix, which generates the usual files. Running nix-build then complained about node-pre-gyp missing. That was easy to solve though with override.nix and buildInputs. But now one of the dependencies for umami is trying to download something in its postinstall.js step. My idea was to simply overwrite/remove this file and perform the downloading through Nix. But how can I override a source?
This is the entry in node-packages.nix I want to override
3211 │ "geolite2-redist-1.0.7" = {
3212 │ name = "geolite2-redist";
3213 │ packageName = "geolite2-redist";
3214 │ version = "1.0.7";
3215 │ src = fetchurl {
3216 │ url = "https://registry.npmjs.org/geolite2-redist/-/geolite2-redist-1.0.7.tgz";
3217 │ sha512 = "NrsPDYUU7OVTtZzj5McnBI7b2n8teS+zgX3IXSd3qxF9M2OaDA4SeF1loWzDyzkQzPFr8JHEYYIBTD0sQGQ7ug==";
3218 │ };
3219 │ };
There's this issue #195 about overriding sources which makes me think that there's currently no easy mechanism for this.
Sorry if I'm missing something obvious I'm still more or less a Nix beginner.
Similarly, I have the use-case of javascript sources which are generated by nix. Right now I:
- Build the JS sources
- Run
node2nix - Edit the result to use nix expression rather than refer to generate sources as a
FileSource
This works but is ugly and tedious.
I've just started learning Nix the past week and am evaluating if it can improve the build process for js/ts frontend and node projects. As a test, I'm trying to build a well known public repo: The Ghost blogging platform.
I started with the package.json here: https://github.com/TryGhost/Ghost/blob/a3215a6edf6bce8c2d7e3db18e15320489f5b1f4/package.json
I ended up with the same error at the "sharp" dep.
I tried fiddling with overrides based on various conversations I've seen but have no idea what to do here.
I assume I need a preRebuild that will separately build this package, which will require me diving deeper into Nix to figure out how to make it a pure build itself.
I'd recommend that people see if they can use https://github.com/nix-community/npmlock2nix/ since it's simpler, with fewer features and seems better maintained at the moment