diff --git a/pkgs/development/embedded/platformio/chrootenv.nix b/pkgs/development/embedded/platformio/chrootenv.nix index 18bcfdb9b8b7..dd3da78250a2 100644 --- a/pkgs/development/embedded/platformio/chrootenv.nix +++ b/pkgs/development/embedded/platformio/chrootenv.nix @@ -1,9 +1,9 @@ -{ lib, buildFHSUserEnv, version, src }: +{ lib, buildFHSUserEnv, platformio-core }: let pio-pkgs = pkgs: let - python = pkgs.python3; + inherit (platformio-core) python; in (with pkgs; [ platformio-core @@ -35,10 +35,8 @@ buildFHSUserEnv { }; extraInstallCommands = '' - mkdir -p $out/lib/udev/rules.d - ln -s $out/bin/platformio $out/bin/pio - ln -s ${src}/platformio/assets/system/99-platformio-udev.rules $out/lib/udev/rules.d/99-platformio-udev.rules + ln -s ${platformio-core.udev}/lib $out/lib ''; runScript = "platformio"; diff --git a/pkgs/development/embedded/platformio/core.nix b/pkgs/development/embedded/platformio/core.nix index 00ee07a5fc5b..81ad2354c99a 100644 --- a/pkgs/development/embedded/platformio/core.nix +++ b/pkgs/development/embedded/platformio/core.nix @@ -3,12 +3,22 @@ , fetchPypi , git , spdx-license-list-data -, version, src }: with python3.pkgs; buildPythonApplication rec { pname = "platformio"; - inherit version src; + + version = "6.1.6"; + + # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964 + src = fetchFromGitHub { + owner = "platformio"; + repo = "platformio-core"; + rev = "v${version}"; + sha256 = "sha256-BEeMfdmAWqFbQUu8YKKrookQVgmhfZBqXnzeb2gfhms="; + }; + + outputs = [ "out" "udev" ]; patches = [ ./fix-searchpath.patch @@ -60,6 +70,13 @@ with python3.pkgs; buildPythonApplication rec { pytestCheckHook ]; + # Install udev rules into a separate output so all of platformio-core is not a dependency if + # you want to use the udev rules on NixOS but not install platformio in your system packages. + postInstall = '' + mkdir -p $udev/lib/udev/rules.d/99-platformio-udev.rules + cp platformio/assets/system/99-platformio-udev.rules $udev/lib/udev/rules.d/99-platformio-udev.rules + ''; + disabledTestPaths = [ "tests/commands/pkg/test_install.py" "tests/commands/pkg/test_list.py" @@ -145,6 +162,10 @@ with python3.pkgs; buildPythonApplication rec { "test_pkgmanifest.py::test_packages" ]); + passthru = { + python = python3; + }; + meta = with lib; { description = "An open source ecosystem for IoT development"; homepage = "https://platformio.org"; diff --git a/pkgs/development/embedded/platformio/default.nix b/pkgs/development/embedded/platformio/default.nix index fbcce7eae60e..956d7dee06cd 100644 --- a/pkgs/development/embedded/platformio/default.nix +++ b/pkgs/development/embedded/platformio/default.nix @@ -3,20 +3,10 @@ let callPackage = newScope self; - version = "6.1.6"; - - # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964 - src = fetchFromGitHub { - owner = "platformio"; - repo = "platformio-core"; - rev = "v${version}"; - sha256 = "sha256-BEeMfdmAWqFbQUu8YKKrookQVgmhfZBqXnzeb2gfhms="; - }; - self = { - platformio-core = python3Packages.callPackage ./core.nix { inherit version src; }; + platformio-core = python3Packages.callPackage ./core.nix { }; - platformio-chrootenv = callPackage ./chrootenv.nix { inherit version src; }; + platformio-chrootenv = callPackage ./chrootenv.nix { }; }; in diff --git a/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch b/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch index 2a978496a19b..4be06ceac8b1 100644 --- a/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch +++ b/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch @@ -6,7 +6,5 @@ index ef1d3bab..445174fc 100644 MESSAGE = ( "Warning! Please install `99-platformio-udev.rules`. \nMore details: " "https://docs.platformio.org/en/latest/core/installation/udev-rules.html" -+ "On NixOS add the platformio package to services.udev.packages" ++ "On NixOS add the platformio-core.udev package to services.udev.packages" ) - -