aboutsummaryrefslogtreecommitdiff
path: root/shell.nix
diff options
context:
space:
mode:
authorSteve Purcell <steve@sanityinc.com>2020-07-09 08:50:01 +1200
committerGitHub <noreply@github.com>2020-07-08 21:50:01 +0100
commit2b55c419ea72225030c884ce818a571ef0247b42 (patch)
treefcfc1eb79d79d5e1887135bf0a0e841ff4f7028c /shell.nix
parent83e1b9ab6eee3ff11b58a905ea2015f92a724cf0 (diff)
downloadqmk_firmware-2b55c419ea72225030c884ce818a571ef0247b42.tar.gz
qmk_firmware-2b55c419ea72225030c884ce818a571ef0247b42.zip
shell.nix improvements, and fix problems on Darwin (#9551)
Diffstat (limited to 'shell.nix')
-rw-r--r--shell.nix48
1 files changed, 34 insertions, 14 deletions
diff --git a/shell.nix b/shell.nix
index 78bc005f7..93db7b371 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,25 +1,40 @@
1{ avr ? true, arm ? true, teensy ? true }: 1{ avr ? true, arm ? true, teensy ? true }:
2 2
3let 3let
4 overlay = self: super:
5 let addDarwinSupport = pkg: pkg.overrideAttrs (oldAttrs: {
6 meta.platforms = (oldAttrs.meta.platforms or []) ++ self.lib.platforms.darwin;
7 });
8 in {
9 dfu-programmer = addDarwinSupport super.dfu-programmer;
10 teensy-loader-cli = addDarwinSupport super.teensy-loader-cli;
11 };
12
13 nixpkgs = builtins.fetchTarball { 4 nixpkgs = builtins.fetchTarball {
14 url = "https://github.com/NixOS/nixpkgs/archive/903266491b7b9b0379e88709feca0af900def0d9.tar.gz"; 5 url = "https://github.com/NixOS/nixpkgs/archive/903266491b7b9b0379e88709feca0af900def0d9.tar.gz";
15 sha256 = "1b5wjrfgyha6s15k1yjyx41hvrpmd5szpkpkxk6l5hyrfqsr8wip"; 6 sha256 = "1b5wjrfgyha6s15k1yjyx41hvrpmd5szpkpkxk6l5hyrfqsr8wip";
16 }; 7 };
17 8
18 pkgs = import nixpkgs { overlays = [ overlay ]; }; 9 pkgs = import nixpkgs { };
10
11 hjson = with pkgs.python3Packages; buildPythonPackage rec {
12 pname = "hjson";
13 version = "3.0.1";
14
15 src = fetchPypi {
16 inherit pname version;
17 sha256 = "1yaimcgz8w0ps1wk28wk9g9zdidp79d14xqqj9rjkvxalvx2f5qx";
18 };
19 doCheck = false;
20 };
21
22 pythonEnv = pkgs.python3.withPackages (p: with p; [
23 # requirements.txt
24 appdirs
25 argcomplete
26 colorama
27 hjson
28 # requirements-dev.txt
29 nose2
30 flake8
31 pep8-naming
32 yapf
33 ]);
19in 34in
20 35
21with pkgs; 36with pkgs;
22let 37let
23 avrlibc = pkgsCross.avr.libcCross; 38 avrlibc = pkgsCross.avr.libcCross;
24 39
25 avr_incflags = [ 40 avr_incflags = [
@@ -32,11 +47,11 @@ let
32 "-L${avrlibc}/avr/lib/avr51" 47 "-L${avrlibc}/avr/lib/avr51"
33 ]; 48 ];
34in 49in
35stdenv.mkDerivation { 50mkShell {
36 name = "qmk-firmware"; 51 name = "qmk-firmware";
37 52
38 buildInputs = [ dfu-programmer dfu-util diffutils git python3 ] 53 buildInputs = [ dfu-programmer dfu-util diffutils git pythonEnv ]
39 ++ lib.optional avr [ 54 ++ lib.optional avr [
40 pkgsCross.avr.buildPackages.binutils 55 pkgsCross.avr.buildPackages.binutils
41 pkgsCross.avr.buildPackages.gcc8 56 pkgsCross.avr.buildPackages.gcc8
42 avrlibc 57 avrlibc
@@ -47,4 +62,9 @@ stdenv.mkDerivation {
47 62
48 AVR_CFLAGS = lib.optional avr avr_incflags; 63 AVR_CFLAGS = lib.optional avr avr_incflags;
49 AVR_ASFLAGS = lib.optional avr avr_incflags; 64 AVR_ASFLAGS = lib.optional avr avr_incflags;
65 shellHook = ''
66 # Prevent the avr-gcc wrapper from picking up host GCC flags
67 # like -iframework, which is problematic on Darwin
68 unset NIX_TARGET_CFLAGS_COMPILE
69 '';
50} 70}