From 39d4eace911f9e838df023ad80f52132380e01c2 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 20 Nov 2023 10:12:30 +0200 Subject: [PATCH] nimPackages.buildNimPackage: move to top-level --- .../nim/build-nim-package.nix} | 16 +++++++++++----- pkgs/top-level/all-packages.nix | 1 + pkgs/top-level/nim-packages.nix | 8 +++++--- 3 files changed, 17 insertions(+), 8 deletions(-) rename pkgs/development/{nim-packages/build-nim-package/default.nix => compilers/nim/build-nim-package.nix} (63%) diff --git a/pkgs/development/nim-packages/build-nim-package/default.nix b/pkgs/development/compilers/nim/build-nim-package.nix similarity index 63% rename from pkgs/development/nim-packages/build-nim-package/default.nix rename to pkgs/development/compilers/nim/build-nim-package.nix index 6e20b78899f6..d11eb7cd8e30 100644 --- a/pkgs/development/nim-packages/build-nim-package/default.nix +++ b/pkgs/development/compilers/nim/build-nim-package.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, nim, nim_builder }: +{ lib, stdenv, nim1, nim2, nim_builder, defaultNimVersion ? 2 }: pkgArgs: let @@ -27,13 +27,19 @@ let nim_builder --phase:install runHook postInstall ''; - meta = { inherit (nim.meta) maintainers platforms; }; + meta = { inherit (nim2.meta) maintainers platforms; }; }; - inputsOverride = - { depsBuildBuild ? [ ], nativeBuildInputs ? [ ], ... }: { + inputsOverride = { depsBuildBuild ? [ ], nativeBuildInputs ? [ ] + , requiredNimVersion ? defaultNimVersion, ... }: + (if requiredNimVersion == 1 then { + nativeBuildInputs = [ nim1 ] ++ nativeBuildInputs; + } else if requiredNimVersion == 2 then { + nativeBuildInputs = [ nim2 ] ++ nativeBuildInputs; + } else + throw "requiredNimVersion ${toString requiredNimVersion} is not valid") + // { depsBuildBuild = [ nim_builder ] ++ depsBuildBuild; - nativeBuildInputs = [ nim ] ++ nativeBuildInputs; }; composition = finalAttrs: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a5c35be35c14..b62acb50ae27 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16810,6 +16810,7 @@ with pkgs; nim = nim1; nimPackages = recurseIntoAttrs nim1.pkgs; nim2Packages = recurseIntoAttrs nim2.pkgs; + buildNimPackage = callPackage ../development/compilers/nim/build-nim-package.nix { }; nrpl = callPackage ../development/tools/nrpl { }; diff --git a/pkgs/top-level/nim-packages.nix b/pkgs/top-level/nim-packages.nix index 7fc4a5f9ff87..ea3091237c13 100644 --- a/pkgs/top-level/nim-packages.nix +++ b/pkgs/top-level/nim-packages.nix @@ -1,11 +1,13 @@ -{ lib, pkgs, stdenv, newScope, nim, fetchFromGitHub }: +{ lib, pkgs, stdenv, newScope, nim, buildNimPackage }: lib.makeScope newScope (self: let callPackage = self.callPackage; in { inherit nim; - buildNimPackage = - callPackage ../development/nim-packages/build-nim-package { }; + buildNimPackage = buildNimPackage.override { + defaultNimVersion = + if lib.versionAtLeast nim.version "2.0.0" then 2 else 1; + }; asciigraph = callPackage ../development/nim-packages/asciigraph { };