Skip to content

Commit cab52a3

Browse files
committed
Turn qmk_firmware into a flake input
1 parent d364f40 commit cab52a3

5 files changed

Lines changed: 44 additions & 13 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ Waiting for Teensy device...
8585

8686
## Notes
8787

88+
- You can change the version of `qmk_firmware` used by nixcaps by overriding its `qmk_firmware` flake input as follows:
89+
90+
```nix
91+
nixcaps.inputs.qmk_firmware.url = "git+https://github.com/qmk/qmk_firmware?submodules=1&rev=<COMMIT_SHA>";
92+
```
93+
8894
- Under the hood, this derivation first copies the files in `src` into `keyboards/<keyboard>/keymaps/nixcaps` inside an internal copy of the `qmk_firmware` repo, and then executes `qmk compile --keyboard <keyboard>[/<variant>] --keymap nixcaps`.
8995

9096
- While it should be possible to flash the compiled firmwares using `qmk flash`, this command is only available while inside the `qmk_firmware` repo. So, it is not enough to provide such a derivation with just the compiled firmware, and one would have to copy the entire (or a large part of) the `qmk_firmware` repo as well. If you know how to implement this in an efficient way, let me know!

flake.lock

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44
inputs = {
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
7+
qmk_firmware = {
8+
url = "git+https://github.com/qmk/qmk_firmware?submodules=1&rev=54e8fad959d6a6e53e08c62ac3a3c4d4bdc6c957";
9+
flake = false;
10+
};
711
};
812

913
outputs =
10-
{ nixpkgs, flake-utils, ... }:
14+
{
15+
nixpkgs,
16+
flake-utils,
17+
qmk_firmware,
18+
...
19+
}:
1120
(flake-utils.lib.eachDefaultSystem (
1221
system:
1322
let
1423
pkgs = nixpkgs.legacyPackages.${system};
15-
nixcaps = pkgs.callPackage ./nixcaps.nix { };
24+
nixcaps = pkgs.callPackage ./nixcaps.nix { inherit qmk_firmware; };
1625
in
1726
{
18-
packages = { inherit (nixcaps) compile qmk_firmware; };
27+
packages = { inherit (nixcaps) compile; };
1928
formatter = pkgs.nixfmt-rfc-style;
2029
}
2130
))

nixcaps.nix

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
{
2+
qmk_firmware,
23
qmk,
3-
fetchFromGitHub,
44
stdenv,
55
writeShellScriptBin,
66
symlinkJoin,
77
lib,
88
}:
9-
rec {
10-
qmk_firmware = fetchFromGitHub {
11-
owner = "qmk";
12-
repo = "qmk_firmware";
13-
rev = "0.30.3";
14-
sha256 = "sha256-lM5B9xl7sSxGhI/fbS0ys22t5oVUp8aMLI4pzICEKHk=";
15-
fetchSubmodules = true;
16-
};
9+
{
1710
compile =
1811
{
1912
keyboard,

templates/ergodox_ez/flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
77
nixcaps.url = "github:agustinmista/nixcaps/main";
8+
# Uncomment the next line if you want to use a specific revision of
9+
# qmk_firmware. Just make sure not to remove the submodules=1 part.
10+
# nixcaps.inputs.qmk_firmware.url = "git+https://github.com/qmk/qmk_firmware?submodules=1&rev=54e8fad959d6a6e53e08c62ac3a3c4d4bdc6c957";
811
};
912

1013
outputs =

0 commit comments

Comments
 (0)