diff options
50 files changed, 909 insertions, 418 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a64b6918c4997..50263b7ff7f04 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -231,3 +231,8 @@ # Cinnamon /pkgs/desktops/cinnamon @mkg20001 + +#nim +/pkgs/development/compilers/nim @ehmry +/pkgs/development/nim-packages @ehmry +/pkgs/top-level/nim-packages.nix @ehmry diff --git a/.github/labeler.yml b/.github/labeler.yml index ff831042461cc..780843a2a5533 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -72,6 +72,12 @@ - nixos/**/* - pkgs/os-specific/linux/nixos-rebuild/**/* +"6.topic: nim": + - doc/languages-frameworks/nim.section.md + - pkgs/development/compilers/nim/* + - pkgs/development/nim-packages/**/* + - pkgs/top-level/nim-packages.nix + "6.topic: ocaml": - doc/languages-frameworks/ocaml.section.md - pkgs/development/compilers/ocaml/**/* diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml index 29a1e089692f6..b010f27cac02f 100644 --- a/doc/languages-frameworks/index.xml +++ b/doc/languages-frameworks/index.xml @@ -23,6 +23,7 @@ <xi:include href="javascript.section.xml" /> <xi:include href="lua.section.xml" /> <xi:include href="maven.section.xml" /> + <xi:include href="nim.section.xml" /> <xi:include href="ocaml.section.xml" /> <xi:include href="octave.section.xml" /> <xi:include href="perl.section.xml" /> diff --git a/doc/languages-frameworks/nim.section.md b/doc/languages-frameworks/nim.section.md new file mode 100644 index 0000000000000..16dce61d71c9f --- /dev/null +++ b/doc/languages-frameworks/nim.section.md @@ -0,0 +1,91 @@ +# Nim {#nim} + +## Overview {#nim-overview} + +The Nim compiler, a builder function, and some packaged libraries are available +in Nixpkgs. Until now each compiler release has been effectively backwards +compatible so only the latest version is available. + +## Nim program packages in Nixpkgs {#nim-program-packages-in-nixpkgs} + +Nim programs can be built using `nimPackages.buildNimPackage`. In the +case of packages not containing exported library code the attribute +`nimBinOnly` should be set to `true`. + +The following example shows a Nim program that depends only on Nim libraries: + +```nix +{ lib, nimPackages, fetchurl }: + +nimPackages.buildNimPackage rec { + pname = "hottext"; + version = "1.4"; + + nimBinOnly = true; + + src = fetchurl { + url = "https://git.sr.ht/~ehmry/hottext/archive/v${version}.tar.gz"; + sha256 = "sha256-hIUofi81zowSMbt1lUsxCnVzfJGN3FEiTtN8CEFpwzY="; + }; + + buildInputs = with nimPackages; [ + bumpy + chroma + flatty + nimsimd + pixie + sdl2 + typography + vmath + zippy + ]; +} + +``` + +## Nim library packages in Nixpkgs {#nim-library-packages-in-nixpkgs} + + +Nim libraries can also be built using `nimPackages.buildNimPackage`, but +often the product of a fetcher is sufficient to satisfy a dependency. +The `fetchgit`, `fetchFromGitHub`, and `fetchNimble` functions yield an +output that can be discovered during the `configurePhase` of `buildNimPackage`. + +Nim library packages are listed in +[pkgs/top-level/nim-packages.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/nim-packages.nix) and implemented at +[pkgs/development/nim-packages](https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/nim-packages). + +The following example shows a Nim library that propagates a dependency on a +non-Nim package: +```nix +{ lib, buildNimPackage, fetchNimble, SDL2 }: + +buildNimPackage rec { + pname = "sdl2"; + version = "2.0.4"; + src = fetchNimble { + inherit pname version; + hash = "sha256-Vtcj8goI4zZPQs2TbFoBFlcR5UqDtOldaXSH/+/xULk="; + }; + propagatedBuildInputs = [ SDL2 ]; +} +``` + +## `buildNimPackage` parameters {#buildnimpackage-parameters} + +All parameters from `stdenv.mkDerivation` function are still supported. The +following are specific to `buildNimPackage`: + +* `nimBinOnly ? false`: If `true` then build only the programs listed in + the Nimble file in the packages sources. +* `nimbleFile`: Specify the Nimble file location of the package being built + rather than discover the file at build-time. +* `nimRelease ? true`: Build the package in *release* mode. +* `nimDefines ? []`: A list of Nim defines. Key-value tuples are not supported. +* `nimFlags ? []`: A list of command line arguments to pass to the Nim compiler. + Use this to specify defines with arguments in the form of `-d:${name}=${value}`. +* `nimDoc` ? false`: Build and install HTML documentation. + +* `buildInputs` ? []: The packages listed here will be searched for `*.nimble` + files which are used to populate the Nim library path. Otherwise the standard + behavior is in effect. diff --git a/pkgs/applications/science/biology/mosdepth/default.nix b/pkgs/applications/science/biology/mosdepth/default.nix index 715f2ea313b40..b6cc5e4061536 100644 --- a/pkgs/applications/science/biology/mosdepth/default.nix +++ b/pkgs/applications/science/biology/mosdepth/default.nix @@ -1,23 +1,9 @@ -{lib, stdenv, fetchFromGitHub, nim, htslib, pcre}: +{lib, nimPackages, fetchFromGitHub, pcre}: -let - hts-nim = fetchFromGitHub { - owner = "brentp"; - repo = "hts-nim"; - rev = "v0.3.4"; - sha256 = "0670phk1bq3l9j2zaa8i5wcpc5dyfrc0l2a6c21g0l2mmdczffa7"; - }; - - docopt = fetchFromGitHub { - owner = "docopt"; - repo = "docopt.nim"; - rev = "v0.6.7"; - sha256 = "1ga7ckg21fzwwvh26jp2phn2h3pvkn8g8sm13dxif33rp471bv37"; - }; - -in stdenv.mkDerivation rec { +nimPackages.buildNimPackage rec { pname = "mosdepth"; version = "0.3.2"; + nimBinOnly = true; src = fetchFromGitHub { owner = "brentp"; @@ -26,15 +12,7 @@ in stdenv.mkDerivation rec { sha256 = "sha256-uui4yC7ok+pvbXVKfBVsAarH40fnH4fnP8P4uzOqztQ="; }; - nativeBuildInputs = [ nim ]; - buildInputs = [ htslib pcre ]; - - buildPhase = '' - HOME=$TMPDIR - nim -p:${hts-nim}/src -p:${docopt}/src c --nilseqs:on -d:release mosdepth.nim - ''; - - installPhase = "install -Dt $out/bin mosdepth"; + buildInputs = with nimPackages; [ docopt hts-nim pcre ]; meta = with lib; { description = "fast BAM/CRAM depth calculation for WGS, exome, or targeted sequencing"; diff --git a/pkgs/applications/terminal-emulators/nimmm/default.nix b/pkgs/applications/terminal-emulators/nimmm/default.nix index bb09fa776b621..0e0d75ab80125 100644 --- a/pkgs/applications/terminal-emulators/nimmm/default.nix +++ b/pkgs/applications/terminal-emulators/nimmm/default.nix @@ -1,30 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, nim, termbox, pcre }: +{ lib, nimPackages, fetchFromGitHub, nim, termbox, pcre }: -let - noise = fetchFromGitHub { - owner = "jangko"; - repo = "nim-noise"; - rev = "v0.1.14"; - sha256 = "0wndiphznfyb1pac6zysi3bqljwlfwj6ziarcwnpf00sw2zni449"; - }; - - nimbox = fetchFromGitHub { - owner = "dom96"; - repo = "nimbox"; - rev = "6a56e76c01481176f16ae29b7d7c526bd83f229b"; - sha256 = "15x1sdfxa1xcqnr68705jfnlv83lm0xnp2z9iz3pgc4bz5vwn4x1"; - }; - - lscolors = fetchFromGitHub { - owner = "joachimschmidt557"; - repo = "nim-lscolors"; - rev = "v0.3.3"; - sha256 = "0526hqh46lcfsvymb67ldsc8xbfn24vicn3b8wrqnh6mag8wynf4"; - }; - -in stdenv.mkDerivation rec { +nimPackages.buildNimPackage rec { pname = "nimmm"; version = "0.2.0"; + nimBinOnly = true; src = fetchFromGitHub { owner = "joachimschmidt557"; @@ -33,17 +12,8 @@ in stdenv.mkDerivation rec { sha256 = "168n61avphbxsxfq8qzcnlqx6wgvz5yrjvs14g25cg3k46hj4xqg"; }; - nativeBuildInputs = [ nim ]; - buildInputs = [ termbox pcre ]; - - buildPhase = '' - export HOME=$TMPDIR; - nim -p:${noise} -p:${nimbox} -p:${lscolors}/src c -d:release src/nimmm.nim - ''; - - installPhase = '' - install -Dt $out/bin src/nimmm - ''; + buildInputs = [ termbox pcre ] + ++ (with nimPackages; [ noise nimbox lscolors ]); meta = with lib; { description = "Terminal file manager written in nim"; diff --git a/pkgs/development/compilers/nim/default.nix b/pkgs/development/compilers/nim/default.nix index 49e18097ab9a7..7434347f2a28f 100644 --- a/pkgs/development/compilers/nim/default.nix +++ b/pkgs/development/compilers/nim/default.nix @@ -1,8 +1,9 @@ # https://nim-lang.github.io/Nim/packaging.html # https://nim-lang.org/docs/nimc.html -{ lib, buildPackages, stdenv, fetchurl, fetchgit, fetchFromGitHub, makeWrapper -, openssl, pcre, readline, boehmgc, sqlite, nim-unwrapped }: +{ lib, callPackage, buildPackages, stdenv, fetchurl, fetchgit, fetchFromGitHub +, makeWrapper, openssl, pcre, readline, boehmgc, sqlite, nim-unwrapped +, nimble-unwrapped }: let parseCpu = platform: @@ -186,138 +187,141 @@ in { nim' = buildPackages.nim-unwrapped; nimble' = buildPackages.nimble-unwrapped; inherit (stdenv) targetPlatform; - in stdenv.mkDerivation { - name = "${targetPlatform.config}-nim-wrapper-${nim'.version}"; - inherit (nim') version; - preferLocalBuild = true; - strictDeps = true; - - nativeBuildInputs = [ makeWrapper ]; - - patches = [ - ./nim.cfg.patch - # Remove configurations that clash with ours - ]; - - unpackPhase = '' - runHook preUnpack - tar xf ${nim'.src} nim-$version/config - cd nim-$version - runHook postUnpack - ''; - - dontConfigure = true; - - buildPhase = - # Configure the Nim compiler to use $CC and $CXX as backends - # The compiler is configured by two configuration files, each with - # a different DSL. The order of evaluation matters and that order - # is not documented, so duplicate the configuration across both files. - '' - runHook preBuild - cat >> config/config.nims << WTF - - switch("os", "${nimTarget.os}") - switch("cpu", "${nimTarget.cpu}") - switch("define", "nixbuild") - - # Configure the compiler using the $CC set by Nix at build time - import strutils - let cc = getEnv"CC" - if cc.contains("gcc"): - switch("cc", "gcc") - elif cc.contains("clang"): - switch("cc", "clang") - WTF - - mv config/nim.cfg config/nim.cfg.old - cat > config/nim.cfg << WTF - os = "${nimTarget.os}" - cpu = "${nimTarget.cpu}" - define:"nixbuild" - WTF - - cat >> config/nim.cfg < config/nim.cfg.old - rm config/nim.cfg.old - - cat >> config/nim.cfg << WTF - - clang.cpp.exe %= "\$CXX" - clang.cpp.linkerexe %= "\$CXX" - clang.exe %= "\$CC" - clang.linkerexe %= "\$CC" - gcc.cpp.exe %= "\$CXX" - gcc.cpp.linkerexe %= "\$CXX" - gcc.exe %= "\$CC" - gcc.linkerexe %= "\$CC" - WTF - - runHook postBuild + self = stdenv.mkDerivation { + name = "${targetPlatform.config}-nim-wrapper-${nim'.version}"; + inherit (nim') version; + preferLocalBuild = true; + strictDeps = true; + + nativeBuildInputs = [ makeWrapper ]; + + patches = [ + ./nim.cfg.patch + # Remove configurations that clash with ours + ]; + + unpackPhase = '' + runHook preUnpack + tar xf ${nim'.src} nim-$version/config + cd nim-$version + runHook postUnpack ''; - wrapperArgs = [ - "--prefix PATH : ${lib.makeBinPath [ buildPackages.gdb ]}:${ - placeholder "out" - }/bin" - # Used by nim-gdb - - "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl pcre ]}" - # These libraries may be referred to by the standard library. - # This is broken for cross-compilation because the package - # set will be shifted back by nativeBuildInputs. - - "--set NIM_CONFIG_PATH ${placeholder "out"}/etc/nim" - # Use the custom configuration - - ''--set NIX_HARDENING_ENABLE "''${NIX_HARDENING_ENABLE/fortify}"'' - # Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds. - ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/bin $out/etc + dontConfigure = true; + + buildPhase = + # Configure the Nim compiler to use $CC and $CXX as backends + # The compiler is configured by two configuration files, each with + # a different DSL. The order of evaluation matters and that order + # is not documented, so duplicate the configuration across both files. + '' + runHook preBuild + cat >> config/config.nims << WTF + + switch("os", "${nimTarget.os}") + switch("cpu", "${nimTarget.cpu}") + switch("define", "nixbuild") + + # Configure the compiler using the $CC set by Nix at build time + import strutils + let cc = getEnv"CC" + if cc.contains("gcc"): + switch("cc", "gcc") + elif cc.contains("clang"): + switch("cc", "clang") + WTF + + mv config/nim.cfg config/nim.cfg.old + cat > config/nim.cfg << WTF + os = "${nimTarget.os}" + cpu = "${nimTarget.cpu}" + define:"nixbuild" + WTF + + cat >> config/nim.cfg < config/nim.cfg.old + rm config/nim.cfg.old + + cat >> config/nim.cfg << WTF + + clang.cpp.exe %= "\$CXX" + clang.cpp.linkerexe %= "\$CXX" + clang.exe %= "\$CC" + clang.linkerexe %= "\$CC" + gcc.cpp.exe %= "\$CXX" + gcc.cpp.linkerexe %= "\$CXX" + gcc.exe %= "\$CC" + gcc.linkerexe %= "\$CC" + WTF + + runHook postBuild + ''; + + wrapperArgs = [ + "--prefix PATH : ${lib.makeBinPath [ buildPackages.gdb ]}:${ + placeholder "out" + }/bin" + # Used by nim-gdb + + "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl pcre ]}" + # These libraries may be referred to by the standard library. + # This is broken for cross-compilation because the package + # set will be shifted back by nativeBuildInputs. + + "--set NIM_CONFIG_PATH ${placeholder "out"}/etc/nim" + # Use the custom configuration + + ''--set NIX_HARDENING_ENABLE "''${NIX_HARDENING_ENABLE/fortify}"'' + # Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds. + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin $out/etc + + cp -r config $out/etc/nim + + 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 - cp -r config $out/etc/nim + makeWrapper \ + ${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \ + --set-default CC $(command -v $CC) \ + --set-default CXX $(command -v $CXX) \ + $wrapperArgs + ln -s $out/bin/${targetPlatform.config}-nim $out/bin/nim - for binpath in ${nim'}/bin/nim?*; do - local binname=`basename $binpath` makeWrapper \ - $binpath $out/bin/${targetPlatform.config}-$binname \ + ${nim'}/bin/testament $out/bin/${targetPlatform.config}-testament \ $wrapperArgs - ln -s $out/bin/${targetPlatform.config}-$binname $out/bin/$binname - done - - makeWrapper \ - ${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \ - --set-default CC $(command -v $CC) \ - --set-default CXX $(command -v $CXX) \ - $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 + ln -s $out/bin/${targetPlatform.config}-testament $out/bin/testament - runHook postInstall - ''; + makeWrapper \ + ${nimble'}/bin/nimble $out/bin/${targetPlatform.config}-nimble \ + --suffix PATH : $out/bin + ln -s $out/bin/${targetPlatform.config}-nimble $out/bin/nimble - passthru = { - nim = nim'; - nimble = nimble'; - }; + runHook postInstall + ''; + + passthru = { + nim = nim'; + nimble = nimble'; + }; - meta = nim'.meta // { - description = nim'.meta.description - + " (${targetPlatform.config} wrapper)"; - platforms = with lib.platforms; unix ++ genode; + meta = nim'.meta // { + description = nim'.meta.description + + " (${targetPlatform.config} wrapper)"; + platforms = with lib.platforms; unix ++ genode; + }; }; + in self // { + pkgs = callPackage ../../../top-level/nim-packages.nix { nim = self; }; }; } diff --git a/pkgs/development/nim-packages/astpatternmatching/default.nix b/pkgs/development/nim-packages/astpatternmatching/default.nix new file mode 100644 index 0000000000000..6f1137ac70456 --- /dev/null +++ b/pkgs/development/nim-packages/astpatternmatching/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "krux02"; + repo = "ast-pattern-matching"; + rev = "87f7d163421af5a4f5e5cb6da7b93278e6897e96"; + sha256 = "19mb5bb6riia8380p5dpc3q0vwgrj958dd6p7vw8vkvwiqrzg6zq"; +} diff --git a/pkgs/development/nim-packages/build-nim-package/default.nix b/pkgs/development/nim-packages/build-nim-package/default.nix new file mode 100644 index 0000000000000..6c7aafd22c81e --- /dev/null +++ b/pkgs/development/nim-packages/build-nim-package/default.nix @@ -0,0 +1,43 @@ +{ lib, stdenv, nim, nim_builder }: + +{ strictDeps ? true, nativeBuildInputs ? [ ], configurePhase ? null +, buildPhase ? null, checkPhase ? null, installPhase ? null, meta ? { }, ... +}@attrs: + +stdenv.mkDerivation (attrs // { + inherit strictDeps; + nativeBuildInputs = [ nim nim_builder ] ++ nativeBuildInputs; + + configurePhase = if isNull configurePhase then '' + runHook preConfigure + find $NIX_BUILD_TOP -name .attrs.json + nim_builder --phase:configure + runHook postConfigure + '' else + buildPhase; + + buildPhase = if isNull buildPhase then '' + runHook preBuild + nim_builder --phase:build + runHook postBuild + '' else + buildPhase; + + checkPhase = if isNull checkPhase then '' + runHook preCheck + nim_builder --phase:check + runHook postCheck + '' else + checkPhase; + + installPhase = if isNull installPhase then '' + runHook preInstall + nim_builder --phase:install + runHook postInstall + '' else + installPhase; + + meta = meta // { + maintainers = (meta.maintainers or [ ]) ++ [ lib.maintainers.ehmry ]; + }; +}) diff --git a/pkgs/development/nim-packages/bumpy/default.nix b/pkgs/development/nim-packages/bumpy/default.nix new file mode 100644 index 0000000000000..9579d87d9d5d4 --- /dev/null +++ b/pkgs/development/nim-packages/bumpy/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "bumpy"; + version = "1.0.3"; + hash = "sha256-mDmDlhOGoYYjKgF5j808oT2NqRlfcOdLSDE3WtdJFQ0="; +} diff --git a/pkgs/development/nim-packages/c2nim/default.nix b/pkgs/development/nim-packages/c2nim/default.nix new file mode 100644 index 0000000000000..408e4fbee96e7 --- /dev/null +++ b/pkgs/development/nim-packages/c2nim/default.nix @@ -0,0 +1,19 @@ +{ lib, buildNimPackage, fetchFromGitHub, SDL2 }: + +buildNimPackage rec { + pname = "c2nim"; + version = "0.9.18"; + nimBinOnly = true; + src = fetchFromGitHub { + owner = "nim-lang"; + repo = pname; + rev = version; + hash = "sha256-127ux36mfC+PnS2HIQffw+z0TSvzdQXnKRxqYV3XahU="; + }; + meta = with lib; + src.meta // { + description = "Tool to translate Ansi C code to Nim"; + license = licenses.mit; + maintainers = [ maintainers.ehmry ]; + }; +} diff --git a/pkgs/development/nim-packages/chroma/default.nix b/pkgs/development/nim-packages/chroma/default.nix new file mode 100644 index 0000000000000..266cd0645f367 --- /dev/null +++ b/pkgs/development/nim-packages/chroma/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "chroma"; + version = "0.2.5"; + hash = "sha256-6lNHpO2aMorgkaPfo6kRcOs9r5R6T/kislVmkeoulw8="; +} diff --git a/pkgs/development/nim-packages/docopt/default.nix b/pkgs/development/nim-packages/docopt/default.nix new file mode 100644 index 0000000000000..38465384fbdef --- /dev/null +++ b/pkgs/development/nim-packages/docopt/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "docopt"; + repo = "docopt.nim"; + rev = "v0.6.7"; + sha256 = "1ga7ckg21fzwwvh26jp2phn2h3pvkn8g8sm13dxif33rp471bv37"; +} diff --git a/pkgs/development/nim-packages/fetch-nimble/builder.sh b/pkgs/development/nim-packages/fetch-nimble/builder.sh new file mode 100644 index 0000000000000..693ab339408ed --- /dev/null +++ b/pkgs/development/nim-packages/fetch-nimble/builder.sh @@ -0,0 +1,12 @@ +source $stdenv/setup +export HOME=$NIX_BUILD_TOP + +nimble --accept --noSSLCheck develop "${pkgname}@${version}" +# TODO: bring in the certificates for Nimble to verify the fetch of +# the package list. + +pkgdir=${NIX_BUILD_TOP}/${pkgname} + +find "$pkgdir" -name .git -print0 | xargs -0 rm -rf + +cp -a "$pkgdir" "$out" diff --git a/pkgs/development/nim-packages/fetch-nimble/default.nix b/pkgs/development/nim-packages/fetch-nimble/default.nix new file mode 100644 index 0000000000000..ccdacc8e27b9b --- /dev/null +++ b/pkgs/development/nim-packages/fetch-nimble/default.nix @@ -0,0 +1,20 @@ +{ lib, makeOverridable, stdenv, gitMinimal, nim, cacert }: + +makeOverridable ( + + { pname, version, hash ? lib.fakeHash, + + meta ? { }, passthru ? { }, preferLocalBuild ? true }: + stdenv.mkDerivation { + inherit version meta passthru preferLocalBuild; + pname = pname + "-src"; + pkgname = pname; + builder = ./builder.sh; + nativeBuildInputs = [ gitMinimal nim ]; + outputHash = hash; + outputHashAlgo = null; + outputHashMode = "recursive"; + impureEnvVars = lib.fetchers.proxyImpureEnvVars + ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ]; + GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + }) diff --git a/pkgs/development/nim-packages/flatty/default.nix b/pkgs/development/nim-packages/flatty/default.nix new file mode 100644 index 0000000000000..241b59f8230f1 --- /dev/null +++ b/pkgs/development/nim-packages/flatty/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "flatty"; + version = "0.2.1"; + hash = "sha256-TqNnRh2+i6n98ktLRVQxt9CVw17FGLNYq29rJoMus/0="; +} diff --git a/pkgs/development/nim-packages/frosty/default.nix b/pkgs/development/nim-packages/frosty/default.nix new file mode 100644 index 0000000000000..6394c455d07ff --- /dev/null +++ b/pkgs/development/nim-packages/frosty/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "disruptek"; + repo = "frosty"; + rev = "0.3.1"; + sha256 = "0hd6484ihjgl57gmqyp5xfq5prycb49k0313fqky600mhz71nmyz"; +} diff --git a/pkgs/development/nim-packages/hts-nim/default.nix b/pkgs/development/nim-packages/hts-nim/default.nix new file mode 100644 index 0000000000000..960a9e63d215f --- /dev/null +++ b/pkgs/development/nim-packages/hts-nim/default.nix @@ -0,0 +1,13 @@ +{ buildNimPackage, fetchFromGitHub, htslib }: + +buildNimPackage rec { + pname = "hts-nim"; + version = "0.3.4"; + src = fetchFromGitHub { + owner = "brentp"; + repo = pname; + rev = "v${version}"; + sha256 = "0670phk1bq3l9j2zaa8i5wcpc5dyfrc0l2a6c21g0l2mmdczffa7"; + }; + propagatedBuildInputs = [ htslib ]; +} diff --git a/pkgs/development/nim-packages/jester/default.nix b/pkgs/development/nim-packages/jester/default.nix new file mode 100644 index 0000000000000..21646f3667f03 --- /dev/null +++ b/pkgs/development/nim-packages/jester/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "dom96"; + repo = "jester"; + rev = "v0.5.0"; + sha256 = "0m8a4ss4460jd2lcbqcbdd68jhcy35xg7qdyr95mh8rflwvmcvhk"; +} diff --git a/pkgs/development/nim-packages/jsonschema/default.nix b/pkgs/development/nim-packages/jsonschema/default.nix new file mode 100644 index 0000000000000..8dc195b8b8229 --- /dev/null +++ b/pkgs/development/nim-packages/jsonschema/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "PMunch"; + repo = "jsonschema"; + rev = "7b41c03e3e1a487d5a8f6b940ca8e764dc2cbabf"; + sha256 = "1js64jqd854yjladxvnylij4rsz7212k31ks541pqrdzm6hpblbz"; +} diff --git a/pkgs/development/nim-packages/karax/default.nix b/pkgs/development/nim-packages/karax/default.nix new file mode 100644 index 0000000000000..35a5c78ee56a1 --- /dev/null +++ b/pkgs/development/nim-packages/karax/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "karaxnim"; + repo = "karax"; + rev = "1.1.2"; + sha256 = "07ykrd21hd76vlmkqpvv5xvaxw6aaq87bky47p2420ni85a6d94j"; +} diff --git a/pkgs/development/nim-packages/lscolors/default.nix b/pkgs/development/nim-packages/lscolors/default.nix new file mode 100644 index 0000000000000..5a72c46e4c503 --- /dev/null +++ b/pkgs/development/nim-packages/lscolors/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "joachimschmidt557"; + repo = "nim-lscolors"; + rev = "v0.3.3"; + sha256 = "0526hqh46lcfsvymb67ldsc8xbfn24vicn3b8wrqnh6mag8wynf4"; +} diff --git a/pkgs/development/nim-packages/markdown/default.nix b/pkgs/development/nim-packages/markdown/default.nix new file mode 100644 index 0000000000000..c893ff0e41485 --- /dev/null +++ b/pkgs/development/nim-packages/markdown/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "soasme"; + repo = "nim-markdown"; + rev = "abdbe5e"; + sha256 = "0f3c1sxvhbbds43c9l8cz69pfpf984msj1lv4pb7bzpxb5zil2wy"; +} diff --git a/pkgs/development/nim-packages/nim_builder/default.nix b/pkgs/development/nim-packages/nim_builder/default.nix new file mode 100644 index 0000000000000..34da4dfa61a07 --- /dev/null +++ b/pkgs/development/nim-packages/nim_builder/default.nix @@ -0,0 +1,19 @@ +{ lib, stdenv, nim }: + +stdenv.mkDerivation { + pname = "nim_builder"; + inherit (nim) version; + dontUnpack = true; + nativeBuildInputs = [ nim ]; + buildPhase = '' + cp ${./nim_builder.nim} nim_builder.nim + nim c --nimcache:$TMPDIR nim_builder + ''; + installPhase = '' + install -Dt $out/bin nim_builder + ''; + meta = { + description = "Internal Nixpkgs utility for buildNimPackage."; + maintainers = [ lib.maintainers.ehmry ]; + }; +} diff --git a/pkgs/development/nim-packages/nim_builder/nim_builder.nim b/pkgs/development/nim-packages/nim_builder/nim_builder.nim new file mode 100644 index 0000000000000..b8881b700047f --- /dev/null +++ b/pkgs/development/nim-packages/nim_builder/nim_builder.nim @@ -0,0 +1,166 @@ +# SPDX-FileCopyrightText: 2021 Nixpkgs/NixOS contributors +## Custom Nim builder for Nixpkgs. + +import std/[os, osproc, parseutils, sequtils, streams, strutils] + +proc findNimbleFile(): string = + ## Copied from Nimble. + ## Copyright (c) 2015, Dominik Picheta + ## BSD3 + let dir = getCurrentDir() + result = "" + var hits = 0 + for kind, path in walkDir(dir): + if kind in {pcFile, pcLinkToFile}: + let ext = path.splitFile.ext + if ext == ".nimble": + result = path + inc hits + if hits >= 2: + quit("Only one .nimble file should be present in " & dir) + elif hits == 0: + quit("Could not find a file with a .nimble extension in " & dir) + +proc getEnvBool(key: string; default = false): bool = + ## Parse a boolean environmental variable. + let val = getEnv(key) + if val == "": default + else: parseBool(val) + +proc getNimbleFilePath(): string = + ## Get the Nimble file for the current package. + if existsEnv"nimbleFile": + getEnv"nimbleFile" + else: + findNimbleFile() + +proc getNimbleValue(filePath, key: string; default = ""): string = + ## Extract a string value from the Nimble file at ``filePath``. + var + fs = newFileStream(filePath, fmRead) + line: string + if fs.isNil: + quit("could not open " & filePath) + while fs.readline(line): + if line.startsWith(key): + var i = key.len + i.inc skipWhile(line, Whitespace, i) + if line[i] == '=': + inc i + i.inc skipWhile(line, Whitespace, i) + discard parseUntil(line, result, Newlines, i) + if result.len > 0 and result[0] == '"': + result = result.unescape + return + default + +proc getNimbleValues(filePath, key: string): seq[string] = + ## Extract a string sequence from the Nimble file at ``filePath``. + var gunk = getNimbleValue(filePath, key) + result = gunk.strip(chars = {'@', '[', ']'}).split(',') + if result == @[""]: reset result + apply(result) do (s: var string): + s = s.strip() + if s.len > 0 and s[0] == '"': + s = s.unescape() + +proc configurePhase*() = + ## Generate "config.nims" which will be read by the Nim + ## compiler during later phases. + const configFilePath = "config.nims" + echo "generating ", configFilePath + let + nf = getNimbleFilePath() + mode = + if fileExists configFilePath: fmAppend + else: fmWrite + var cfg = newFileStream(configFilePath, mode) + proc switch(key, val: string) = + cfg.writeLine("switch(", key.escape, ",", val.escape, ")") + switch("backend", nf.getNimbleValue("backend", "c")) + switch("nimcache", getEnv("NIX_BUILD_TOP", ".") / "nimcache") + if getEnvBool("nimRelease", true): + switch("define", "release") + for def in getEnv("nimDefines").split: + if def != "": + switch("define", def) + for input in getEnv("buildInputs").split: + if input != "": + for nimbleFile in walkFiles(input / "*.nimble"): + let inputSrc = normalizedPath( + input / nimbleFile.getNimbleValue("srcDir", ".")) + echo "found nimble input ", inputSrc + switch("path", inputSrc) + close(cfg) + +proc buildPhase*() = + ## Build the programs listed in the Nimble file and + ## optionally some documentation. + var cmds: seq[string] + proc before(idx: int) = + echo "build job ", idx, ": ", cmds[idx] + let + nf = getNimbleFilePath() + bins = nf.getNimbleValues("bin") + srcDir = nf.getNimbleValue("srcDir", ".") + binDir = getenv("outputBin", getenv("out", "/dev/null")) / "bin" + if bins != @[]: + for bin in bins: + cmds.add("nim compile $# --outdir:$# $#" % + [getenv"nimFlags", binDir, normalizedPath(srcDir / bin)]) + if getEnvBool"nimDoc": + echo "generating documentation" + let docDir = getenv("outputDoc", (getenv("out", "/dev/null") / "doc")) + for path in walkFiles(srcDir / "*.nim"): + cmds.add("nim doc --outdir:$# $#" % [docDir, path]) + if cmds.len > 0: + let err = execProcesses( + cmds, n = 1, + beforeRunEvent = before) + if err != 0: quit("build phase failed", err) + +proc installPhase*() = + ## Install the Nim sources if ``nimBinOnly`` is not + ## set in the environment. + if not getEnvBool"nimBinOnly": + let + nf = getNimbleFilePath() + srcDir = nf.getNimbleValue("srcDir", ".") + devDir = getenv("outputDev", getenv("out", "/dev/null")) + echo "Install ", srcDir, " to ", devDir + copyDir(normalizedPath(srcDir), normalizedPath(devDir / srcDir)) + copyFile(nf, devDir / nf.extractFilename) + +proc checkPhase*() = + ## Build and run the tests in ``tests``. + var cmds: seq[string] + proc before(idx: int) = + echo "check job ", idx, ": ", cmds[idx] + for path in walkPattern("tests/t*.nim"): + cmds.add("nim r $#" % [path]) + let err = execProcesses( + cmds, n = 1, + beforeRunEvent = before) + if err != 0: quit("check phase failed", err) + +when isMainModule: + import std/parseopt + var phase: string + + for kind, key, val in getopt(): + case kind + of cmdLongOption: + case key.toLowerAscii + of "phase": + if phase != "": quit("only a single phase may be specified") + phase = val + else: quit("unhandled argument " & key) + of cmdEnd: discard + else: quit("unhandled argument " & key) + + case phase + of "configure": configurePhase() + of "build": buildPhase() + of "install": installPhase() + of "check": checkPhase() + else: quit("unhandled phase " & phase) diff --git a/pkgs/development/nim-packages/nimbox/default.nix b/pkgs/development/nim-packages/nimbox/default.nix new file mode 100644 index 0000000000000..53663c6428105 --- /dev/null +++ b/pkgs/development/nim-packages/nimbox/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "dom96"; + repo = "nimbox"; + rev = "6a56e76c01481176f16ae29b7d7c526bd83f229b"; + sha256 = "15x1sdfxa1xcqnr68705jfnlv83lm0xnp2z9iz3pgc4bz5vwn4x1"; +} diff --git a/pkgs/development/nim-packages/nimcrypto/default.nix b/pkgs/development/nim-packages/nimcrypto/default.nix new file mode 100644 index 0000000000000..6c212ef45f1a6 --- /dev/null +++ b/pkgs/development/nim-packages/nimcrypto/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "cheatfate"; + repo = "nimcrypto"; + rev = "a5742a9a214ac33f91615f3862c7b099aec43b00"; + sha256 = "0al0jsaicm8vyr63n909dq1glhvpra1n9sllmj0r7lsjsdb59wsz"; +} diff --git a/pkgs/development/nim-packages/nimsimd/default.nix b/pkgs/development/nim-packages/nimsimd/default.nix new file mode 100644 index 0000000000000..9ccd96453572c --- /dev/null +++ b/pkgs/development/nim-packages/nimsimd/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "nimsimd"; + version = "1.0.0"; + hash = "sha256-kp61fylAJ6MSN9hLYLi7CU2lxVR/lbrNCvZTe0LJLGo="; +} diff --git a/pkgs/development/nim-packages/noise/default.nix b/pkgs/development/nim-packages/noise/default.nix new file mode 100644 index 0000000000000..7931467dbbd5a --- /dev/null +++ b/pkgs/development/nim-packages/noise/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "jangko"; + repo = "nim-noise"; + rev = "v0.1.14"; + sha256 = "0wndiphznfyb1pac6zysi3bqljwlfwj6ziarcwnpf00sw2zni449"; +} diff --git a/pkgs/development/nim-packages/packedjson/default.nix b/pkgs/development/nim-packages/packedjson/default.nix new file mode 100644 index 0000000000000..9edad962d589b --- /dev/null +++ b/pkgs/development/nim-packages/packedjson/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "Araq"; + repo = "packedjson"; + rev = "7198cc8"; + sha256 = "1ay2zd88q8hvpvigsg8h0y5vc65hk3lk0d48fy9hwg4lcng19mp1"; +} diff --git a/pkgs/development/nim-packages/pixie/default.nix b/pkgs/development/nim-packages/pixie/default.nix new file mode 100644 index 0000000000000..2262ccf23721b --- /dev/null +++ b/pkgs/development/nim-packages/pixie/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "pixie"; + version = "1.1.3"; + hash = "sha256-xKIejVxOd19mblL1ZwpJH91dgKQS5g8U08EL8lGGelA="; +} diff --git a/pkgs/development/nim-packages/redis/default.nix b/pkgs/development/nim-packages/redis/default.nix new file mode 100644 index 0000000000000..1768bf1976f52 --- /dev/null +++ b/pkgs/development/nim-packages/redis/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "zedeus"; + repo = "redis"; + rev = "94bcbf1"; + sha256 = "1p9zv4f4lqrjqa8fk98cb89b9fzlf866jc584ll9sws14904i80j"; +} diff --git a/pkgs/development/nim-packages/redpool/default.nix b/pkgs/development/nim-packages/redpool/default.nix new file mode 100644 index 0000000000000..ef14854b32dcb --- /dev/null +++ b/pkgs/development/nim-packages/redpool/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "zedeus"; + repo = "redpool"; + rev = "57aeb25"; + sha256 = "0fph7qlia6fvya1zqzbgvww2hk5pd0vq1wlf9ij9jyn655mg0w3q"; +} diff --git a/pkgs/development/nim-packages/regex/default.nix b/pkgs/development/nim-packages/regex/default.nix new file mode 100644 index 0000000000000..d89fbdd605387 --- /dev/null +++ b/pkgs/development/nim-packages/regex/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "nitely"; + repo = "nim-regex"; + rev = "2e32fdc"; + sha256 = "1hrl40mwql7nh4wc7sdhmk8bj5728b93v5a93j49v660l0rn4qx8"; +} diff --git a/pkgs/development/nim-packages/sass/default.nix b/pkgs/development/nim-packages/sass/default.nix new file mode 100644 index 0000000000000..79885ed9ec5a6 --- /dev/null +++ b/pkgs/development/nim-packages/sass/default.nix @@ -0,0 +1,13 @@ +{ buildNimPackage, fetchFromGitHub, libsass }: + +buildNimPackage rec { + pname = "sass"; + version = "e683aa1"; + src = fetchFromGitHub { + owner = "dom96"; + repo = pname; + rev = version; + sha256 = "0qvly5rilsqqsyvr67pqhglm55ndc4nd6v90jwswbnigxiqf79lc"; + }; + propagatedBuildInputs = [ libsass ]; +} diff --git a/pkgs/development/nim-packages/sdl2/default.nix b/pkgs/development/nim-packages/sdl2/default.nix new file mode 100644 index 0000000000000..ddcdf072c6b4f --- /dev/null +++ b/pkgs/development/nim-packages/sdl2/default.nix @@ -0,0 +1,17 @@ +{ lib, buildNimPackage, fetchNimble, SDL2 }: + +buildNimPackage rec { + pname = "sdl2"; + version = "2.0.4"; + src = fetchNimble { + inherit pname version; + hash = "sha256-Vtcj8goI4zZPQs2TbFoBFlcR5UqDtOldaXSH/+/xULk="; + }; + propagatedBuildInputs = [ SDL2 ]; + doCheck = true; + meta = { + description = "Nim wrapper for SDL 2.x"; + platforms = lib.platforms.linux; # Problems with Darwin. + license = [ lib.licenses.mit ]; + }; +} diff --git a/pkgs/development/nim-packages/segmentation/default.nix b/pkgs/development/nim-packages/segmentation/default.nix new file mode 100644 index 0000000000000..c695cd00ca92b --- /dev/null +++ b/pkgs/development/nim-packages/segmentation/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "nitely"; + repo = "nim-segmentation"; + rev = "v0.1.0"; + sha256 = "007bkx8dwy8n340zbp6wyqfsq9bh6q5ykav1ywdlwykyp1n909bh"; +} diff --git a/pkgs/development/nim-packages/supersnappy/default.nix b/pkgs/development/nim-packages/supersnappy/default.nix new file mode 100644 index 0000000000000..471543eca4115 --- /dev/null +++ b/pkgs/development/nim-packages/supersnappy/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "guzba"; + repo = "supersnappy"; + rev = "1.1.5"; + sha256 = "1y26sgnszvdf5sn7j0jx2dpd4i03mvbk9i9ni9kbyrs798bjwi6z"; +} diff --git a/pkgs/development/nim-packages/typography/default.nix b/pkgs/development/nim-packages/typography/default.nix new file mode 100644 index 0000000000000..59037cbd9dd33 --- /dev/null +++ b/pkgs/development/nim-packages/typography/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "typography"; + version = "0.7.9"; + hash = "sha256-IYjw3PCp5XzVed2fGGCt9Hb60cxFeF0BUZ7L5PedTLU="; +} diff --git a/pkgs/development/nim-packages/unicodedb/default.nix b/pkgs/development/nim-packages/unicodedb/default.nix new file mode 100644 index 0000000000000..8b60710e82106 --- /dev/null +++ b/pkgs/development/nim-packages/unicodedb/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "nitely"; + repo = "nim-unicodedb"; + rev = "v0.9.0"; + sha256 = "06j8d0bjbpv1iibqlmrac4qb61ggv17hvh6nv4pbccqk1rlpxhsq"; +} diff --git a/pkgs/development/nim-packages/unicodeplus/default.nix b/pkgs/development/nim-packages/unicodeplus/default.nix new file mode 100644 index 0000000000000..772524eaf94b5 --- /dev/null +++ b/pkgs/development/nim-packages/unicodeplus/default.nix @@ -0,0 +1,8 @@ +{ fetchFromGitHub }: + +fetchFromGitHub { + owner = "nitely"; + repo = "nim-unicodeplus"; + rev = "v0.8.0"; + sha256 = "181wzwivfgplkqn5r4crhnaqgsza7x6fi23i86djb2dxvm7v6qxk"; +} diff --git a/pkgs/development/nim-packages/vmath/default.nix b/pkgs/development/nim-packages/vmath/default.nix new file mode 100644 index 0000000000000..9ca48c43d7f4f --- /dev/null +++ b/pkgs/development/nim-packages/vmath/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "vmath"; + version = "1.0.3"; + hash = "sha256-zzSKXjuTZ46HTFUs0N47mxEKTKIdS3dwr+60sQYSdn0="; +} diff --git a/pkgs/development/nim-packages/zippy/default.nix b/pkgs/development/nim-packages/zippy/default.nix new file mode 100644 index 0000000000000..230892b688992 --- /dev/null +++ b/pkgs/development/nim-packages/zippy/default.nix @@ -0,0 +1,7 @@ +{ fetchNimble }: + +fetchNimble { + pname = "zippy"; + version = "0.5.6"; + hash = "sha256-axp4t9+8TFSpvnATlRKZyuOGLA0e/XKfvrVSwreXpC4="; +} diff --git a/pkgs/development/tools/misc/nimlsp/default.nix b/pkgs/development/tools/misc/nimlsp/default.nix index b1d59c9450acc..0e837b8fd614d 100644 --- a/pkgs/development/tools/misc/nimlsp/default.nix +++ b/pkgs/development/tools/misc/nimlsp/default.nix @@ -1,22 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, srcOnly, nim }: -let - astpatternmatching = fetchFromGitHub { - owner = "krux02"; - repo = "ast-pattern-matching"; - rev = "87f7d163421af5a4f5e5cb6da7b93278e6897e96"; - sha256 = "19mb5bb6riia8380p5dpc3q0vwgrj958dd6p7vw8vkvwiqrzg6zq"; - }; +{ lib, nimPackages, fetchFromGitHub, srcOnly, nim }: - jsonschema = fetchFromGitHub { - owner = "PMunch"; - repo = "jsonschema"; - rev = "7b41c03e3e1a487d5a8f6b940ca8e764dc2cbabf"; - sha256 = "1js64jqd854yjladxvnylij4rsz7212k31ks541pqrdzm6hpblbz"; - }; -in -stdenv.mkDerivation rec { +nimPackages.buildNimPackage rec { pname = "nimlsp"; version = "0.3.2"; + nimBinOnly = true; src = fetchFromGitHub { owner = "PMunch"; @@ -25,18 +12,15 @@ stdenv.mkDerivation rec { sha256 = "1lm823nvpp3bj9527jd8n1jxh6y8p8ngkfkj91p94m7ffai6jazq"; }; - nativeBuildInputs = [ nim ]; + buildInputs = with nimPackages; [ astpatternmatching jsonschema ]; - buildPhase = '' - export HOME=$TMPDIR - nim -d:release -p:${astpatternmatching}/src -p:${jsonschema}/src \ - c --threads:on -d:nimcore -d:nimsuggest -d:debugCommunication \ - -d:debugLogging -d:explicitSourcePath=${srcOnly nim.passthru.nim} -d:tempDir=/tmp src/nimlsp - ''; + nimFlags = [ + "--threads:on" + "-d:explicitSourcePath=${srcOnly nimPackages.nim.passthru.nim}" + "-d:tempDir=/tmp" + ]; - installPhase = '' - install -Dt $out/bin src/nimlsp - ''; + nimDefines = [ "nimcore" "nimsuggest" "debugCommunication" "debugLogging" ]; meta = with lib; { description = "Language Server Protocol implementation for Nim"; diff --git a/pkgs/development/tools/nrpl/default.nix b/pkgs/development/tools/nrpl/default.nix index 67a86ca8dec59..84147faf74e5a 100644 --- a/pkgs/development/tools/nrpl/default.nix +++ b/pkgs/development/tools/nrpl/default.nix @@ -1,8 +1,9 @@ -{ stdenv, lib, fetchFromGitHub, fetchpatch, makeWrapper, nim, pcre, tinycc }: +{ lib, nimPackages, fetchFromGitHub, fetchpatch, makeWrapper, pcre, tinycc }: -stdenv.mkDerivation { +nimPackages.buildNimPackage { pname = "nrpl"; version = "20150522"; + nimBinOnly = true; src = fetchFromGitHub { owner = "wheineman"; @@ -12,7 +13,7 @@ stdenv.mkDerivation { }; nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ nim pcre ]; + buildInputs = [ pcre ]; patches = [ (fetchpatch { @@ -24,16 +25,9 @@ stdenv.mkDerivation { NIX_LDFLAGS = "-lpcre"; - buildPhase = '' - HOME=$TMPDIR - nim c -d:release nrpl.nim - ''; - - installPhase = "install -Dt $out/bin nrpl"; - postFixup = '' wrapProgram $out/bin/nrpl \ - --prefix PATH : ${lib.makeBinPath [ nim tinycc ]} + --prefix PATH : ${lib.makeBinPath [ nimPackages.nim tinycc ]} ''; meta = with lib; { diff --git a/pkgs/servers/nitter/default.nix b/pkgs/servers/nitter/default.nix index b5137c92b4503..36bffaa3ec611 100644 --- a/pkgs/servers/nitter/default.nix +++ b/pkgs/servers/nitter/default.nix @@ -1,99 +1,9 @@ -{ lib -, stdenv -, nixosTests -, fetchFromGitHub -, nim -, libsass -}: +{ lib, nimPackages, nixosTests, fetchFromGitHub, libsass }: -let - jester = fetchFromGitHub { - owner = "dom96"; - repo = "jester"; - rev = "v0.5.0"; - sha256 = "0m8a4ss4460jd2lcbqcbdd68jhcy35xg7qdyr95mh8rflwvmcvhk"; - }; - karax = fetchFromGitHub { - owner = "karaxnim"; - repo = "karax"; - rev = "1.1.2"; - sha256 = "07ykrd21hd76vlmkqpvv5xvaxw6aaq87bky47p2420ni85a6d94j"; - }; - sass = fetchFromGitHub { - owner = "dom96"; - repo = "sass"; - rev = "e683aa1"; - sha256 = "0qvly5rilsqqsyvr67pqhglm55ndc4nd6v90jwswbnigxiqf79lc"; - }; - regex = fetchFromGitHub { - owner = "nitely"; - repo = "nim-regex"; - rev = "2e32fdc"; - sha256 = "1hrl40mwql7nh4wc7sdhmk8bj5728b93v5a93j49v660l0rn4qx8"; - }; - unicodedb = fetchFromGitHub { - owner = "nitely"; - repo = "nim-unicodedb"; - rev = "v0.9.0"; - sha256 = "06j8d0bjbpv1iibqlmrac4qb61ggv17hvh6nv4pbccqk1rlpxhsq"; - }; - unicodeplus= fetchFromGitHub { - owner = "nitely"; - repo = "nim-unicodeplus"; - rev = "v0.8.0"; - sha256 = "181wzwivfgplkqn5r4crhnaqgsza7x6fi23i86djb2dxvm7v6qxk"; - }; - segmentation = fetchFromGitHub { - owner = "nitely"; - repo = "nim-segmentation"; - rev = "v0.1.0"; - sha256 = "007bkx8dwy8n340zbp6wyqfsq9bh6q5ykav1ywdlwykyp1n909bh"; - }; - nimcrypto = fetchFromGitHub { - owner = "cheatfate"; - repo = "nimcrypto"; - rev = "a5742a9a214ac33f91615f3862c7b099aec43b00"; - sha256 = "0al0jsaicm8vyr63n909dq1glhvpra1n9sllmj0r7lsjsdb59wsz"; - }; - markdown = fetchFromGitHub { - owner = "soasme"; - repo = "nim-markdown"; - rev = "abdbe5e"; - sha256 = "0f3c1sxvhbbds43c9l8cz69pfpf984msj1lv4pb7bzpxb5zil2wy"; - }; - packedjson = fetchFromGitHub { - owner = "Araq"; - repo = "packedjson"; - rev = "7198cc8"; - sha256 = "1ay2zd88q8hvpvigsg8h0y5vc65hk3lk0d48fy9hwg4lcng19mp1"; - }; - supersnappy = fetchFromGitHub { - owner = "guzba"; - repo = "supersnappy"; - rev = "1.1.5"; - sha256 = "1y26sgnszvdf5sn7j0jx2dpd4i03mvbk9i9ni9kbyrs798bjwi6z"; - }; - redpool = fetchFromGitHub { - owner = "zedeus"; - repo = "redpool"; - rev = "57aeb25"; - sha256 = "0fph7qlia6fvya1zqzbgvww2hk5pd0vq1wlf9ij9jyn655mg0w3q"; - }; - frosty = fetchFromGitHub { - owner = "disruptek"; - repo = "frosty"; - rev = "0.3.1"; - sha256 = "0hd6484ihjgl57gmqyp5xfq5prycb49k0313fqky600mhz71nmyz"; - }; - redis = fetchFromGitHub { - owner = "zedeus"; - repo = "redis"; - rev = "94bcbf1"; - sha256 = "1p9zv4f4lqrjqa8fk98cb89b9fzlf866jc584ll9sws14904i80j"; - }; -in stdenv.mkDerivation rec { +nimPackages.buildNimPackage rec { pname = "nitter"; version = "unstable-2021-07-18"; + nimBinOnly = true; src = fetchFromGitHub { owner = "zedeus"; @@ -102,28 +12,33 @@ in stdenv.mkDerivation rec { sha256 = "1dl8ndyv8m1hnydrp5xilcpp2cfbp02d5jap3y42i4nazc9ar6p4"; }; - nativeBuildInputs = [ nim ]; - buildInputs = [ libsass ]; - - buildPhase = '' - runHook preBuild - export HOME=$TMPDIR - nim -d:release -p:${jester} -p:${karax} -p:${sass}/src -p:${regex}/src -p:${unicodedb}/src -p:${unicodeplus}/src -p:${segmentation}/src -p:${nimcrypto} -p:${markdown}/src -p:${packedjson} -p:${supersnappy}/src -p:${redpool}/src -p:${frosty} -p:${redis}/src c src/$pname - nim -p:${sass}/src c --hint[Processing]:off -r tools/gencss - runHook postBuild + buildInputs = with nimPackages; [ + jester + karax + sass + regex + unicodedb + unicodeplus + segmentation + nimcrypto + markdown + packedjson + supersnappy + redpool + frosty + redis + ]; + + postBuild = '' + nim c --hint[Processing]:off -r tools/gencss ''; - installPhase = '' - runHook preInstall - install -Dt $out/bin src/$pname + postInstall = '' mkdir -p $out/share/nitter cp -r public $out/share/nitter/public - runHook postInstall ''; - passthru.tests = { - inherit (nixosTests) nitter; - }; + passthru.tests = { inherit (nixosTests) nitter; }; meta = with lib; { description = "Alternative Twitter front-end"; diff --git a/pkgs/tools/text/hottext/default.nix b/pkgs/tools/text/hottext/default.nix index ca0cbf9d1a090..6fe7a686c1006 100644 --- a/pkgs/tools/text/hottext/default.nix +++ b/pkgs/tools/text/hottext/default.nix @@ -1,81 +1,30 @@ -{ lib, stdenv, fetchurl, fetchFromGitHub, nim, gentium, SDL2, makeDesktopItem }: +{ lib, nimPackages, fetchurl, gentium, makeDesktopItem }: -let - treeformLibs = lib.attrsets.mapAttrsToList (repo: args: - fetchFromGitHub ({ - inherit repo; - owner = "treeform"; - } // args)) { - bumpy = { - rev = "1.0.3"; - sha256 = "sha256-mDmDlhOGoYYjKgF5j808oT2NqRlfcOdLSDE3WtdJFQ0="; - }; - chroma = { - rev = "0.2.5"; - sha256 = "sha256-6lNHpO2aMorgkaPfo6kRcOs9r5R6T/kislVmkeoulw8="; - }; - flatty = { - rev = "0.2.1"; - sha256 = "sha256-TqNnRh2+i6n98ktLRVQxt9CVw17FGLNYq29rJoMus/0="; - }; - pixie = { - rev = "1.1.3"; - sha256 = "sha256-xKIejVxOd19mblL1ZwpJH91dgKQS5g8U08EL8lGGelA="; - }; - typography = { - rev = "0.7.9"; - sha256 = "sha256-IYjw3PCp5XzVed2fGGCt9Hb60cxFeF0BUZ7L5PedTLU="; - }; - vmath = { - rev = "1.0.3"; - sha256 = "sha256-zzSKXjuTZ46HTFUs0N47mxEKTKIdS3dwr+60sQYSdn0="; - }; - }; - - nimLibs = treeformLibs ++ [ - (fetchFromGitHub { - owner = "nim-lang"; - repo = "sdl2"; - rev = "v2.0.2"; - sha256 = "sha256-Ivx/gxDa2HVDjCVrJVu23i4d0pDzzv+ThmwqNjtkjsA="; - }) - (fetchFromGitHub { - owner = "guzba"; - repo = "nimsimd"; - rev = "1.0.0"; - sha256 = "sha256-kp61fylAJ6MSN9hLYLi7CU2lxVR/lbrNCvZTe0LJLGo="; - }) - (fetchFromGitHub { - owner = "guzba"; - repo = "zippy"; - rev = "0.5.6"; - sha256 = "sha256-axp4t9+8TFSpvnATlRKZyuOGLA0e/XKfvrVSwreXpC4="; - }) - ]; - -in stdenv.mkDerivation rec { +nimPackages.buildNimPackage rec { pname = "hottext"; version = "1.4"; + nimBinOnly = true; + src = fetchurl { url = "https://git.sr.ht/~ehmry/hottext/archive/v${version}.tar.gz"; sha256 = "sha256-hIUofi81zowSMbt1lUsxCnVzfJGN3FEiTtN8CEFpwzY="; }; - nativeBuildInputs = [ nim ]; - buildInputs = [ SDL2 ]; - - nimFlags = [ "-d:release" ] ++ map (lib: "--path:${lib}/src") nimLibs; + buildInputs = with nimPackages; [ + bumpy + chroma + flatty + nimsimd + pixie + sdl2 + typography + vmath + zippy + ]; HOTTEXT_FONT_PATH = "${gentium}/share/fonts/truetype/GentiumPlus-Regular.ttf"; - buildPhase = '' - runHook preBuild - HOME=$TMPDIR - nim $nimFlags compile src/$pname - runHook postBuild - ''; - desktopItem = makeDesktopItem { categories = "Utility;"; comment = meta.description; @@ -84,11 +33,8 @@ in stdenv.mkDerivation rec { name = pname; }; - installPhase = '' - runHook preInstall - install -Dt $out/bin src/$pname + postInstall = '' cp -r $desktopItem/* $out - runHook postInstall ''; meta = with lib; { diff --git a/pkgs/tools/wayland/swaycwd/default.nix b/pkgs/tools/wayland/swaycwd/default.nix index 36e223f8d4ca6..401144f74d2a9 100644 --- a/pkgs/tools/wayland/swaycwd/default.nix +++ b/pkgs/tools/wayland/swaycwd/default.nix @@ -1,8 +1,8 @@ -{ lib, nim, stdenv, fetchFromGitLab +{ lib, nimPackages, fetchFromGitLab , enableShells ? [ "bash" "zsh" "fish" "sh" "posh" ] }: -stdenv.mkDerivation { +nimPackages.buildNimPackage { name = "swaycwd"; version = "0.0.1"; @@ -13,27 +13,18 @@ stdenv.mkDerivation { hash = "sha256-MkyY3wWByQo0l0J28xKDfGtxfazVPRyZHCObl9Fszh4="; }; - configurePhase = '' - runHook preConfigure + preConfigure = '' { echo 'let enabledShells: seq[string] = @${builtins.toJSON enableShells}' echo 'export enabledShells' } > shells.nim - runHook postConfigure + cat << EOF > swaycwd.nimble + srcDir = "." + bin = "swaycwd" + EOF ''; - nativeBuildInputs = [ nim ]; - - buildPhase = '' - export HOME=$TMPDIR - nim c --opt:speed -d:release swaycwd.nim - ''; - - installPhase = '' - runHook preInstall - install -D -m555 -t $out/bin swaycwd - runHook postInstall - ''; + nimFlags = [ "--opt:speed" ]; meta = with lib; { homepage = "https://gitlab.com/cab404/swaycwd"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5c1caa45568e6..96873691fcccf 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12210,6 +12210,7 @@ with pkgs; inherit (callPackages ../development/compilers/nim { }) nim-unwrapped nimble-unwrapped nim; + nimPackages = recurseIntoAttrs nim.pkgs; nrpl = callPackage ../development/tools/nrpl { }; diff --git a/pkgs/top-level/nim-packages.nix b/pkgs/top-level/nim-packages.nix new file mode 100644 index 0000000000000..5d45b0c5eca96 --- /dev/null +++ b/pkgs/top-level/nim-packages.nix @@ -0,0 +1,75 @@ +{ lib, pkgs, stdenv, newScope, nim, fetchFromGitHub }: + +lib.makeScope newScope (self: + let callPackage = self.callPackage; + in { + inherit nim; + nim_builder = callPackage ../development/nim-packages/nim_builder { }; + buildNimPackage = + callPackage ../development/nim-packages/build-nim-package { }; + fetchNimble = callPackage ../development/nim-packages/fetch-nimble { }; + + astpatternmatching = + callPackage ../development/nim-packages/astpatternmatching { }; + + bumpy = callPackage ../development/nim-packages/bumpy { }; + + chroma = callPackage ../development/nim-packages/chroma { }; + + c2nim = callPackage ../development/nim-packages/c2nim { }; + + docopt = callPackage ../development/nim-packages/docopt { }; + + flatty = callPackage ../development/nim-packages/flatty { }; + + frosty = callPackage ../development/nim-packages/frosty { }; + + hts-nim = callPackage ../development/nim-packages/hts-nim { }; + + jester = callPackage ../development/nim-packages/jester { }; + + jsonschema = callPackage ../development/nim-packages/jsonschema { }; + + karax = callPackage ../development/nim-packages/karax { }; + + lscolors = callPackage ../development/nim-packages/lscolors { }; + + markdown = callPackage ../development/nim-packages/markdown { }; + + nimcrypto = callPackage ../development/nim-packages/nimcrypto { }; + + nimbox = callPackage ../development/nim-packages/nimbox { }; + + nimsimd = callPackage ../development/nim-packages/nimsimd { }; + + noise = callPackage ../development/nim-packages/noise { }; + + packedjson = callPackage ../development/nim-packages/packedjson { }; + + pixie = callPackage ../development/nim-packages/pixie { }; + + redis = callPackage ../development/nim-packages/redis { }; + + redpool = callPackage ../development/nim-packages/redpool { }; + + regex = callPackage ../development/nim-packages/regex { }; + + sass = callPackage ../development/nim-packages/sass { }; + + sdl2 = callPackage ../development/nim-packages/sdl2 { }; + + segmentation = callPackage ../development/nim-packages/segmentation { }; + + supersnappy = callPackage ../development/nim-packages/supersnappy { }; + + typography = callPackage ../development/nim-packages/typography { }; + + unicodedb = callPackage ../development/nim-packages/unicodedb { }; + + unicodeplus = callPackage ../development/nim-packages/unicodeplus { }; + + vmath = callPackage ../development/nim-packages/vmath { }; + + zippy = callPackage ../development/nim-packages/zippy { }; + + }) |