Commit faef33ad authored by eveeifyeve's avatar eveeifyeve Committed by Emery Hemingway
Browse files

nim: 2.0.8 -> 2.2.0; nim: init updatescript;

nim: init updatescript

nim: updated hash

nim: fix patches
parent 0cc879fa
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -76,12 +76,12 @@ in {

  nim-unwrapped-2 = stdenv.mkDerivation (finalAttrs: {
    pname = "nim-unwrapped";
    version = "2.0.8";
    version = "2.2.0";
    strictDeps = true;

    src = fetchurl {
      url = "https://nim-lang.org/download/nim-${finalAttrs.version}.tar.xz";
      hash = "sha256-VwLahEcA0xKdtzFwtcYGrb37h+grgWwNkRB+ogpl3xY=";
      hash = "sha256-zphChJyXYOSH7N0c2t98DyhEyvrmBUAcfHKuJXZEiTw=";
    };

    buildInputs = [ boehmgc openssl pcre readline sqlite ]
@@ -94,7 +94,7 @@ in {
      ./nixbuild.patch
      # Load libraries at runtime by absolute path

      ./extra-mangling.patch
      ./extra-mangling-2.patch
      # Mangle store paths of modules to prevent runtime dependence.

      ./openssl.patch
@@ -151,12 +151,16 @@ in {
      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 ];
      maintainers = with maintainers; [ ehmry eveeifyeve ];
    };
  });

+48 −0
Original line number Diff line number Diff line
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 '/'
+25 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash nix-update curl coreutils jq

set -ex

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

curl_github() {
  curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "$@"
}


case "$UPDATE_NIX_ATTR_PATH" in
nim)
  latestTag=$(curl_github https://api.github.com/repos/nim-lang/Nim/releases/latest | jq -r ".tag_name")
  latestVersion="$(expr "$latestTag" : 'v\(.*\)')"

  echo "Updating Nim"
  nix-update --version "$latestVersion" \
    --override-filename "$SCRIPT_DIR/default.nix" \
  nim
*)
  echo "Unknown attr path $UPDATE_NIX_ATTR_PATH"
  ;;
esac