Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error trying to follow steps for parcel #49

Open
goosetherumfoodle opened this issue Feb 22, 2023 · 2 comments
Open

error trying to follow steps for parcel #49

goosetherumfoodle opened this issue Feb 22, 2023 · 2 comments

Comments

@goosetherumfoodle
Copy link

goosetherumfoodle commented Feb 22, 2023

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.

      configurePhase = nixpkgs.legacyPackages.${system}.elmPackages.fetchElmDeps {
        elmVersion = "0.19.1";
        elmPackages = import ./elm-srcs.nix;
        registryDat = ./registry.dat;
      };

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 and versions.dat. (The new fetchElmDeps doesn't seem to require versions.dat, is that just no longer used?)

But running nix build throws an error during the configurePhase:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
mv: cannot copy a directory, '/build', into itself, '/build/temp'
@goosetherumfoodle goosetherumfoodle changed the title configurePhase issue error trying to follow steps for parcel Feb 25, 2023
@greglearns
Copy link

+1 Did you ever figure out how to do this with parcel? Would love to hear a solution -- trying to solve this now myself.

@sandydoo
Copy link
Member

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
        '';
      };
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants