From 1fd8b1497a848247c63b7d74adf6a89db467cea9 Mon Sep 17 00:00:00 2001 From: aviac Date: Fri, 13 Feb 2026 09:35:36 +0100 Subject: [PATCH 1/4] build(nix): add nix flake so NixOS users can use the CLI --- .gitignore | 3 +++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 563ff66..109674e 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,6 @@ cython_debug/ # VS Code settings .vscode/launch.json + +# nix related +result* diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cf1abde --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1772624091, + "narHash": "sha256-QKyJ0QGWBn6r0invrMAK8dmJoBYWoOWy7lN+UHzW1jc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "80bdc1e5ce51f56b19791b52b2901187931f5353", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1772328832, + "narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0e249fa --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "The CLI tool for ZMK"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { + self', + pkgs, + ... + }: + let + python = pkgs.python3Packages; + in + { + packages.default = self'.packages.zmk-cli; + packages.zmk-cli = python.buildPythonPackage (finalAttrs: { + pname = "zmk"; + version = "0.4.0"; + src = ./.; + + pyproject = true; + + # basically required for all python packages + build-system = [ + python.setuptools + python.setuptools-scm + ]; + + # This is required since some deps in the nixpkgs python + # distribution are slightly too old. But this should be resolved + # fairly soon + # + # At the time of writing this we have + # + # > Checking runtime dependencies for zmk-0.4.0-py3-none-any.whl + # > - dacite<2.0.0,>=1.9.2 not satisfied by version 1.9.1 + # > - mako<2.0.0,>=1.3.10 not satisfied by version 1.3.10.dev0 + # > - ruamel-yaml<0.19.0,>=0.18.17 not satisfied by version 0.18.16 + pythonRelaxDeps = true; + + # those were infered by just building the package, the check phase + # will inform you about missing deps if any new ones should pop up + dependencies = [ + python.dacite + python.giturlparse + python.mako + python.rich + python.ruamel-yaml + python.shellingham + python.typer + python.west + ]; + }); + }; + }; +} From 1efe8e43dedeb421aac3fff2ed9130de0f0ce7a9 Mon Sep 17 00:00:00 2001 From: aviac Date: Fri, 6 Mar 2026 09:05:58 +0100 Subject: [PATCH 2/4] chore(fmt): format pyproject.toml ... sort keys alphabetically --- pyproject.toml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index be9ea13..eb75bba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,4 @@ [project] -name = "zmk" -description = "A command line program to help set up ZMK Firmware" -readme = "README.md" -requires-python = ">=3.11" -license-files = ["LICENSE"] classifiers = [ "Development Status :: 3 - Alpha", "Environment :: Console", @@ -24,31 +19,32 @@ dependencies = [ "typer >= 0.21.0, < 0.22.0", "west >= 1.5.0, < 2.0.0", ] +description = "A command line program to help set up ZMK Firmware" dynamic = ["version"] +license-files = ["LICENSE"] +name = "zmk" +readme = "README.md" +requires-python = ">=3.11" [project.urls] -Chat = "https://zmk.dev/community/discord/invite" -Documentation = "https://zmk.dev/docs" +Chat = "https://zmk.dev/community/discord/invite" +Documentation = "https://zmk.dev/docs" "Issue Tracker" = "https://github.com/zmkfirmware/zmk-cli/issues/" -"Source Code" = "https://github.com/zmkfirmware/zmk-cli/" +"Source Code" = "https://github.com/zmkfirmware/zmk-cli/" [project.scripts] zmk = "zmk.main:app" [dependency-groups] -dev = [ - "prek>=0.3.3", - "pyright>=1.1.408", - "ruff>=0.15.2", -] +dev = ["prek>=0.3.3", "pyright>=1.1.408", "ruff>=0.15.2"] [build-system] -requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" +requires = ["setuptools", "setuptools-scm"] [tool.pyright] +venv = ".venv" venvPath = "." -venv = ".venv" [tool.ruff.lint] select = [ @@ -99,7 +95,7 @@ select = [ # flake8-type-checking "TC", # pyupgrade - "UP" + "UP", ] [tool.setuptools] From be3a14756c5fb731a88636d439f4bcc34e1f1abc Mon Sep 17 00:00:00 2001 From: aviac Date: Fri, 6 Mar 2026 09:18:19 +0100 Subject: [PATCH 3/4] feat(nix): source build information from pyproject.toml --- flake.nix | 73 +++++++++++++++++++++++++++----------------------- pyproject.toml | 3 ++- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/flake.nix b/flake.nix index 0e249fa..848d46a 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ perSystem = { self', + lib, pkgs, ... }: @@ -26,44 +27,48 @@ in { packages.default = self'.packages.zmk-cli; - packages.zmk-cli = python.buildPythonPackage (finalAttrs: { - pname = "zmk"; - version = "0.4.0"; - src = ./.; + packages.zmk-cli = + let + pyprojectToml = lib.importTOML ./pyproject.toml; + in + python.buildPythonPackage (finalAttrs: { + pname = pyprojectToml.project.name; + version = pyprojectToml.project.version; + src = ./.; - pyproject = true; + pyproject = true; - # basically required for all python packages - build-system = [ - python.setuptools - python.setuptools-scm - ]; + # basically required for all python packages + build-system = [ + python.setuptools + python.setuptools-scm + ]; - # This is required since some deps in the nixpkgs python - # distribution are slightly too old. But this should be resolved - # fairly soon - # - # At the time of writing this we have - # - # > Checking runtime dependencies for zmk-0.4.0-py3-none-any.whl - # > - dacite<2.0.0,>=1.9.2 not satisfied by version 1.9.1 - # > - mako<2.0.0,>=1.3.10 not satisfied by version 1.3.10.dev0 - # > - ruamel-yaml<0.19.0,>=0.18.17 not satisfied by version 0.18.16 - pythonRelaxDeps = true; + # This is required since some deps in the nixpkgs python + # distribution are slightly too old. But this should be resolved + # fairly soon + # + # At the time of writing this we have + # + # > Checking runtime dependencies for zmk-0.4.0-py3-none-any.whl + # > - dacite<2.0.0,>=1.9.2 not satisfied by version 1.9.1 + # > - mako<2.0.0,>=1.3.10 not satisfied by version 1.3.10.dev0 + # > - ruamel-yaml<0.19.0,>=0.18.17 not satisfied by version 0.18.16 + pythonRelaxDeps = true; - # those were infered by just building the package, the check phase - # will inform you about missing deps if any new ones should pop up - dependencies = [ - python.dacite - python.giturlparse - python.mako - python.rich - python.ruamel-yaml - python.shellingham - python.typer - python.west - ]; - }); + # those were infered by just building the package, the check phase + # will inform you about missing deps if any new ones should pop up + dependencies = [ + python.dacite + python.giturlparse + python.mako + python.rich + python.ruamel-yaml + python.shellingham + python.typer + python.west + ]; + }); }; }; } diff --git a/pyproject.toml b/pyproject.toml index eb75bba..8fe50e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,11 +20,12 @@ dependencies = [ "west >= 1.5.0, < 2.0.0", ] description = "A command line program to help set up ZMK Firmware" -dynamic = ["version"] license-files = ["LICENSE"] name = "zmk" readme = "README.md" requires-python = ">=3.11" +version = "0.4.0" +# dynamic = ["version"] [project.urls] Chat = "https://zmk.dev/community/discord/invite" From 5ac3e67aa2cdbf16aa75c200338b759811790460 Mon Sep 17 00:00:00 2001 From: aviac Date: Fri, 6 Mar 2026 09:29:53 +0100 Subject: [PATCH 4/4] feat(nix): create dev shell with zmk-cli ready for use --- flake.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/flake.nix b/flake.nix index 848d46a..59dba06 100644 --- a/flake.nix +++ b/flake.nix @@ -69,6 +69,16 @@ python.west ]; }); + devShells.default = self'.devShells.zmk-cli; + devShells.zmk-cli = pkgs.mkShell { + name = "zmk-cli dev shell"; + packages = [ + self'.packages.zmk-cli + # `zmk-cli` starts `west` processes so we need it to be available + # in the shell environment + python.west + ]; + }; }; }; }