I’m trying out Nix for my Elm app that I build with Parcel. I’m however getting the following error when trying to nix build
:
npm ERR! Downloading Elm 0.19.1 from GitHub.
npm ERR!
npm ERR! NOTE: You can avoid npm entirely by downloading directly from:
npm ERR! https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
npm ERR! All this package does is download that file and put it somewhere.
npm ERR!
npm ERR! --------------------------------------------------------------------------------
npm ERR! -- ERROR -----------------------------------------------------------------------
npm ERR!
npm ERR! Something went wrong while fetching the following URL:
npm ERR!
npm ERR! https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
npm ERR!
npm ERR! It is saying:
npm ERR!
npm ERR! Error: getaddrinfo EAI_AGAIN github.com
From my understanding it’s saying Error: getaddrinfo EAI_AGAIN github.com
because nix-build works in a sandbox and doesn’t allow downloading files as this would not be reproducible. Which makes sense.
To build this, in my flake.nix I have:
packages.default = pkgs.buildNpmPackage {
name = "elmder";
buildInputs = with pkgs; [
nodejs_18
];
src = ./.;
npmDepsHash = "sha256-SvlklTgqGSoDyjlHRIjlhBuB4dyYl4Ro1Sc2aBgx76I=";
npmBuild = "npm run build";
installPhase = ''
mkdir $out
cp -r dist/ $out
'';
};
And my package.json has:
"devDependencies": {
"@parcel/packager-raw-url": "^2.8.3",
"@parcel/transformer-elm": "^2.8.3",
"@parcel/transformer-sass": "^2.8.3",
"@parcel/transformer-webmanifest": "^2.8.3",
"parcel": "^2.8.3"
},
To fix this I tried to install Elm directly through nix, by adding elmPackages.elm
in my buildInputs
. But that didn’t change anything, I assume because @parcel/transformer-elm
has elm as a peerDependency so it still tries to install it through npm (and that just downloads the elm binary into node_modules).
I also read there is a way of disabling the nix sandbox, then the download would be possible, but I don’t want to do that really.
Has anybody experienced this problem before? And is there a good way of fixing it?