Skip to content

Instantly share code, notes, and snippets.

@Ariakenom
Last active August 22, 2019 09:01
Show Gist options
  • Save Ariakenom/73d01c739d20ffb56d65ef8217bc73f0 to your computer and use it in GitHub Desktop.
Save Ariakenom/73d01c739d20ffb56d65ef8217bc73f0 to your computer and use it in GitHub Desktop.
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
setup = [ ./setup.sh ];
baseInputs = [ gnutar gzip gnumake gcc binutils-unwrapped
coreutils gawk gnused gnugrep patchelf findutils ];
buildInputs = [];
system = builtins.currentSystem;
};
in
derivation (defaultAttrs // attrs)
set -e
source $setup
genericBuild
[patrik@attentec85:~/nixtest/11_inputpattern]$ nix-build graphviz.nix
/nix/store/kw92knc13ljycc8rxx9a8khyc5gqdahs-graphviz
[patrik@attentec85:~/nixtest/11_inputpattern]$ echo 'graph test { a -- b }'|result/bin/dot -Tpng -o butterfly16.png
Format: "png" not recognized. Use one of: canon cmap cmapx cmapx_np dot eps fig gv imap imap_np ismap pic plain plain-ext pov ps ps2 svg tk vml xdot xdot1.2 xdot1.4
let
pkgs = import <nixpkgs> {};
mkDerivation = import ./autotools.nix pkgs;
in mkDerivation {
name = "graphviz";
src = ./graphviz-2.38.0.tar.gz;
buildInputs = with pkgs; [ gd fontconfig libjpeg bzip2 ];
}
unset PATH
for p in $baseInputs $buildInputs; do
if [ -d $p/bin ]; then
export PATH="$p/bin${PATH:+:}$PATH"
fi
if [ -d $p/include ]; then
export NIX_CFLAGS_COMPILE="-I $p/include${NIX_CFLAGS_COMPILE:+ }$NIX_CFLAGS_COMPILE"
fi
if [ -d $p/lib ]; then
export NIX_LDFLAGS="-rpath $p/lib -L $p/lib${NIX_LDFLAGS:+ }$NIX_LDFLAGS"
fi
done
function unpackPhase() {
tar -xzf $src
for d in *; do
if [ -d "$d" ]; then
cd "$d"
break
fi
done
}
function configurePhase() {
./configure --prefix=$out
}
function buildPhase() {
make
}
function installPhase() {
make install
}
function fixupPhase() {
find $out -type f -exec patchelf --shrink-rpath '{}' \; -exec strip '{}' \; 2>/dev/null
}
function genericBuild() {
unpackPhase
configurePhase
buildPhase
installPhase
fixupPhase
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment