You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

3 years ago
  1. { avr ? true, arm ? true, teensy ? true }:
  2. let
  3. # We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example.
  4. sources = import ./nix/sources.nix {};
  5. pkgs = import sources.nixpkgs {};
  6. # Builds the python env based on nix/pyproject.toml and
  7. # nix/poetry.lock Use the "poetry update --lock", "poetry add
  8. # --lock" etc. in the nix folder to adjust the contents of those
  9. # files if the requirements*.txt files change
  10. pythonEnv = pkgs.poetry2nix.mkPoetryEnv {
  11. projectDir = ./nix;
  12. };
  13. in
  14. with pkgs;
  15. let
  16. avrlibc = pkgsCross.avr.libcCross;
  17. avr_incflags = [
  18. "-isystem ${avrlibc}/avr/include"
  19. "-B${avrlibc}/avr/lib/avr5"
  20. "-L${avrlibc}/avr/lib/avr5"
  21. "-B${avrlibc}/avr/lib/avr35"
  22. "-L${avrlibc}/avr/lib/avr35"
  23. "-B${avrlibc}/avr/lib/avr51"
  24. "-L${avrlibc}/avr/lib/avr51"
  25. ];
  26. in
  27. mkShell {
  28. name = "qmk-firmware";
  29. buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv poetry niv ]
  30. ++ lib.optional avr [
  31. pkgsCross.avr.buildPackages.binutils
  32. pkgsCross.avr.buildPackages.gcc8
  33. avrlibc
  34. avrdude
  35. ]
  36. ++ lib.optional arm [ gcc-arm-embedded ]
  37. ++ lib.optional teensy [ teensy-loader-cli ];
  38. AVR_CFLAGS = lib.optional avr avr_incflags;
  39. AVR_ASFLAGS = lib.optional avr avr_incflags;
  40. shellHook = ''
  41. # Prevent the avr-gcc wrapper from picking up host GCC flags
  42. # like -iframework, which is problematic on Darwin
  43. unset NIX_CFLAGS_COMPILE_FOR_TARGET
  44. '';
  45. }