zqqw / pakku

Pacman wrapper with AUR support
GNU General Public License v3.0
39 stars 3 forks source link

Nim 2.0 support #29

Closed zqqw closed 1 year ago

zqqw commented 1 year ago

Info update: The Nim compile option "-d:nimPreviewSlimSystem" allows this to be tested, and with a recent nim-git build at this commit: commit 53eed2be4515a3ae853ae4d2fbd84daa49c1d6d6 Date: Sun Dec 18 22:31:13 2022 +0800 this works and builds fine - although at that point in Nim it fails on a normal build, without these modifications below! I will probably commit these small changes in preparation for Nim 2.0 but leave the -d:nimPreviewSlimSystem commented out, because that option would not be relevant in old or future versions of Nim, so users can edit the Makefile to enable it if desired - or required.

diff --git a/Makefile b/Makefile
index bae3b09..c9b2639 100644
--- a/Makefile
+++ b/Makefile
@@ -61,6 +61,7 @@ NIM_OPTIONS = \
    --putenv:'PROG_LOCALSTATEDIR'="${LOCALSTATEDIR}" \
    --putenv:'PROG_SYSCONFDIR'="${SYSCONFDIR}" \
    -d:'${NIM_TARGET}' \
+   -d:nimPreviewSlimSystem \
    --opt:'${NIM_OPTIMIZE}' \
    --hint'[Conf]':off \
    --hint'[Processing]':off \
diff --git a/lib/install.nim b/lib/install.nim
index 2a89ade..f2886df 100644
--- a/lib/install.nim
+++ b/lib/install.nim
@@ -1,5 +1,6 @@
 import
   os, posix, sequtils, strutils, sugar
+when not declared(system.stdout): import std/syncio

 proc splitCommands(params: seq[string], index: int, res: seq[seq[string]]): seq[seq[string]] =
   if index < params.len:
diff --git a/src/args.nim b/src/args.nim
index deabeff..f17f60b 100644
--- a/src/args.nim
+++ b/src/args.nim
@@ -1,6 +1,7 @@
 import
   options, os, posix, sequtils, sets, strutils, sugar,
   utils
+when not declared(system.stdout): import std/syncio

 type
   ArgumentType* {.pure.} = enum
diff --git a/src/common.nim b/src/common.nim
index da36c0d..46831ce 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -2,6 +2,7 @@ import
   options, os, osproc, posix, sequtils, sets, strutils, sugar, tables,
   args, config, format, lists, package, pacman, utils,
   "wrapper/alpm"
+when not declared(system.stdout): import std/syncio

 type
   CacheKind* {.pure.} = enum
diff --git a/src/config.nim b/src/config.nim
index 598b488..a5fab96 100644
--- a/src/config.nim
+++ b/src/config.nim
@@ -1,6 +1,7 @@
 import
   std/[options, posix, re, sequtils, sets, strutils, sugar, tables],
   utils
+when not declared(system.stdout): import std/syncio

 type
   ColorMode* {.pure.} = enum
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index ffb299e..647dac1 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -3,6 +3,7 @@ import
   "../args", "../aur", "../common", "../config", "../format", "../package",
     "../pacman", "../utils",
   "../wrapper/alpm"
+when not declared(system.stdout): import std/syncio

 const
   pacmanInfoStrings = [
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index a728851..ec7e748 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -3,6 +3,7 @@ import
   "../args", "../aur", "../config", "../common", "../format", "../lists", "../package",
     "../pacman", "../utils",
   "../wrapper/alpm"
+when not declared(system.stdout): import std/syncio

 type
   Installed = tuple[
diff --git a/src/format.nim b/src/format.nim
index cf4b9db..60c550d 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -1,6 +1,7 @@
 import
   std/[macros, options, posix, sequtils, strutils, sugar, times, unicode, terminal],
   utils
+when not declared(system.stdout): import std/syncio

 type
   PackageLineFormat* = tuple[
diff --git a/src/main.nim b/src/main.nim
index 3960d59..c6745d8 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -1,6 +1,7 @@
 import
   options, os, posix, re, sequtils, strutils, sugar,
   args, config, format, pacman, utils
+when not declared(system.stdout): import std/syncio

 import
   "feature/localquery",
diff --git a/src/package.nim b/src/package.nim
index e48b01f..9cfe49e 100644
--- a/src/package.nim
+++ b/src/package.nim
@@ -1,6 +1,7 @@
 import
   options, os, re, sequtils, sets, strutils, sugar, tables, utils,
   "wrapper/alpm"
+when not declared(system.stdout): import std/syncio

 type
   ConstraintOperation* {.pure.} = enum
diff --git a/src/pacman.nim b/src/pacman.nim
index c37a54c..ee20a07 100644
--- a/src/pacman.nim
+++ b/src/pacman.nim
@@ -1,6 +1,7 @@
 import
   macros, options, posix, sequtils, sets, strutils, sugar, tables,
   args, config, utils
+when not declared(system.stdout): import std/syncio

 type
   OpGroup* {.pure.} = enum
zqqw commented 1 year ago

Closed by https://github.com/zqqw/pakku/commit/72654defb34e9143b00d17fc75a923b5abb366da Uncomment # -d:nimPreviewSlimSystem \ in Makefile with newer versions of Nim that support this option if you like - it shouldn't make a difference to the functioning of Pakku, although the internal operation of the binary will reflect the latest developments in Nim.