nixpkgs/pkgs/tools/misc/sam-ba/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

52 lines
1.8 KiB
Nix

{ lib, stdenv, fetchzip, libX11, libXScrnSaver, libXext, libXft, libXrender
, freetype, zlib, fontconfig
}:
let
maybe64 = if stdenv.isx86_64 then "_64" else "";
libPath = stdenv.lib.makeLibraryPath
[ stdenv.cc.cc.lib libX11 libXScrnSaver libXext libXft libXrender freetype
zlib fontconfig
];
in
stdenv.mkDerivation rec {
version = "2.16";
pname = "sam-ba";
src = fetchzip {
url = "http://www.atmel.com/dyn/resources/prod_documents/sam-ba_${version}_linux.zip";
sha256 = "18lsi4747900cazq3bf0a87n3pc7751j5papj9sxarjymcz9vks4";
};
# Pre-built binary package. Install everything to /opt/sam-ba to not mess up
# the internal directory structure. Then create wrapper in /bin. Attemts to
# use "patchelf --set-rpath" instead of setting LD_PRELOAD_PATH failed.
installPhase = ''
mkdir -p "$out/bin/" \
"$out/opt/sam-ba/"
cp -a . "$out/opt/sam-ba/"
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/opt/sam-ba/sam-ba${maybe64}"
cat > "$out/bin/sam-ba" << EOF
export LD_LIBRARY_PATH="${libPath}"
exec "$out/opt/sam-ba/sam-ba${maybe64}"
EOF
chmod +x "$out/bin/sam-ba"
'';
# Do our own thing
dontPatchELF = true;
meta = with lib; {
description = "Programming tools for Atmel SAM3/7/9 ARM-based microcontrollers";
longDescription = ''
Atmel SAM-BA software provides an open set of tools for programming the
Atmel SAM3, SAM7 and SAM9 ARM-based microcontrollers.
'';
homepage = "http://www.at91.com/linux4sam/bin/view/Linux4SAM/SoftwareTools";
# License in <source>/doc/readme.txt
license = "BSD-like (partly binary-only)"; # according to Buildroot
platforms = [ "x86_64-linux" ]; # patchelf fails on i686-linux
maintainers = [ maintainers.bjornfor ];
};
}