-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
91 lines (80 loc) · 2.29 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# {
# description = "a simple flake that echoes hi";
#
# inputs = {
# flake-utils.url = "github:numtide/flake-utils";
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# };
#
# outputs = { nixpkgs, flake-utils, ... }:
# flake-utils.lib.eachdefaultsystem (system:
# let
# pkgs = import nixpkgs {
# inherit system;
# };
# in {
# devshell = pkgs.mkshell {
# buildinputs = [ pkgs.hello ];
# };
#
# defaultpackage = pkgs.writeshellscriptbin "say-hi" ''
# echo "hi ''${name:-there}"!
# '';
# });
# }
{
description = "Personal QMK keymaps";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: rec {
packages = {
blank = lib.mkKeymap {
keyboard = "";
keymap = "";
target = "";
extension = "";
sha = "7620c64b99dc5bec480bfaa2708cb3fae709e2b3";
};
air40 = lib.mkKeymap {
keyboard = "ymdk/ymd40/air40";
keymap = "air40";
target = "flash";
extension = "hex";
sha = "2fd56317763e8b3b73f0db7488ef42a70f5b946e";
};
default = packages.blank;
};
lib = {
mkKeymap = { keyboard, keymap, target, extension, sha }:
let
pkgs = nixpkgs.legacyPackages.${system};
name = "qmk-keymap-${keymap}";
firmware = builtins.fetchGit {
url = "https://github.com/qmk/qmk_firmware.git";
rev = sha;
submodules = true;
};
buildScript = pkgs.writeShellScriptBin name ''
echo "Hi $USER - ''${KEYMAP:-asd} ${keymap} for ${keyboard}"
realpath $0
dir="$(dirname $0)"
echo $dir
'';
in pkgs.stdenv.mkDerivation rec {
inherit name;
nativeBuildInputs = with pkgs; [ qmk git buildScript ];
src = firmware;
BUILD_DIR = src;
buildPhase = ''
mkdir -p $out/{bin,lib,share}
cp -r . "$out/lib/qmk_firmware"
'';
installPhase = ''
ln -s "${buildScript}/bin/${name}" "$out/bin/${name}"
'';
};
};
});
}