-
-
Save tfc/ca800a444b029e85a14e530c25f8e872 to your computer and use it in GitHub Desktop.
Nix pill 12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
source $setup | |
genericBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
pkgs = import <nixpkgs> {}; | |
mkDerivation = import ./autotools.nix pkgs; | |
in with pkgs; { | |
hello = import ./hello.nix { inherit mkDerivation; }; | |
graphviz = import ./graphviz.nix { inherit mkDerivation lib gd pkg-config; }; | |
graphvizCore = import ./graphviz.nix { | |
inherit mkDerivation lib gd pkg-config; | |
gdSupport = false; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ mkDerivation, lib, gdSupport ? true, gd, pkg-config }: | |
mkDerivation { | |
name = "graphviz"; | |
src = ./graphviz-2.49.3.tar.gz; | |
buildInputs = | |
if gdSupport | |
then [ | |
pkg-config | |
(lib.getLib gd) | |
(lib.getDev gd) | |
] | |
else []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ mkDerivation }: | |
mkDerivation { | |
name = "hello"; | |
src = ./hello-2.10.tar.gz; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unset PATH | |
for p in $baseInputs $buildInputs; do | |
if [ -d $p/bin ]; then | |
export PATH="$p/bin${PATH:+:}$PATH" | |
fi | |
if [ -d $p/lib/pkgconfig ]; then | |
export PKG_CONFIG_PATH="$p/lib/pkgconfig${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH" | |
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 | |
} |
For folks on a mac that just want to get through the examples, an alternative to a mac adaptation would be just running it in docker. I found this to work:
docker run -it -v $(pwd):/pills nixos/nix:master bash
cd pills
nix-build -A hello
result/bin/hello
I can't check if this launch successfully on Mac, but for the reference. The 8th pill contains recommendations for Darwin (MacOS) users. In accordance with it, you need at least to change autotools.nix as follows:
- replace
gcc
withclang
- replace
binutils-unwrapped
withclang.bintools.bintools_bin
):
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
setup = ./setup.sh;
baseInputs = [
gnutar gzip gawk
gnused gnugrep
gnumake coreutils
patchelf findutils
];
gcc = pkgs.clang;
bintools = pkgs.clang.bintools.bintools_bin;
buildInputs = [];
system = builtins.currentSystem;
};
in
derivation (defaultAttrs // attrs)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is there a version of this that works on macos?