Skip to content

Instantly share code, notes, and snippets.

@crinklywrappr
Created November 28, 2021 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crinklywrappr/a84ed4a7b61f8f5861d96824409c4008 to your computer and use it in GitHub Desktop.
Save crinklywrappr/a84ed4a7b61f8f5861d96824409c4008 to your computer and use it in GitHub Desktop.
graphviz nix build
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];
buildInputs = [];
system = builtins.currentSystem;
};
in
derivation (defaultAttrs // attrs)
set -e
source $setup
genericBuild
let
pkgs = import <nixpkgs> {};
mkDerivation = import ./autotools.nix pkgs;
in mkDerivation {
name = "graphviz";
src = ./graphviz-2.38.0.tar.gz;
}
function join_by { local IFS="$1"; shift; echo "$*"; }
unset PATH
PATH=""
for p in $baseInputs $buildInputs; do
export PATH=$(join_by ":" $PATH "$p/bin");
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