]> git.scottworley.com Git - tattlekey/blob - client/default.nix
eb65f49b6b488219d05b556f53310f4fb746261d
[tattlekey] / client / default.nix
1 { pkgs ? import <nixpkgs> { }, }:
2 let
3
4 tattlekey = { lib, stdenv, cmake, pico-sdk, pico-examples, python3 }:
5 stdenv.mkDerivation {
6 pname = "tattlekey";
7 version = "0.0.1";
8 src = lib.cleanSource ./.;
9 nativeBuildInputs = [ cmake python3 ];
10 postUnpack = ''
11 # Per https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf page 9
12 cp ${pico-examples}/pico_w/wifi/lwipopts_examples_common.h lwipopts.h
13 '';
14 cmakeFlags = [
15 "-DCMAKE_C_COMPILER=/usr/bin/arm-none-eabi-gcc"
16 "-DCMAKE_CXX_COMPILER=/usr/bin/arm-none-eabi-c++"
17 "-DPICO_BOARD=pico_w"
18 "-DPICO_SDK_PATH=${pico-sdk}/lib/pico-sdk"
19 ];
20 diskImage = debImage;
21 diskImageFormat = "qcow2";
22 };
23
24 pico-sdk-version = "1.5.1";
25
26 pico-sdk = pkgs.pico-sdk.overrideAttrs (old: {
27 version = pico-sdk-version;
28 src = pkgs.fetchFromGitHub {
29 fetchSubmodules = true;
30 owner = "raspberrypi";
31 repo = "pico-sdk";
32 rev = pico-sdk-version;
33 hash = "sha256-GY5jjJzaENL3ftuU5KpEZAmEZgyFRtLwGVg3W1e/4Ho=";
34 };
35 });
36
37 pico-examples = pkgs.fetchFromGitHub {
38 fetchSubmodules = true;
39 owner = "raspberrypi";
40 repo = "pico-examples";
41 rev = "sdk-${pico-sdk-version}";
42 hash = "sha256-mJIOWUqsQJcg7FUWZePf+pA/YblZskDtIVnUJiz7szU=";
43 };
44
45 distro = "debian11x86_64";
46
47 extraPackages = [
48 "build-essential"
49 "cmake"
50 "gcc-arm-none-eabi"
51 "libnewlib-arm-none-eabi"
52 "libstdc++-arm-none-eabi-newlib"
53 ];
54
55 debImage = pkgs.vmTools.diskImageFuns."${distro}" { inherit extraPackages; };
56
57 in pkgs.vmTools.runInLinuxImage
58 (pkgs.callPackage tattlekey { inherit pico-examples pico-sdk; })