shell.nix 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. let
  2. # We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example.
  3. sources = import ./util/nix/sources.nix { };
  4. in
  5. # However, if you want to override Niv's inputs, this will let you do that.
  6. { pkgs ? import sources.nixpkgs { }
  7. , poetry2nix ? pkgs.callPackage (import sources.poetry2nix) { }
  8. , avr ? true
  9. , arm ? true
  10. , teensy ? true }:
  11. with pkgs;
  12. let
  13. avrlibc = pkgsCross.avr.libcCross;
  14. avr_incflags = [
  15. "-isystem ${avrlibc}/avr/include"
  16. "-B${avrlibc}/avr/lib/avr5"
  17. "-L${avrlibc}/avr/lib/avr5"
  18. "-B${avrlibc}/avr/lib/avr35"
  19. "-L${avrlibc}/avr/lib/avr35"
  20. "-B${avrlibc}/avr/lib/avr51"
  21. "-L${avrlibc}/avr/lib/avr51"
  22. ];
  23. # Builds the python env based on nix/pyproject.toml and
  24. # nix/poetry.lock Use the "poetry update --lock", "poetry add
  25. # --lock" etc. in the nix folder to adjust the contents of those
  26. # files if the requirements*.txt files change
  27. pythonEnv = poetry2nix.mkPoetryEnv {
  28. projectDir = ./util/nix;
  29. overrides = poetry2nix.overrides.withDefaults (self: super: {
  30. qmk = super.qmk.overridePythonAttrs(old: {
  31. # Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes
  32. # $PATH and breaks these invocations).
  33. dontWrapPythonPrograms = true;
  34. });
  35. });
  36. };
  37. in
  38. mkShell {
  39. name = "qmk-firmware";
  40. buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv poetry niv ]
  41. ++ lib.optional avr [
  42. pkgsCross.avr.buildPackages.binutils
  43. pkgsCross.avr.buildPackages.gcc8
  44. avrlibc
  45. avrdude
  46. ]
  47. ++ lib.optional arm [ gcc-arm-embedded ]
  48. ++ lib.optional teensy [ teensy-loader-cli ];
  49. AVR_CFLAGS = lib.optional avr avr_incflags;
  50. AVR_ASFLAGS = lib.optional avr avr_incflags;
  51. shellHook = ''
  52. # Prevent the avr-gcc wrapper from picking up host GCC flags
  53. # like -iframework, which is problematic on Darwin
  54. unset NIX_CFLAGS_COMPILE_FOR_TARGET
  55. '';
  56. }