From c6fbdc3c5fd3bb2b60b60268b69b59d7028725d5 Mon Sep 17 00:00:00 2001 From: urob <978080+urob@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:56:03 -0400 Subject: [PATCH] Add keymap drawer binary --- .envrc | 1 + flake.lock | 20 +++++++++++++++++--- flake.nix | 6 ++++-- keymap_drawer.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 keymap_drawer.nix diff --git a/.envrc b/.envrc index 585508c..19c420a 100644 --- a/.envrc +++ b/.envrc @@ -3,3 +3,4 @@ export DIRENV_LOG_FORMAT=$'\033[2mdirenv: %s\033[0m' # Use flake use flake +watch_file keymap_drawer.nix diff --git a/flake.lock b/flake.lock index 9ba4c31..0fa274d 100644 --- a/flake.lock +++ b/flake.lock @@ -50,6 +50,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1723400035, + "narHash": "sha256-WoKZDlBEdMhP+hjquBAh0BhUJbcH2+U8g2mHOr1mv8I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a731b45590a5169542990c36ffcde6cebd9a3356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1720535198, "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", @@ -114,9 +130,7 @@ }, "zephyr-nix": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs_2", "pyproject-nix": "pyproject-nix", "zephyr": [ "zephyr" diff --git a/flake.nix b/flake.nix index b7545d7..87fe090 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { inputs = { # Pin this to 23.11 to provide py3.8 needed for the sdk-ng without building it ourselves - nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; # Zephyr version determining which requirements.txt to use to install python dependencies zephyr.url = "github:zephyrproject-rtos/zephyr/v3.5.0"; @@ -9,7 +9,7 @@ # Zephyr sdk and host tools zephyr-nix.url = "github:urob/zephyr-nix"; - zephyr-nix.inputs.nixpkgs.follows = "nixpkgs"; + # zephyr-nix.inputs.nixpkgs.follows = "nixpkgs"; zephyr-nix.inputs.zephyr.follows = "zephyr"; }; @@ -19,10 +19,12 @@ devShells = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; zephyr = zephyr-nix.packages.${system}; + keymap_drawer = pkgs.python3Packages.callPackage ./keymap_drawer.nix { }; in { default = pkgs.mkShell { packages = [ + keymap_drawer zephyr.hosttools-nix zephyr.pythonEnv (zephyr.sdk.override { targets = [ "arm-zephyr-eabi" ]; }) diff --git a/keymap_drawer.nix b/keymap_drawer.nix new file mode 100644 index 0000000..c43da62 --- /dev/null +++ b/keymap_drawer.nix @@ -0,0 +1,46 @@ +{ + lib, + buildPythonApplication, + fetchPypi, + poetry-core, + pydantic, + pcpp, + pyparsing, + pyyaml, + platformdirs, + pydantic-settings, +}: +buildPythonApplication rec { + pname = "keymap-drawer"; + version = "0.18.0"; + pyproject = true; + + src = fetchPypi { + pname = "keymap_drawer"; + inherit version; + hash = "sha256-faJB+cjj740Ny2wqVwc5t/+grEWBIEyhex3RoLCuIs8="; + }; + + postPatch = '' + substituteInPlace pyproject.toml --replace 'platformdirs = "^3.5.1"' 'platformdirs = "^4.0.0"' + ''; + + build-system = [poetry-core]; + + propagatedBuildInputs = [ + pydantic + pcpp + pyparsing + pyyaml + platformdirs + pydantic-settings + ]; + + doCheck = false; + + meta = { + homepage = "https://github.com/caksoylar/keymap-drawer"; + description = "Parse QMK & ZMK keymaps and draw them as vector graphics"; + license = lib.licenses.mit; + }; +}