Fix up gmp

This commit is contained in:
Smaug123
2021-10-30 09:27:29 +01:00
parent 4226206375
commit e25e363c6f
2 changed files with 16 additions and 13 deletions

25
gmp.nix
View File

@@ -1,14 +1,17 @@
{ pkgs ? import <nixpkgs> {} }:
# If this fails, `chmod -R a+rw /usr/local/opt/gmp/lib`
pkgs.stdenv.mkDerivation {
name = "gmp-symlink";
builder = "${pkgs.bash}/bin/bash";
args = ["-c" "${pkgs.coreutils}/bin/mkdir -p $out && ${pkgs.coreutils}/bin/touch $out/gmp-symlink"];
system = "x86_64-darwin";
postInstall =
''
${pkgs.coreutils}/bin/echo "hi!"
${pkgs.coreutils}/bin/ln -s ${pkgs.gmp}/lib/libgmp.10.dylib /usr/local/opt/gmp/lib/libgmp.10.dylib
'';
}
pkgs.runCommandLocal "gmp-symlink" {} ''
dest="/usr/local/opt/gmp/lib/libgmp.10.dylib"
existing=$(readlink "$dest")
if [ $? -eq 1 ]; then
ln -s ${pkgs.gmp}/lib/libgmp.10.dylib "$dest" && mkdir -p $out && touch $out/done.txt
else
if [[ "$existing" == /nix/store/* ]]; then
ln -fs ${pkgs.gmp}/lib/libgmp.10.dylib "$dest" && mkdir -p $out && touch $out/done.txt
else
echo "Existing symlink is $existing, refusing to overwrite"
exit 1
fi
fi
''