Skip to content

Instantly share code, notes, and snippets.

@lucabrunox
Last active December 19, 2018 02:38
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save lucabrunox/97fae227329b442267bc to your computer and use it in GitHub Desktop.
Save lucabrunox/97fae227329b442267bc to your computer and use it in GitHub Desktop.
Nix pill 10
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
setup = ./setup.sh;
baseInputs = [ gnutar gzip gnumake gcc binutils coreutils gawk gnused gnugrep patchelf findutils ];
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 = "hello";
src = ./hello-2.9.tar.gz;
}
unset PATH
for p in $baseInputs $buildInputs; do
export PATH=$p/bin${PATH:+:}$PATH
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
}
@rolfschr
Copy link

The hello.nix file should reference hello-2.10.tar.gz to be consistent with chap 08 of nix pills, i.e. https://gist.githubusercontent.com/rolfschr/03050a2a02f46a57ce2c2a4065958b9d/raw/4f32da8ee9bf03ae3ce2aea66d1ab50145c0225a/hello.nix

@mhwombat
Copy link

mhwombat commented Dec 19, 2018

I got the error message /bin/bash: ar: command not found. I fixed this by changing binutils to binutils-unwrapped at line 7 in autotools.nix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment