~jack/misc

misc/ergodox/default.nix -rw-r--r-- 1.9 KiB
2400b973Jack Kelly ergodox: add binds for fst/snd a month ago
                                                                                
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
{ nixpkgs ? import ../nix/nixpkgs.nix }:
let
  inherit (nixpkgs) pkgs;

  controller = pkgs.fetchFromGitHub {
    owner = "kiibohd";
    repo = "controller";
    rev = "c7fb6d1c3be29de1bcb0b9c7201448e66fb2ca33";
    sha256 = "170fz7qa6zdjs4hgal3v0h6nsh99wnscf6kd467frg5d61lyxr5g";
  };

  kll = pkgs.fetchFromGitHub {
    owner = "kiibohd";
    repo = "kll";
    rev = "2062be08e34430d523b20947e9eb5a3ec3948331";
    sha256 = "0xgg12bsg1gq3jfy7g7qyngaxq2nmzl747w1nr2nb85dvqq1mkad";
  };

  static-inline-patch = builtins.fetchurl {
    url = "https://gist.githubusercontent.com/wailashi/3f4322985c2f752bc8e76e1bfb4a127b/raw/1ecfb2bc999b0c32d6d65906873b190865f45e1b/inline_fix.patch";
    sha256 = "0cwza4cmq7knggwkn8pmw9wmranb2h053i8mn8a61g81r377lnp9";
  };
in
  pkgs.stdenv.mkDerivation rec {
    name = "ergodox-infinity-firmware";
    src = ./config;

    buildInputs = with pkgs; [
      cmake dfu-util gcc-arm-embedded gnumake git
    ];

    patches = [ static-inline-patch ];

    unpackPhase = ''
      cp -R ${controller}/* .
      cp -R ${kll} kll
      chmod -R +w .

      # Fix the interpreters
      sed -i '1c#!${pkgs.bash}/bin/bash' Lib/CMake/sizeCalculator
      sed -i '1c#!${pkgs.bash}/bin/bash' Lib/CMake/writer
      sed -i '1c#!${pkgs.python3}/bin/python3' kll/kll.py

      # Copy our config
      cp -v $src/scancode_map.kll Scan/Infinity_Ergodox
      cp -v $src/ergodox-custom.bash Keyboards
      cp -v $src/MDErgo1-Default-*.kll kll/layouts
    '';

    configurePhase = ":";

    buildPhase = ''
      cd Keyboards
      bash ergodox-custom.bash || true
    '';

    installPhase = ''
      mkdir $out
      cp ICED-L.gcc/kiibohd.dfu.bin $out/left.dfu.bin
      cp ICED-R.gcc/kiibohd.dfu.bin $out/right.dfu.bin
    '';

    meta = with pkgs.stdenv.lib; {
      description = "Firmware for my Infinity Ergodox";
      license = licenses.agpl3Plus;
      maintainers = [ maintainers.endgame ];
      platforms = platforms.all;
    };
  }