spago2nix icon indicating copy to clipboard operation
spago2nix copied to clipboard

More beginner friendly and complete example setup, please

Open magthe opened this issue 2 years ago • 4 comments

I'm struggling with setting up a derivation for my project and I think it'd be useful to have a beginner friendly (complete) example. Or maybe you have some public project using spago2nix that you can point to?

This is what I have at the moment:

{ pkgs ? import <nixpkgs> { }) }:

with pkgs;

let spagoPkgs = import ./spago-packages.nix { inherit pkgs; };

in stdenv.mkDerivation rec {
  pname = "my-frontend";
  src = lib.cleanSource ./.;
  version = "0.1";
  buildInputs = []; # what to put here??
  buildPhase = ''
    ${spagoPkgs.installSpagoStyle} # fails because it's a directory???
    ${spagoPkgs.buildSpagoStyle}
    ${spagoPkgs.buildFromNixStore}
  '';
  installPhase = ''
    echo "what would an install phase look like? 'spago bundle-app'?"
    echo "hello" > "$out/hello"
  '';
}

and it results in

❯ nix-build
these derivations will be built:
  /nix/store/snqbfnfiimbwmxx49sv52jcs3ixvxlhm-my-frontend-0.1.drv
building '/nix/store/snqbfnfiimbwmxx49sv52jcs3ixvxlhm-my-frontend-0.1.drv'...
unpacking sources
unpacking source archive /nix/store/1yyr076qh70rmkqh8s717q0sg7d48y0h-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
/nix/store/dj40kjgp5lhs55v4hc47vyrarhq4qycz-stdenv-linux/setup: line 1309: /nix/store/cdpd8vclmd9iji26qq0pd8jyd2syhndx-install-spago-style: Is a directory
builder for '/nix/store/snqbfnfiimbwmxx49sv52jcs3ixvxlhm-my-frontend-0.1.drv' failed with exit code 126
error: build of '/nix/store/snqbfnfiimbwmxx49sv52jcs3ixvxlhm-my-frontend-0.1.drv' failed

magthe avatar Aug 10 '21 09:08 magthe