bump to nim 1.4.2
This commit is contained in:
parent
7f201eaef1
commit
7e9a06b51d
|
@ -26,6 +26,8 @@ self: super:
|
||||||
|
|
||||||
nim = super.callPackage ./pkgs/nim/default.nix { };
|
nim = super.callPackage ./pkgs/nim/default.nix { };
|
||||||
|
|
||||||
|
nimble-unwrapped = self.nim.nimble-unwrapped;
|
||||||
|
|
||||||
picotls = super.callPackage ./pkgs/picotls/default.nix { };
|
picotls = super.callPackage ./pkgs/picotls/default.nix { };
|
||||||
|
|
||||||
picoquic = super.callPackage ./pkgs/picoquic/default.nix { };
|
picoquic = super.callPackage ./pkgs/picoquic/default.nix { };
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim
|
||||||
|
index a470179bd..73cfa1a23 100644
|
||||||
|
--- a/compiler/nimconf.nim
|
||||||
|
+++ b/compiler/nimconf.nim
|
||||||
|
@@ -225,10 +225,15 @@ proc getUserConfigPath*(filename: RelativeFile): AbsoluteFile =
|
||||||
|
proc getSystemConfigPath*(conf: ConfigRef; filename: RelativeFile): AbsoluteFile =
|
||||||
|
# try standard configuration file (installation did not distribute files
|
||||||
|
# the UNIX way)
|
||||||
|
- let p = getPrefixDir(conf)
|
||||||
|
- result = p / RelativeDir"config" / filename
|
||||||
|
+ let
|
||||||
|
+ prefix = getPrefixDir(conf)
|
||||||
|
+ env = getEnv("NIM_CONFIG_PATH")
|
||||||
|
+ if env != "":
|
||||||
|
+ result = env.toAbsoluteDir / filename
|
||||||
|
+ else:
|
||||||
|
+ result = prefix / RelativeDir"config" / filename
|
||||||
|
when defined(unix):
|
||||||
|
- if not fileExists(result): result = p / RelativeDir"etc/nim" / filename
|
||||||
|
+ if not fileExists(result): result = prefix / RelativeDir"etc/nim" / filename
|
||||||
|
if not fileExists(result): result = AbsoluteDir"/etc/nim" / filename
|
||||||
|
|
||||||
|
proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef) =
|
|
@ -1,69 +1,279 @@
|
||||||
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
|
# https://nim-lang.github.io/Nim/packaging.html
|
||||||
|
|
||||||
{ stdenv, lib, fetchurl, makeWrapper, openssl, pcre, readline,
|
{ stdenv, lib, fetchurl, fetchgit, fetchFromGitHub, makeWrapper, gdb, openssl
|
||||||
boehmgc, sfml, sqlite }:
|
, pcre, readline, boehmgc, sqlite, nim-unwrapped, nimble-unwrapped }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "nim";
|
|
||||||
version = "1.2.6";
|
|
||||||
|
|
||||||
|
let
|
||||||
|
version = "1.4.2";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://nim-lang.org/download/${pname}-${version}.tar.xz";
|
url = "https://nim-lang.org/download/nim-${version}.tar.xz";
|
||||||
sha256 = "0zk5qzxayqjw7kq6p92j4008g9bbyilyymhdc5xq9sln5rqym26z";
|
sha256 = "0q8i56343b69f1bh48a8vxkqman9i2kscyj0lf017n3xfy1pb903";
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Statically typed, imperative programming language";
|
||||||
|
homepage = "https://nim-lang.org/";
|
||||||
|
license = licenses.mit;
|
||||||
|
maintainers = with maintainers; [ ehmry ];
|
||||||
|
};
|
||||||
|
|
||||||
|
parseCpu = platform:
|
||||||
|
with platform;
|
||||||
|
# Derive a Nim CPU identifier
|
||||||
|
if isAarch32 then
|
||||||
|
"arm"
|
||||||
|
else if isAarch64 then
|
||||||
|
"arm64"
|
||||||
|
else if isAlpha then
|
||||||
|
"alpha"
|
||||||
|
else if isAvr then
|
||||||
|
"avr"
|
||||||
|
else if isMips && is32bit then
|
||||||
|
"mips"
|
||||||
|
else if isMips && is64bit then
|
||||||
|
"mips64"
|
||||||
|
else if isMsp430 then
|
||||||
|
"msp430"
|
||||||
|
else if isPowerPC && is32bit then
|
||||||
|
"powerpc"
|
||||||
|
else if isPowerPC && is64bit then
|
||||||
|
"powerpc64"
|
||||||
|
else if isRiscV && is64bit then
|
||||||
|
"riscv64"
|
||||||
|
else if isSparc then
|
||||||
|
"sparc"
|
||||||
|
else if isx86_32 then
|
||||||
|
"i386"
|
||||||
|
else if isx86_64 then
|
||||||
|
"amd64"
|
||||||
|
else
|
||||||
|
abort "no Nim CPU support known for ${config}";
|
||||||
|
|
||||||
|
parseOs = platform:
|
||||||
|
with platform;
|
||||||
|
# Derive a Nim OS identifier
|
||||||
|
if isAndroid then
|
||||||
|
"Android"
|
||||||
|
else if isDarwin then
|
||||||
|
"MacOSX"
|
||||||
|
else if isFreeBSD then
|
||||||
|
"FreeBSD"
|
||||||
|
else if isGenode then
|
||||||
|
"Genode"
|
||||||
|
else if isLinux then
|
||||||
|
"Linux"
|
||||||
|
else if isNetBSD then
|
||||||
|
"NetBSD"
|
||||||
|
else if isNone then
|
||||||
|
"Standalone"
|
||||||
|
else if isOpenBSD then
|
||||||
|
"OpenBSD"
|
||||||
|
else if isWindows then
|
||||||
|
"Windows"
|
||||||
|
else if isiOS then
|
||||||
|
"iOS"
|
||||||
|
else
|
||||||
|
abort "no Nim OS support known for ${config}";
|
||||||
|
|
||||||
|
parsePlatform = p: {
|
||||||
|
cpu = parseCpu p;
|
||||||
|
os = parseOs p;
|
||||||
|
};
|
||||||
|
|
||||||
|
nimHost = parsePlatform stdenv.hostPlatform;
|
||||||
|
nimTarget = parsePlatform stdenv.targetPlatform;
|
||||||
|
|
||||||
|
wrapperInputs = rec {
|
||||||
|
|
||||||
|
bootstrap = stdenv.mkDerivation rec {
|
||||||
|
pname = "nim-bootstrap";
|
||||||
|
version = "0.20.0";
|
||||||
|
|
||||||
|
src = fetchgit {
|
||||||
|
# A Git checkout is much smaller than a GitHub tarball.
|
||||||
|
url = "https://github.com/nim-lang/csources.git";
|
||||||
|
rev = "v" + version;
|
||||||
|
sha256 = "0i6vsfy1sgapx43n226q8m0pvn159sw2mhp50zm3hhb9zfijanis";
|
||||||
};
|
};
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
NIX_LDFLAGS = "-lcrypto -lpcre -lreadline -lgc -lsqlite3";
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
install -Dt $out/bin bin/nim
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# we could create a separate derivation for the "written in c" version of nim
|
unwrapped = stdenv.mkDerivation {
|
||||||
# used for bootstrapping, but koch insists on moving the nim compiler around
|
pname = "nim-unwrapped";
|
||||||
# as part of building it, so it cannot be read-only
|
inherit version src;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
buildInputs = [ boehmgc openssl pcre readline sqlite ];
|
||||||
makeWrapper
|
|
||||||
|
patches = [
|
||||||
|
./NIM_CONFIG_DIR.patch
|
||||||
|
# Override compiler configuration via an environmental variable
|
||||||
|
|
||||||
|
./nixbuild.patch
|
||||||
|
# Load libraries at runtime by absolute path
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
configurePhase = ''
|
||||||
openssl pcre readline boehmgc sfml sqlite
|
runHook preConfigure
|
||||||
];
|
cp ${bootstrap}/bin/nim bin/
|
||||||
|
echo 'define:nixbuild' >> config/nim.cfg
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
|
||||||
|
kochArgs = [
|
||||||
|
"--cpu:${nimHost.cpu}"
|
||||||
|
"--os:${nimHost.os}"
|
||||||
|
"-d:release"
|
||||||
|
"-d:useGnuReadline"
|
||||||
|
] ++ lib.optional (stdenv.isDarwin || stdenv.isLinux)
|
||||||
|
"-d:nativeStacktrace";
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
local HOME=$TMPDIR
|
||||||
# build.sh wants to write to $HOME/.cache
|
|
||||||
HOME=$TMPDIR
|
|
||||||
sh build.sh
|
|
||||||
./bin/nim c koch
|
./bin/nim c koch
|
||||||
./koch boot -d:release \
|
./koch boot $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||||
-d:useGnuReadline \
|
./koch toolsNoExternal $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||||
${lib.optionals (stdenv.isDarwin || stdenv.isLinux) "-d:nativeStacktrace"}
|
|
||||||
./koch tools -d:release
|
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
install -Dt $out/bin bin/*
|
||||||
install -Dt $out/bin bin/* koch
|
ln -sf $out/nim/bin/nim $out/bin/nim
|
||||||
./koch install $out
|
./install.sh $out
|
||||||
mv $out/nim/bin/* $out/bin/ && rmdir $out/nim/bin
|
|
||||||
mv $out/nim/* $out/ && rmdir $out/nim
|
|
||||||
|
|
||||||
# Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
|
|
||||||
wrapProgram $out/bin/nim \
|
|
||||||
--run 'NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}' \
|
|
||||||
--suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
|
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
inherit meta;
|
||||||
description = "Statically typed, imperative programming language";
|
|
||||||
homepage = "https://nim-lang.org/";
|
|
||||||
license = licenses.mit;
|
|
||||||
maintainers = with maintainers; [ ehmry ];
|
|
||||||
platforms = with platforms; linux ++ darwin; # arbitrary
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
nimble-unwrapped = stdenv.mkDerivation rec {
|
||||||
|
pname = "nimble-unwrapped";
|
||||||
|
version = "0.12.0";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "nim-lang";
|
||||||
|
repo = "nimble";
|
||||||
|
rev = "v" + version;
|
||||||
|
sha256 = "0vx0mdk31n00dr2rhiip6f4x7aa3z3mnblnmwk7f65ixd5hayq6y";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ nim-unwrapped ];
|
||||||
|
buildInputs = [ openssl ];
|
||||||
|
|
||||||
|
nimFlags = [ "--cpu:${nimHost.cpu}" "--os:${nimHost.os}" "-d:release" ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
HOME=$NIX_BUILD_TOP nim c $nimFlags src/nimble
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
install -Dt $out/bin src/nimble
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapped = let
|
||||||
|
nim' = nim-unwrapped;
|
||||||
|
nimble' = nimble-unwrapped;
|
||||||
|
inherit (stdenv) targetPlatform;
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
name = "${targetPlatform.config}-nim-wrapper-${nim'.version}";
|
||||||
|
inherit (nim') version;
|
||||||
|
preferLocalBuild = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
runHook preUnpack
|
||||||
|
tar xf ${nim'.src} nim-$version/config/nim.cfg
|
||||||
|
cd nim-$version
|
||||||
|
runHook postUnpack
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontConfigure = true;
|
||||||
|
|
||||||
|
wrapperArgs = [
|
||||||
|
"--prefix PATH : ${lib.makeBinPath [ stdenv.cc gdb ]}:${
|
||||||
|
placeholder "out"
|
||||||
|
}/bin"
|
||||||
|
"--prefix LD_LIBRARY_PATH : ${
|
||||||
|
lib.makeLibraryPath [ stdenv.cc.libc openssl ]
|
||||||
|
}"
|
||||||
|
"--set NIM_CONFIG_PATH ${placeholder "out"}/etc/nim"
|
||||||
|
''--set NIX_HARDENING_ENABLE "''${NIX_HARDENING_ENABLE/fortify}"''
|
||||||
|
# Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = with stdenv;
|
||||||
|
let
|
||||||
|
ccType = if cc.isGNU then
|
||||||
|
"gcc"
|
||||||
|
else if cc.isClang then
|
||||||
|
"clang"
|
||||||
|
else
|
||||||
|
abort "no Nim configuration available for ${cc.name}";
|
||||||
|
in ''
|
||||||
|
runHook preBuild
|
||||||
|
cat >> config/nim.cfg << EOF
|
||||||
|
|
||||||
|
define:nixbuild
|
||||||
|
os = ${nimTarget.os}
|
||||||
|
cpu = ${nimTarget.cpu}
|
||||||
|
cc = ${ccType}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p $out/bin $out/etc/nim
|
||||||
|
export cc=$CC
|
||||||
|
export cxx=$CXX
|
||||||
|
substituteAll config/nim.cfg $out/etc/nim/nim.cfg \
|
||||||
|
--replace "cc = gcc" ""
|
||||||
|
|
||||||
|
for binpath in ${nim'}/bin/nim?*; do
|
||||||
|
local binname=`basename $binpath`
|
||||||
|
makeWrapper \
|
||||||
|
$binpath $out/bin/${targetPlatform.config}-$binname \
|
||||||
|
$wrapperArgs
|
||||||
|
ln -s $out/bin/${targetPlatform.config}-$binname $out/bin/$binname
|
||||||
|
done
|
||||||
|
|
||||||
|
makeWrapper \
|
||||||
|
${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \
|
||||||
|
$wrapperArgs
|
||||||
|
ln -s $out/bin/${targetPlatform.config}-nim $out/bin/nim
|
||||||
|
|
||||||
|
makeWrapper \
|
||||||
|
${nim'}/bin/testament $out/bin/${targetPlatform.config}-testament \
|
||||||
|
$wrapperArgs
|
||||||
|
ln -s $out/bin/${targetPlatform.config}-testament $out/bin/testament
|
||||||
|
|
||||||
|
makeWrapper \
|
||||||
|
${nimble'}/bin/nimble $out/bin/${targetPlatform.config}-nimble \
|
||||||
|
--suffix PATH : $out/bin
|
||||||
|
ln -s $out/bin/${targetPlatform.config}-nimble $out/bin/nimble
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontInstall = true;
|
||||||
|
|
||||||
|
meta = meta // {
|
||||||
|
description = nim'.meta.description
|
||||||
|
+ " (${targetPlatform.config} wrapper)";
|
||||||
|
platforms = lib.platforms.unix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in wrapped // wrapperInputs
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
commit 164ba50fc74b980f77047080b2ae1ea099ae9b27
|
||||||
|
Author: Emery Hemingway <ehmry@posteo.net>
|
||||||
|
Date: Mon Sep 7 14:09:22 2020 +0200
|
||||||
|
|
||||||
|
Load libaries by absolute path on NixOS
|
||||||
|
|
||||||
|
If "nixbuild" is defined then choose dynamic runtime libraries by
|
||||||
|
searching $NIX_LDFLAGS at compile-time.
|
||||||
|
|
||||||
|
Fix #15194
|
||||||
|
|
||||||
|
diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim
|
||||||
|
index f31ae94dd..debed9c07 100644
|
||||||
|
--- a/lib/pure/dynlib.nim
|
||||||
|
+++ b/lib/pure/dynlib.nim
|
||||||
|
@@ -56,6 +56,9 @@
|
||||||
|
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
+when defined(nixbuild):
|
||||||
|
+ import os
|
||||||
|
+
|
||||||
|
type
|
||||||
|
LibHandle* = pointer ## a handle to a dynamically loaded library
|
||||||
|
|
||||||
|
@@ -95,6 +98,25 @@ proc libCandidates*(s: string, dest: var seq[string]) =
|
||||||
|
libCandidates(prefix & middle & suffix, dest)
|
||||||
|
else:
|
||||||
|
add(dest, s)
|
||||||
|
+ when defined(nixbuild):
|
||||||
|
+ # Nix doesn't have a global library directory so
|
||||||
|
+ # load libraries using an absolute path if one
|
||||||
|
+ # can be derived from NIX_LDFLAGS.
|
||||||
|
+ #
|
||||||
|
+ # During Nix/NixOS packaging the line "define:nixbuild"
|
||||||
|
+ # should be appended to the ../../config/nim.cfg file
|
||||||
|
+ # to enable this behavior by default.
|
||||||
|
+ #
|
||||||
|
+ var libDirs = split(getEnv("LD_LIBRARY_PATH"), ':')
|
||||||
|
+ for flag in split(getEnv("NIX_LDFLAGS")):
|
||||||
|
+ if flag.startsWith("-L"):
|
||||||
|
+ libDirs.add(flag[2..flag.high])
|
||||||
|
+ for lib in dest:
|
||||||
|
+ for dir in libDirs:
|
||||||
|
+ let abs = dir / lib
|
||||||
|
+ if existsFile(abs):
|
||||||
|
+ dest = @[abs]
|
||||||
|
+ return
|
||||||
|
|
||||||
|
proc loadLibPattern*(pattern: string, globalSymbols = false): LibHandle =
|
||||||
|
## loads a library with name matching `pattern`, similar to what `dlimport`
|
Loading…
Reference in New Issue