nixpkgs/pkgs/applications/science/electronics/eagle/default.nix
Bjørn Forsman a31ba7ed65 eagle: new package
Eagle is a schematic capture and PCB layout program from CadSoft. This
is proprietary software; CadSoft provide a self-extracting shell script
with embedded tarball of the prebuilt application.

Add the latest Eagle version, 6.4.0.

I've added a small LD_PRELOAD library that redirects operations on the
license file from <eagle_install_path>/bin/eagle.key to
$HOME/.eagle.key. Without this Eagle will never get past the license
dialog (because you cannot write to the nix store).

Eagle also has issues copying its example projects to other locations;
it seems that it wants to preserve the read-only permissions from the
source over to the destination. Because of this it cannot complete the
copy operation because it cannot write the project files into to the
(read-only) project directory it just created. So wrap chmod by OR'ing
in the write-by-owner bit.
2013-05-25 21:12:47 +02:00

87 lines
2.7 KiB
Nix

{ stdenv, fetchurl, makeDesktopItem, patchelf, zlib, freetype, fontconfig
, openssl, libXrender, libXrandr, libXcursor, libX11, libXext, libXi
}:
let
libPath = stdenv.lib.makeLibraryPath
[ zlib freetype fontconfig openssl libXrender libXrandr libXcursor libX11
libXext libXi
];
in
stdenv.mkDerivation rec {
name = "eagle-${version}";
version = "6.4.0";
src = fetchurl {
url = "ftp://ftp.cadsoft.de/eagle/program/6.4/eagle-lin-${version}.run";
sha256 = "0jb44dsq4cl9rx5nam6rxsw9fsmm6fsksv9s544p2zrwnad2x2i8";
};
desktopItem = makeDesktopItem {
name = "Eagle";
exec = "eagle";
icon = "eagle";
comment = "Schematic capture and PCB layout";
desktopName = "Eagle";
genericName = "Schematic editor";
categories = "Application;Development;";
};
buildInputs =
[ patchelf zlib freetype fontconfig openssl libXrender libXrandr libXcursor
libX11 libXext libXi
];
phases = [ "installPhase" ];
# NOTES:
# Eagle for Linux comes as a self-extracting shell script with embedded
# tarball. The tarball data (.tar.bz2) starts after a __DATA__ marker.
#
# Eagle apparently doesn't like binary patching. This is what happens:
# $ ./result/eagle-6.4.0/bin/eagle
# argv[0] (/home/bfo/nixpkgs/result/eagle-6.4.0/bin/eagle) is not the currently executed program version!
installPhase = ''
# Extract eagle tarball
mkdir "$out"
sed '1,/^__DATA__$/d' "$src" | tar -xjf - -C "$out"
# Install manpage
mkdir -p "$out"/share/man/man1
ln -s "$out"/eagle-${version}/doc/eagle.1 "$out"/share/man/man1/eagle.1
# Build LD_PRELOAD library that redirects license file access to the home
# directory of the user
mkdir -p "$out"/lib
gcc -shared -fPIC -DEAGLE_PATH=\"$out/eagle-${version}\" ${./eagle_fixer.c} -o "$out"/lib/eagle_fixer.so -ldl
# Make wrapper script
dynlinker="$(cat $NIX_GCC/nix-support/dynamic-linker)"
mkdir -p "$out"/bin
cat > "$out"/bin/eagle << EOF
#!${stdenv.shell}
export LD_LIBRARY_PATH="${stdenv.gcc.gcc}/lib:${libPath}"
export LD_PRELOAD="$out/lib/eagle_fixer.so"
exec "$dynlinker" "$out/eagle-${version}/bin/eagle" "\$@"
EOF
chmod a+x "$out"/bin/eagle
# Make desktop item
mkdir -p "$out"/share/applications
cp "$desktopItem"/share/applications/* "$out"/share/applications/
mkdir -p "$out"/share/icons
ln -s "$out/eagle-${version}/bin/eagleicon50.png" "$out"/share/icons/eagle.png
'';
meta = with stdenv.lib; {
description = "Schematic editor and PCB layout tool from CadSoft";
homepage = http://www.cadsoftusa.com/;
license = licenses.unfree;
platforms = platforms.linux;
maintainers = [ maintainers.bjornfor ];
};
}