Skip to content
Snippets Groups Projects
Select Git revision
  • d23fbdd045561294e388f09ba87e0199a6a5bf7a
  • master default protected
  • ecg-ledupdate
  • ecg-app-pause
  • ecg-app
  • remove-debug-bhi160
  • docs-power
  • clock-colors
  • ble-text-color
  • menu-timeout
  • update-menu
  • rahix/batt
  • genofire/ble-rewrite
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • ios-workarounds
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
26 results

default.nix

Blame
  • Forked from card10 / firmware
    1403 commits behind the upstream repository.
    q3k's avatar
    q3k authored and Rahix committed
    We provide a nix expression to build card10 firmware.
    
    On Linux/Darwin with Nix and NixOS, this can be used as follows:
    
      $ git submodule update --init
      $ nix build
      $ ls result/
      result/bootloader:
      bootloader.elf
    
      result/epicardium:
      epicardium.elf
    
      result/pycardium:
      pycardium.elf  pycardium_epicardium.bin
    
    This derivation can also be used for development:
    
      $ nix-shell
      $ meson --cross-file card10-cross.ini build/
      $ ninja -C build/ -j8
      $ # hack on things
      $ ninja -C build/ -j 8
      $ ls build/
      [ ... ]
    4d8af366
    History
    default.nix 1.34 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
        meson
        ninja
        py
      ];
      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; do
          patchShebangs "$f"
        done
    
        # Actually run the build.
        meson --cross-file card10-cross.ini "$build"
        ninja -C "$build" -j $NIX_BUILD_CORES
    
        # Copy artifacts to derivation outputs.
        install -D -m 444 "$build/bootloader/bootloader.elf" -t "$out/bootloader"
        install -D -m 444 "$build/pycardium/pycardium_epicardium.bin" -t "$out/pycardium"
        install -D -m 444 "$build/epicardium/epicardium.elf" -t "$out/epicardium"
        install -D -m 444 "$build/pycardium/pycardium.elf" -t "$out/pycardium"
      '';
    }