-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
167 lines (161 loc) · 5.71 KB
/
flake.nix
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
description = "Unfucking the Zephyr/Nrf Experience";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
zephyr-sdk = {
url = "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.15.2/zephyr-sdk-0.15.2_linux-x86_64.tar.gz";
flake = false;
};
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
flake-parts.flakeModules.easyOverlay
];
systems = [ "x86_64-linux" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.self.overlays.default ]; config = { allowUnfree = true; segger-jlink.acceptLicense = true; }; };
overlayAttrs = config.packages // config.legacyPackages;
legacyPackages = {
fetchWestWorkspace = pkgs.callPackage ./functions/fetchWestWorkspace { };
mkZephyrProject = pkgs.callPackage ./functions/mkZephyrProject { };
};
packages = {
zephyr-sdk = pkgs.stdenv.mkDerivation {
name = "zephyr-sdk-patched";
nativeBuildInputs = with pkgs; [ autoPatchelfHook ];
buildInputs = with pkgs; [ pkgs.stdenv.cc.cc.lib python38 ];
installPhase = "ls -lah";
src = inputs.zephyr-sdk;
buildPhase = ''
cp -r $src $out
'';
};
# It's not entirely clear based on the documentation which of all of these
# dependencies are actually necessary to build Zephyr, the list may increase
# depending on the ongoing changes upstream
zephyrPython = pkgs.python3.withPackages (p: with p; [
docutils
wheel
breathe
sphinx
sphinx_rtd_theme
ply
pyelftools
pyserial
pykwalify
colorama
pillow
intelhex
pytest
gcovr
tkinter
future
cryptography
setuptools
pyparsing
click
kconfiglib
pylink-square
pyyaml
cbor2
west
ecdsa
anytree
]);
};
devShells.default =
let
westWorkspace = pkgs.fetchWestWorkspace {
url = "https://github.com/nrfconnect/sdk-nrf";
rev = "v2.1.0";
sha256 = "sha256-LoL0SzPiKfXxWnZdbx+3m0bzyPeHovWNlmkFQsmiR7g=";
};
in pkgs.mkShell {
shellHook = ''
# export GNUARMEMB_TOOLCHAIN_PATH=$#{pkgs.gcc-arm-embedded-11}
echo "Creating mutable west workspace in /tmp/nrf-nix and forcing VSCode to use it"
rm -rf /tmp/nrf-nix
cp -r --no-preserve=mode ${westWorkspace} /tmp/nrf-nix
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=${pkgs.zephyr-sdk};
export ZEPHYR_BASE="/tmp/nrf-nix/zephyr"
export PATH=${pkgs.zephyr-sdk}/arm-zephyr-eabi/bin:$PATH
export PYTHONPATH=${pkgs.zephyrPython}/lib/python3.10/site-packages:$PYTHONPATH
'';
buildInputs = with pkgs;
let
otherExtensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "nrf-connect-extension-pack";
publisher = "nordic-semiconductor";
version = "2023.6.6";
sha256 = "sha256-pq+O2Nctd4Op8pW6lLXI1J1QBYtUeo0thczfnSe+8CA=";
}
{
name = "nrf-terminal";
publisher = "nordic-semiconductor";
version = "2023.6.78";
sha256 = "sha256-vJtlarLrlzcGmnXr+mqEeL3L7dKskuFXE9/mgS/1dN0=";
}
{
name = "nrf-kconfig";
publisher = "nordic-semiconductor";
version = "2023.6.51";
sha256 = "sha256-Bx68ANr/efOVTAqf1JXi8ZMnzHCKwf+pHE+YD710LUE=";
}
{
name = "nrf-devicetree";
publisher = "nordic-semiconductor";
version = "2023.6.108";
sha256 = "sha256-V+jloKRu9komxzRdEIjTIcduwpD9fimXwTAgrZWzeiM=";
}
{
name = "nrf-connect";
publisher = "nordic-semiconductor";
version = "2022.7.111";
sha256 = "sha256-td97z4H5/G8Xgy66kY0N5z/eqWf15S0BL0FtvquYgUE=";
}
{
name = "gnu-mapfiles";
publisher = "trond-snekvik";
version = "1.1.0";
sha256 = "sha256-JHdOqCjHbxHlth2PQ6r7SfNqedKwu6Fsot/mhPPFJhA=";
}
];
vscodeFhs = (pkgs.vscode-fhsWithPackages (p: with p; [
nrf-command-line-tools
segger-jlink
dtc
gn
gperf
ninja
cmake
zephyrPython
]));
myVscode = vscode-with-extensions.override {
vscode = vscodeFhs;
# https://marketplace.visualstudio.com/items?itemName=nordic-semiconductor.nrf-connect-extension-pack
vscodeExtensions = with pkgs.vscode-extensions; [
ms-vscode.cpptools
twxs.cmake
] ++ otherExtensions;
};
in [
myVscode
nrfconnect
nrf-command-line-tools
dtc
gn
gperf
ninja
cmake
zephyrPython
];
};
};
flake = {
};
};
}