nim-unwrapped-2_2: move to pkgs/by-name from nim-unwrapped-2
This commit is contained in:
@@ -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) =
|
||||
@@ -0,0 +1,48 @@
|
||||
diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim
|
||||
index c9e6060e5..acb289498 100644
|
||||
--- a/compiler/modulepaths.nim
|
||||
+++ b/compiler/modulepaths.nim
|
||||
@@ -79,6 +79,13 @@ proc checkModuleName*(conf: ConfigRef; n: PNode; doLocalError=true): FileIndex =
|
||||
else:
|
||||
result = fileInfoIdx(conf, fullPath)
|
||||
|
||||
+proc rot13(result: var string) =
|
||||
+ for i, c in result:
|
||||
+ case c
|
||||
+ of 'a'..'m', 'A'..'M': result[i] = char(c.uint8 + 13)
|
||||
+ of 'n'..'z', 'N'..'Z': result[i] = char(c.uint8 - 13)
|
||||
+ else: discard
|
||||
+
|
||||
proc mangleModuleName*(conf: ConfigRef; path: AbsoluteFile): string =
|
||||
## Mangle a relative module path to avoid path and symbol collisions.
|
||||
##
|
||||
@@ -87,9 +94,11 @@ proc mangleModuleName*(conf: ConfigRef; path: AbsoluteFile): string =
|
||||
##
|
||||
## Example:
|
||||
## `foo-#head/../bar` becomes `@foo-@hhead@s..@sbar`
|
||||
- "@m" & relativeTo(path, conf.projectPath).string.multiReplace(
|
||||
+ result = "@m" & relativeTo(path, conf.projectPath).string.multiReplace(
|
||||
{$os.DirSep: "@s", $os.AltSep: "@s", "#": "@h", "@": "@@", ":": "@c"})
|
||||
+ rot13(result)
|
||||
|
||||
proc demangleModuleName*(path: string): string =
|
||||
## Demangle a relative module path.
|
||||
result = path.multiReplace({"@@": "@", "@h": "#", "@s": "/", "@m": "", "@c": ":"})
|
||||
+ rot13(result)
|
||||
diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim
|
||||
index 77762d23a..59dd8903a 100644
|
||||
--- a/compiler/modulegraphs.nim
|
||||
+++ b/compiler/modulegraphs.nim
|
||||
@@ -503,7 +503,11 @@ proc uniqueModuleName*(conf: ConfigRef; m: PSym): string =
|
||||
for i in 0..<trunc:
|
||||
let c = rel[i]
|
||||
case c
|
||||
- of 'a'..'z', '0'..'9':
|
||||
+ of 'a'..'m':
|
||||
+ result.add char(c.uint8 + 13)
|
||||
+ of 'n'..'z':
|
||||
+ result.add char(c.uint8 - 13)
|
||||
+ of '0'..'9':
|
||||
result.add c
|
||||
of {os.DirSep, os.AltSep}:
|
||||
result.add 'Z' # because it looks a bit like '/'
|
||||
@@ -0,0 +1,40 @@
|
||||
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) and not defined(windows):
|
||||
+ 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) and not defined(windows):
|
||||
+ # 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(replace(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`
|
||||
@@ -0,0 +1,187 @@
|
||||
# When updating this package please check that all other versions of Nim
|
||||
# evaluate because they reuse definitions from the latest compiler.
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
boehmgc,
|
||||
openssl,
|
||||
pcre,
|
||||
readline,
|
||||
sqlite,
|
||||
darwin,
|
||||
Security ? darwin.Security,
|
||||
}:
|
||||
|
||||
let
|
||||
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 isPower && is32bit then
|
||||
"powerpc"
|
||||
else if isPower && 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;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "nim-unwrapped";
|
||||
version = "2.2.0";
|
||||
strictDeps = true;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://nim-lang.org/download/nim-${finalAttrs.version}.tar.xz";
|
||||
hash = "sha256-zphChJyXYOSH7N0c2t98DyhEyvrmBUAcfHKuJXZEiTw=";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
boehmgc
|
||||
openssl
|
||||
pcre
|
||||
readline
|
||||
sqlite
|
||||
] ++ lib.optional stdenv.hostPlatform.isDarwin Security;
|
||||
|
||||
patches = [
|
||||
./NIM_CONFIG_DIR.patch
|
||||
# Override compiler configuration via an environmental variable
|
||||
|
||||
./nixbuild.patch
|
||||
# Load libraries at runtime by absolute path
|
||||
|
||||
./extra-mangling-2.patch
|
||||
# Mangle store paths of modules to prevent runtime dependence.
|
||||
|
||||
./openssl.patch
|
||||
# dlopen is widely used by Python, Ruby, Perl, ... what you're really telling me here is that your OS is fundamentally broken. That might be news for you, but it isn't for me.
|
||||
];
|
||||
|
||||
configurePhase =
|
||||
let
|
||||
bootstrapCompiler = stdenv.mkDerivation {
|
||||
pname = "nim-bootstrap";
|
||||
inherit (finalAttrs) version src preBuild;
|
||||
enableParallelBuilding = true;
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dt $out/bin bin/nim
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
''
|
||||
runHook preConfigure
|
||||
cp ${bootstrapCompiler}/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.hostPlatform.isDarwin || stdenv.hostPlatform.isLinux) "-d:nativeStacktrace";
|
||||
|
||||
preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
||||
substituteInPlace makefile \
|
||||
--replace "aarch64" "arm64"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
local HOME=$TMPDIR
|
||||
./bin/nim c --parallelBuild:$NIX_BUILD_CORES koch
|
||||
./koch boot $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||
./koch toolsNoExternal $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||
./bin/nim js -d:release tools/dochack/dochack.nim
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dt $out/bin bin/*
|
||||
ln -sf $out/nim/bin/nim $out/bin/nim
|
||||
ln -sf $out/nim/lib $out/lib
|
||||
./install.sh $out
|
||||
cp -a tools dist $out/nim/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit nimHost nimTarget;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Statically typed, imperative programming language";
|
||||
homepage = "https://nim-lang.org/";
|
||||
license = licenses.mit;
|
||||
mainProgram = "nim";
|
||||
maintainers = with maintainers; [
|
||||
ehmry
|
||||
eveeifyeve
|
||||
];
|
||||
};
|
||||
|
||||
})
|
||||
@@ -6,164 +6,9 @@
|
||||
, nim-unwrapped-2, nim-unwrapped-1, nim }:
|
||||
|
||||
let
|
||||
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 isPower && is32bit then
|
||||
"powerpc"
|
||||
else if isPower && 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;
|
||||
|
||||
inherit (nim-unwrapped-2.passthru) nimHost nimTarget;
|
||||
in {
|
||||
|
||||
nim-unwrapped-2 = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "nim-unwrapped";
|
||||
version = "2.2.0";
|
||||
strictDeps = true;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://nim-lang.org/download/nim-${finalAttrs.version}.tar.xz";
|
||||
hash = "sha256-zphChJyXYOSH7N0c2t98DyhEyvrmBUAcfHKuJXZEiTw=";
|
||||
};
|
||||
|
||||
buildInputs = [ boehmgc openssl pcre readline sqlite ]
|
||||
++ lib.optional stdenv.hostPlatform.isDarwin Security;
|
||||
|
||||
patches = [
|
||||
./NIM_CONFIG_DIR.patch
|
||||
# Override compiler configuration via an environmental variable
|
||||
|
||||
./nixbuild.patch
|
||||
# Load libraries at runtime by absolute path
|
||||
|
||||
./extra-mangling-2.patch
|
||||
# Mangle store paths of modules to prevent runtime dependence.
|
||||
|
||||
./openssl.patch
|
||||
# dlopen is widely used by Python, Ruby, Perl, ... what you're really telling me here is that your OS is fundamentally broken. That might be news for you, but it isn't for me.
|
||||
];
|
||||
|
||||
configurePhase = let
|
||||
bootstrapCompiler = stdenv.mkDerivation {
|
||||
pname = "nim-bootstrap";
|
||||
inherit (finalAttrs) version src preBuild;
|
||||
enableParallelBuilding = true;
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dt $out/bin bin/nim
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in ''
|
||||
runHook preConfigure
|
||||
cp ${bootstrapCompiler}/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.hostPlatform.isDarwin || stdenv.hostPlatform.isLinux) "-d:nativeStacktrace";
|
||||
|
||||
preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
||||
substituteInPlace makefile \
|
||||
--replace "aarch64" "arm64"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
local HOME=$TMPDIR
|
||||
./bin/nim c --parallelBuild:$NIX_BUILD_CORES koch
|
||||
./koch boot $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||
./koch toolsNoExternal $kochArgs --parallelBuild:$NIX_BUILD_CORES
|
||||
./bin/nim js -d:release tools/dochack/dochack.nim
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dt $out/bin bin/*
|
||||
ln -sf $out/nim/bin/nim $out/bin/nim
|
||||
ln -sf $out/nim/lib $out/lib
|
||||
./install.sh $out
|
||||
cp -a tools dist $out/nim/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
updateScript.command = [ ./update.sh ];
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Statically typed, imperative programming language";
|
||||
homepage = "https://nim-lang.org/";
|
||||
license = licenses.mit;
|
||||
mainProgram = "nim";
|
||||
maintainers = with maintainers; [ ehmry eveeifyeve ];
|
||||
};
|
||||
});
|
||||
|
||||
nim-unwrapped-1 = nim-unwrapped-2.overrideAttrs (finalAttrs: prevAttrs: {
|
||||
version = "1.6.20";
|
||||
src = fetchurl {
|
||||
@@ -313,7 +158,7 @@ in {
|
||||
in {
|
||||
|
||||
nim2 = wrapNim {
|
||||
nim' = buildPackages.nim-unwrapped-2;
|
||||
nim' = buildPackages.nim-unwrapped-2_2;
|
||||
patches = [ ./nim2.cfg.patch ];
|
||||
};
|
||||
|
||||
|
||||
@@ -15325,8 +15325,10 @@ with pkgs;
|
||||
|
||||
inherit (callPackages ../development/compilers/nim
|
||||
{ inherit (darwin) Security; }
|
||||
) nim-unwrapped-1 nim-unwrapped-2 nim1 nim2;
|
||||
) nim-unwrapped-1 nim1 nim2;
|
||||
nim = nim2;
|
||||
nim-unwrapped = nim-unwrapped-2_2;
|
||||
nim-unwrapped-2 = nim-unwrapped-2_2;
|
||||
buildNimPackage = callPackage ../development/compilers/nim/build-nim-package.nix { };
|
||||
nimOverrides = callPackage ./nim-overrides.nix { };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user