about summary refs log tree commit diff
path: root/pkgs/development/embedded/bossa/default.nix
blob: 58ee0642fb380c2028e50b1d1f3607f91c02b04a (plain) (blame)
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
{ lib
, stdenv
, fetchFromGitHub
, wxGTK32
, libX11
, readline
, darwin
}:

let
  # BOSSA needs a "bin2c" program to embed images.
  # Source taken from:
  # http://wiki.wxwidgets.org/Embedding_PNG_Images-Bin2c_In_C
  bin2c = stdenv.mkDerivation {
    name = "bossa-bin2c";
    src = ./bin2c.c;
    dontUnpack = true;
    buildPhase = "cc $src -o bin2c";
    installPhase = "mkdir -p $out/bin; cp bin2c $out/bin/";
  };

in
stdenv.mkDerivation rec {
  pname = "bossa";
  version = "1.9.1";

  src = fetchFromGitHub {
    owner = "shumatech";
    repo = "BOSSA";
    rev = version;
    sha256 = "sha256-8M3MU/+Y1L6SaQ1yoC9Z27A/gGruZdopLnL1z7h7YJw=";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace "-arch x86_64" ""
  '';

  nativeBuildInputs = [ bin2c ];
  buildInputs = [
    wxGTK32
    libX11
    readline
  ] ++ lib.optionals stdenv.isDarwin [
    darwin.apple_sdk.frameworks.Cocoa
  ];

  makeFlags = [
    "WXVERSION=3.2"
    # Explicitly specify targets so they don't get stripped.
    "bin/bossac"
    "bin/bossash"
    "bin/bossa"
  ];
  env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";

  installPhase = ''
    mkdir -p $out/bin
    cp bin/bossa{c,sh,} $out/bin/
  '';

  meta = with lib; {
    description = "A flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers";
    longDescription = ''
      BOSSA is a flash programming utility for Atmel's SAM family of
      flash-based ARM microcontrollers. The motivation behind BOSSA is
      to create a simple, easy-to-use, open source utility to replace
      Atmel's SAM-BA software. BOSSA is an acronym for Basic Open
      Source SAM-BA Application to reflect that goal.
    '';
    homepage = "http://www.shumatech.com/web/products/bossa";
    license = licenses.bsd3;
    platforms = platforms.unix;
  };
}