nathanregner / platformio2nix

1 stars 1 forks source link

Question: packaging a platformio project that doesn't use a Makefile #6

Open crabdancing opened 3 days ago

crabdancing commented 3 days ago

So far, I've figured out that to use platformio2nix, I have to manually write my own buildPhase/patchPhase/etc. As it stands, if I try to call pio run -t build, like so:

{
  gnumake,
  makePlatformIOSetupHook,
  platformio,
  stdenv,
  which,
}: let
  setupHook = makePlatformIOSetupHook {
    lockfile = ./platformio2nix.lock;
  };
in
  stdenv.mkDerivation {
    name = "my-project";
    version = "0.0.0";
    src = ./.;
    nativeBuildInputs = [platformio setupHook];

    buildPhase = ''
      pio run -t build
    '';
  }

The result is that PlatformIO immediately tries to connect to the internet, fails, and throws a fit:

       > --------------------------------------------------------------------------------
       > Library Manager: Installing askuric/Simple FOC @ ^2.3.4
       > InternetConnectionError: You are not connected to the Internet.
       > PlatformIO needs the Internet connection to download dependent packages or to work with PlatformIO Account.
       For full logs, run 'nix log /nix/store/q0mhvwcjlhzhnai56alwzhwcx3qwldhw-my-project.drv'.

So there's something special I have to do to get the dependencies fetched by Nix via platformio2nix to be used by pio?

nathanregner commented 2 days ago

Hmm, you shouldn't have to do anything special. The setupHook will set the PLATFORMIO_CORE_DIR environment variable to a path in the build dir, which should take care of things. My guess is the dependency isn't in the lockfile or there's a bug linking dependencies in setupHook. Do you have an example repo?