Open goosetherumfoodle opened 1 year ago
+1 Did you ever figure out how to do this with parcel? Would love to hear a solution -- trying to solve this now myself.
Here's an example of how to get a build with the current versions of parcel and yarn2nix:
{
description = "A very basic flake";
outputs = { self, nixpkgs }: {
# A dev shell to use elm2nix
devShells.aarch64-linux.default =
let pkgs = nixpkgs.legacyPackages.aarch64-linux;
in pkgs.mkShell {
packages = [ pkgs.elm2nix ];
};
packages.aarch64-linux.default =
let
pkgs = nixpkgs.legacyPackages.aarch64-linux;
yarnPkg = pkgs.mkYarnPackage {
name = "myproject-node-packages";
src = pkgs.lib.cleanSourceWith {
src = ./.;
name = "myproject-node-packages.json";
filter = name: type: baseNameOf (toString name) == "package.json";
};
yarnLock = ./yarn.lock;
publishBinsFor = ["parcel"];
};
in pkgs.stdenv.mkDerivation {
name = "myproject-frontend";
src = pkgs.lib.cleanSource ./.;
buildInputs = with pkgs.elmPackages; [
elm
elm-format
yarnPkg
pkgs.yarn
];
patchPhase = ''
rm -rf elm-stuff
ln -sf ${yarnPkg}/node_modules .
'';
shellHook = ''
ln -fs ${yarnPkg}/node_modules .
'';
configurePhase = pkgs.elmPackages.fetchElmDeps {
elmPackages = import ./elm-srcs.nix;
elmVersion = "0.19.1";
registryDat = ./registry.dat;
};
installPhase = ''
mkdir -p $out
parcel build index.html --dist-dir $out
'';
};
};
}
I have a barebones elm app I'm trying to build with parcel using the steps in the readme here. I had to update the fetchElmDeps attributes as the readme was outdated.
I then followed the steps at https://blog.hercules-ci.com/elm/2019/01/03/elm2nix-0.1/ to generate
elm-srcs.nix
,registry.dat
andversions.dat
. (The new fetchElmDeps doesn't seem to requireversions.dat
, is that just no longer used?)But running
nix build
throws an error during the configurePhase: