Skip to content

Packaging with Nix #528

@pizzapim

Description

@pizzapim

I am trying to package Inbucket using Nix, but I am running into some problems. Packaging the Go backend has been a breeze but I have not been able to package the Yarn frontend yet. Seeing as @jhillyerd is a Nix enthusiast as well, maybe you have tried this already as well?

This is what I have right now:

  pkgs.mkYarnPackage (
    let
      src = pkgs.fetchFromGitHub {
        owner = "inbucket";
        repo = "inbucket";
        rev = "v${version}";
        hash = "sha256-hbNP2ajkaxl3FlGhPEtHnNj0VpbGe4JiqsnbAu1vm5U=";
      };
    in
    {
      inherit version;
      src = "${src}/ui";
      pname = "inbucket-ui";

      offlineCache = pkgs.fetchYarnDeps {
        sha256 = "sha256-JiCW35udb3wjpPGY1W1cmQwD/rX/Q++iHGaYBK5hrs0=";
      };

      configurePhase = ''
        runHook preConfigure
        ln -s $node_modules node_modules
        runHook postConfigure
      '';

      buildPhase = ''
        runHook preBuild

        export HOME=$(mktemp -d)
        yarn --offline run build

        runHook postBuild
      '';

      installPhase = ''
        runHook preInstall

        mkdir -p $out/dist
        cp -r dist/** $out/dist

        runHook postInstall
      '';

      doDist = false;
    }
  );

Unfortunately this results in the following error:

$ nix-build package.nix                                                                                                                                                                                                                 
this derivation will be built:
  /nix/store/fpwfvz8ar50b600zw4jzb0afi2rzlyln-inbucket-ui-3.0.4.drv
building '/nix/store/fpwfvz8ar50b600zw4jzb0afi2rzlyln-inbucket-ui-3.0.4.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/v9hskiqcn5g38124yg3vcir7c036p310-source/ui
source root is ui
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
Running phase: buildPhase
yarn run v1.22.22
$ parcel build --public-url ./
Error: No native build was found for platform=linux arch=x64 runtime=node abi=115 uv=1 libc=glibc node=20.15.1
    loaded from: /nix/store/az1h90fbhvwwxpyfrnxcxqvbvkk1vdym-inbucket-ui-modules-3.0.4/node_modules/lmdb

I know next to nothing about Yarn and the whole JavaScript ecosystem so I might be missing something obvious here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions