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.

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