Skip to content
Snippets Groups Projects
Select Git revision
  • update-requirements
  • master default protected
  • dx/meh-bdf-to-stm
  • dx/somewhat-more-dynamic-config
  • rahix/proper-sleep
  • dx/flatten-config-module
  • schneider/ecg-plot
  • genofire/ble-follow-py
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
35 results

default.nix

Blame
  • Forked from card10 / firmware
    826 commits behind the upstream repository.
    default.nix 1.51 KiB
    with import <nixpkgs> {};
    
    let
      py = python36;
      # crc16 does not exist in pythonPackages - bring in our own.
      crc16 = py.pkgs.buildPythonPackage rec {
        pname = "crc16";
        version = "0.1.1";
    
        src = py.pkgs.fetchPypi {
          inherit pname version;
          sha256 = "15nkx0pa4lskwin84flpk8fsw3jqg6wic6v3s83syjqg76h6my61";
        };
      };
    in stdenv.mkDerivation rec {
      name = "card10";
      nativeBuildInputs = [
        bash
        crc16
        gcc-arm-embedded
        git
        meson
        ninja
        py
        py.pkgs.pillow
      ];
      src = ./.;
      buildCommand = ''
        build=$(pwd)/build
    
        # Copy source over, as dev sources from '.' thend to have odd permissions.
        cp -r $src $(pwd)/src
        cd $(pwd)/src
        # Ensure we have write right to patch shebangs.
        chmod -R +w .
    
        # The nix sandbox does not have /usr/bin/env bash, patch things up.
        for f in lib/micropython/*.sh tools/*.sh; do
          patchShebangs "$f"
        done
    
        # Actually run the build.
        meson --cross-file card10-cross.ini "$build"
        ninja -C "$build" -j $NIX_BUILD_CORES
    
        # Copy ELFs for debugging
        install -D -m 444 "$build/bootloader/bootloader.elf" -t "$out/lib/bootloader.elf"
        install -D -m 444 "$build/epicardium/epicardium.elf" -t "$out/lib/epicardium.elf"
        install -D -m 444 "$build/pycardium/pycardium.elf" -t "$out/lib/pycardium.elf"
        # Create new flash contents
        install -D -m 444 "$build/pycardium/pycardium_epicardium.bin" "$out/card10/card10.bin"
        install -m 444 preload/*.py -t $out/card10/
        cp -ar preload/apps $out/card10/
      '';
    }