From 2a058c998587bcdaf868865a1ec198762997d839 Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sat, 20 Jun 2026 02:09:25 -0400 Subject: [PATCH 1/6] feat(packaging): add aarch64-darwin support - Add aarch64-darwin to the systems list - Exclude ../udev from the source fileset on Darwin - Skip udev postInstall step on Darwin - Guard services.udev.packages behind !stdenv.isDarwin in module.nix - Add darwinModules.default for nix-darwin users - Expand meta.platforms to include darwin --- flake.nix | 8 ++++++++ nix/module.nix | 2 +- nix/package.nix | 23 +++++++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 0373556..d007662 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,7 @@ systems = [ "x86_64-linux" "aarch64-linux" + "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); in @@ -41,5 +42,12 @@ imports = [ ./nix/module.nix ]; programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; }; + + darwinModules.default = + { pkgs, ... }: + { + imports = [ ./nix/module.nix ]; + programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; + }; }; } diff --git a/nix/module.nix b/nix/module.nix index e77955e..72f6c35 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -19,6 +19,6 @@ in config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; - services.udev.packages = [ cfg.package ]; + services.udev.packages = lib.mkIf (!pkgs.stdenv.isDarwin) [ cfg.package ]; }; } diff --git a/nix/package.nix b/nix/package.nix index 711bb37..3838622 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -3,19 +3,22 @@ rustPlatform, pkg-config, libusb1, + stdenv, }: let fs = lib.fileset; src = fs.toSource { root = ../.; - fileset = fs.unions [ - ../Cargo.toml - ../Cargo.lock - ../zapp - ../zapp-core - ../zapp-oryx - ../udev - ]; + fileset = fs.unions ( + [ + ../Cargo.toml + ../Cargo.lock + ../zapp + ../zapp-core + ../zapp-oryx + ] + ++ lib.optional (!stdenv.isDarwin) ../udev + ); }; cargoToml = builtins.fromTOML (builtins.readFile ../zapp/Cargo.toml); in @@ -28,7 +31,7 @@ rustPlatform.buildRustPackage { nativeBuildInputs = [ pkg-config ]; buildInputs = [ libusb1 ]; - postInstall = '' + postInstall = lib.optionalString (!stdenv.isDarwin) '' install -Dm644 udev/50-zsa.rules $out/lib/udev/rules.d/50-zsa.rules ''; @@ -37,6 +40,6 @@ rustPlatform.buildRustPackage { homepage = "https://github.com/zsa/zapp"; license = lib.licenses.mit; mainProgram = "zapp"; - platforms = lib.platforms.linux; + platforms = lib.platforms.linux ++ lib.platforms.darwin; }; } From d94faede7af43ae4213358e03ccd018a8c50edf6 Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sat, 20 Jun 2026 03:03:42 -0400 Subject: [PATCH 2/6] refactor(nix): split module into platform-specific darwin/nixos modules - Replace the single nix/module.nix with nix/module/common.nix holding shared options, plus nix/module/darwin and nix/module/nixos default.nix files for platform-specific config. - The darwin module skips udev package installation, which is required for nixos. - nix/package.nix's udev rule install checks for stdenv.isLinux to install the udev rule. Signed-off-by: Alberth Matos --- flake.nix | 4 ++-- nix/module.nix | 24 ------------------------ nix/module/common.nix | 14 ++++++++++++++ nix/module/darwin/default.nix | 14 ++++++++++++++ nix/module/nixos/default.nix | 15 +++++++++++++++ nix/package.nix | 2 +- 6 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 nix/module/common.nix create mode 100644 nix/module/darwin/default.nix create mode 100644 nix/module/nixos/default.nix diff --git a/flake.nix b/flake.nix index d007662..8a6ea56 100644 --- a/flake.nix +++ b/flake.nix @@ -39,14 +39,14 @@ nixosModules.default = { pkgs, ... }: { - imports = [ ./nix/module.nix ]; + imports = [ ./nix/module/nixos ]; programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; }; darwinModules.default = { pkgs, ... }: { - imports = [ ./nix/module.nix ]; + imports = [ ./nix/module/darwin ]; programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; }; }; diff --git a/nix/module.nix b/nix/module.nix index 72f6c35..e69de29 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,24 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -let - cfg = config.programs.zapp; -in -{ - options.programs.zapp = { - enable = lib.mkEnableOption "zapp, a CLI tool for flashing ZSA keyboards"; - - package = lib.mkOption { - type = lib.types.package; - description = "The zapp package to use."; - }; - }; - - config = lib.mkIf cfg.enable { - environment.systemPackages = [ cfg.package ]; - services.udev.packages = lib.mkIf (!pkgs.stdenv.isDarwin) [ cfg.package ]; - }; -} diff --git a/nix/module/common.nix b/nix/module/common.nix new file mode 100644 index 0000000..6acc292 --- /dev/null +++ b/nix/module/common.nix @@ -0,0 +1,14 @@ +{ + lib, + ... +}: +{ + options.programs.zapp = { + enable = lib.mkEnableOption "zapp, a CLI tool for flashing ZSA keyboards"; + + package = lib.mkOption { + type = lib.types.package; + description = "The zapp package to use."; + }; + }; +} diff --git a/nix/module/darwin/default.nix b/nix/module/darwin/default.nix new file mode 100644 index 0000000..dd5b455 --- /dev/null +++ b/nix/module/darwin/default.nix @@ -0,0 +1,14 @@ +{ + config, + lib, + ... +}: +let + cfg = config.programs.zapp; +in +{ + imports = [ ../common.nix ]; + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + }; +} diff --git a/nix/module/nixos/default.nix b/nix/module/nixos/default.nix new file mode 100644 index 0000000..6921b0c --- /dev/null +++ b/nix/module/nixos/default.nix @@ -0,0 +1,15 @@ +{ + config, + lib, + ... +}: +let + cfg = config.programs.zapp; +in +{ + imports = [ ../common.nix ]; + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + services.udev.packages = [ cfg.package ]; + }; +} diff --git a/nix/package.nix b/nix/package.nix index 3838622..00b7b1f 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -31,7 +31,7 @@ rustPlatform.buildRustPackage { nativeBuildInputs = [ pkg-config ]; buildInputs = [ libusb1 ]; - postInstall = lib.optionalString (!stdenv.isDarwin) '' + postInstall = lib.optionalString stdenv.isLinux '' install -Dm644 udev/50-zsa.rules $out/lib/udev/rules.d/50-zsa.rules ''; From c30f65330de89a6a20b466ca6ba4587aaf810e96 Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sat, 20 Jun 2026 03:18:46 -0400 Subject: [PATCH 3/6] chore: Removed unused original nix/module.nix Signed-off-by: Alberth Matos --- nix/module.nix | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 nix/module.nix diff --git a/nix/module.nix b/nix/module.nix deleted file mode 100644 index e69de29..0000000 From 4fcd6af8713ec868a0af06a02bf9c29ecf21f6fa Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sat, 20 Jun 2026 03:21:42 -0400 Subject: [PATCH 4/6] docs: Updated documentation - README.md updated with details on nix-darwin support. - nix/modules/README.md explains the usage of nix/module/darwin, nix/module/nixos, and nix/module/common.nix and how they interoperate. Signed-off-by: Alberth Matos --- README.md | 20 ++++++++++++++++++++ nix/module/README.md | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 nix/module/README.md diff --git a/README.md b/README.md index 0e461a4..9e16ade 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,26 @@ On NixOS, the flake exposes a module that installs the binary and registers the } ``` +On nix-darwin, the flake exposes a module that installs the binary: + +```nix +{ + inputs.zapp.url = "github:zsa/zapp"; + + outputs = { self, nixpkgs, zapp, ... }: { + darwinConfigurations.my-host = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + zapp.darwinModules.default + { programs.zapp.enable = true; } + ]; + }; + }; +} +``` + +(Adjust nix-darwin.lib.darwinSystem to match your nix-darwin input.) + An overlay is also available (`zapp.overlays.default`) which adds `pkgs.zapp` to nixpkgs. A `nix develop` shell with the Rust toolchain and `nixfmt` is provided for hacking on the flake itself. diff --git a/nix/module/README.md b/nix/module/README.md new file mode 100644 index 0000000..585e47e --- /dev/null +++ b/nix/module/README.md @@ -0,0 +1,11 @@ +## Modules + +The flake exposes two modules: + +- `zapp.nixosModules.default` (for NixOS) +- `zapp.darwinModules.default` (for nix-darwin) + +Each are called from their respective sections in the main flake.nix. Both +modules source from nix/modules/common.nix, and only differ in how they handle +the module configuration: nixos registers a package with services.udev, while +nix-darwin does not. From 0dce8b398db4eb4af48c74feb3b9281fdb912c1b Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sat, 20 Jun 2026 03:41:02 -0400 Subject: [PATCH 5/6] docs: Updated macOS section to add detail on nix-darwin Signed-off-by: Alberth Matos --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9e16ade..0d74baf 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ You can download the latest version of zapp from the [releases](https://github.c brew install zapp ``` +nix-darwin is also supported. See the [Nix flakes](#flakes) section below for details. + ### openSUSE ```sh From 9735661b22bc6e664e689edcefa4517e406d4ce4 Mon Sep 17 00:00:00 2001 From: Alberth Matos Date: Sun, 21 Jun 2026 02:40:14 -0400 Subject: [PATCH 6/6] chore: Replaced pkgs.system with pkgs.stdenv.hostPlatform.system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix for ‘nix build’ warning: evaluation warning: 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system' Per https://discourse.nixos.org/t/how-to-fix-evaluation-warning-system-has-been-renamed-to-replaced-by-stdenv-hostplatform-system/72120, pkgs.system changed because the ‘system’ alias was dropped, so as to make it clearer which ‘system’ one is choosing (i.e. the local ‘system’) Signed-off-by: Alberth Matos --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 8a6ea56..c6544c7 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ devShells = forAllSystems (pkgs: { default = pkgs.mkShell { - inputsFrom = [ self.packages.${pkgs.system}.zapp ]; + inputsFrom = [ self.packages.${pkgs.stdenv.hostPlatform.system}.zapp ]; packages = [ pkgs.cargo pkgs.rustc @@ -40,14 +40,14 @@ { pkgs, ... }: { imports = [ ./nix/module/nixos ]; - programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; + programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default; }; darwinModules.default = { pkgs, ... }: { imports = [ ./nix/module/darwin ]; - programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.system}.default; + programs.zapp.package = nixpkgs.lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default; }; }; }