diff --git a/.gitignore b/.gitignore index 15201ac..a511eec 100644 --- a/.gitignore +++ b/.gitignore @@ -169,3 +169,6 @@ cython_debug/ # PyPI configuration file .pypirc + +# NIX +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9d47e88 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1759733170, + "narHash": "sha256-TXnlsVb5Z8HXZ6mZoeOAIwxmvGHp1g4Dw89eLvIwKVI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8913c168d1c56dc49a7718685968f38752171c3b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fef4543 --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs: + inputs.flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + + lib = pkgs.lib; + + inherit (pkgs) python3Packages; + + meshcore = python3Packages.buildPythonPackage rec { + pname = "meshcore"; + version = "2.1.9"; + pyproject = true; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-FhTOuVHhpYvmITgxfhXys8AJhRfYnMwCJ3fWJhMf53w="; + }; + + build-system = [ python3Packages.hatchling ]; + + dependencies = [ + python3Packages.bleak + python3Packages.pycayennelpp + python3Packages.pyserial-asyncio + ]; + + pythonImportsCheck = [ "meshcore" ]; + }; + + pyproject = lib.importTOML ./pyproject.toml; + version = pyproject.project.version; + in + { + packages.meshcore-cli = python3Packages.buildPythonPackage { + pname = "meshcore-cli"; + inherit version; + + src = ./.; + + pyproject = true; + + nativeBuildInputs = [ + python3Packages.hatchling + python3Packages.setuptools + python3Packages.wheel + ]; + + propagatedBuildInputs = [ + meshcore + python3Packages.click + python3Packages.prompt_toolkit + python3Packages.pyserial + python3Packages.requests + ]; + + doCheck = false; + }; + } + ); +}