From f2a3ee67b440b1e9fb3f50fe29717b5d3c058a29 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 14 Nov 2024 11:08:35 +1300 Subject: [PATCH] Add the tool plans to as hydraJobs (#172) --- cross-js.nix | 26 +++++++++++++++++--------- cross-windows.nix | 22 +++++++++++++++------- dynamic.nix | 24 ++++++++++++++++-------- flake.nix | 5 +++-- static.nix | 16 ++++++++++++---- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/cross-js.nix b/cross-js.nix index 21d1083..28408a5 100644 --- a/cross-js.nix +++ b/cross-js.nix @@ -1,7 +1,15 @@ { self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }: let tool-version-map = import ./tool-map.nix; - tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; - cabal-install = pkgs.haskell-nix.nix-tools-unchecked.exes.cabal; + tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; + cabal-install = pkgs.pkgsBuildBuild.haskell-nix.nix-tools-unchecked.exes.cabal; + haskell-tools = + pkgs.lib.optionalAttrs (withHLS && (compiler-not-in ( + # it appears we can't get HLS build with 9.8 yet. + pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) { hls = tool "haskell-language-server"; } + // pkgs.lib.optionalAttrs (withHlint && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) { hlint = tool "hlint"; }; # add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler. compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true); @@ -86,17 +94,17 @@ pkgs.mkShell ({ (tool "alex") stdenv.cc.cc.lib ]) ++ (with pkgs.buildPackages; [ ]) - ++ pkgs.lib.optional (withHLS && (compiler-not-in ( - # it appears we can't get HLS build with 9.8 yet. - pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server") - ++ pkgs.lib.optional (withHlint && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint") + ++ builtins.attrValues haskell-tools ++ pkgs.lib.optional withIOG (with pkgs; [ cddl cbor-diag ] ++ map pkgs.lib.getDev (with pkgs; [ libblst libsodium-vrf secp256k1 ])) ; + + passthru = { + plans = if haskell-tools == {} then {} else + pkgs.pkgsBuildBuild.linkFarm "plans" + (builtins.mapAttrs (_: t: t.project.plan-nix) haskell-tools); + }; }) diff --git a/cross-windows.nix b/cross-windows.nix index 5643216..af59d75 100644 --- a/cross-windows.nix +++ b/cross-windows.nix @@ -2,6 +2,14 @@ let tool-version-map = import ./tool-map.nix; tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; cabal-install = pkgs.pkgsBuildBuild.haskell-nix.nix-tools-unchecked.exes.cabal; + haskell-tools = + pkgs.lib.optionalAttrs (withHLS && (compiler-not-in ( + # it appears we can't get HLS build with 9.8 yet. + pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) { hls = tool "haskell-language-server"; } + // pkgs.lib.optionalAttrs (withHlint && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) { hlint = tool "hlint"; }; # add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler. compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true); # Exclude zstd support for now, since it's currently broken on mingw32W64: @@ -192,17 +200,17 @@ pkgs.pkgsBuildBuild.mkShell ({ windows.mcfgthreads windows.mingw_w64_pthreads ]) - ++ pkgs.lib.optional (withHLS && (compiler-not-in ( - # it appears we can't get HLS build with 9.8 yet. - pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server") - ++ pkgs.lib.optional (withHlint && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint") + ++ builtins.attrValues haskell-tools ++ pkgs.lib.optional withIOG (with pkgs.pkgsBuildBuild; [ cddl cbor-diag ] ++ map pkgs.lib.getDev (with pkgs; [ libblst libsodium-vrf secp256k1 ])) ; + + passthru = { + plans = if haskell-tools == {} then {} else + pkgs.pkgsBuildBuild.linkFarm "plans" + (builtins.mapAttrs (_: t: t.project.plan-nix) haskell-tools); + }; }) diff --git a/dynamic.nix b/dynamic.nix index bf0ebf1..4736174 100644 --- a/dynamic.nix +++ b/dynamic.nix @@ -1,8 +1,15 @@ # define a development shell for dynamically linked applications (default) { self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false }: let tool-version-map = import ./tool-map.nix; - tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; - cabal-install = pkgs.haskell-nix.nix-tools-unchecked.exes.cabal; + tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; + cabal-install = pkgs.pkgsBuildBuild.haskell-nix.nix-tools-unchecked.exes.cabal; + haskell-tools = + pkgs.lib.optionalAttrs (withHLS && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) { hls = tool "haskell-language-server"; } + // pkgs.lib.optionalAttrs (withHlint && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.10" >= 0) compiler-nix-name + ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) { hlint = tool "hlint"; }; # add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler. compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true); @@ -94,12 +101,7 @@ pkgs.mkShell { ] ++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux systemd ) - ++ pkgs.lib.optional (withHLS && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server") - ++ pkgs.lib.optional (withHlint && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.10" >= 0) compiler-nix-name - ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint") + ++ builtins.attrValues haskell-tools ++ pkgs.lib.optional withIOG (with pkgs; [ cddl @@ -114,4 +116,10 @@ pkgs.mkShell { postgresql # for db-sync ])) ; + + passthru = { + plans = if haskell-tools == {} then {} else + pkgs.pkgsBuildBuild.linkFarm "plans" + (builtins.mapAttrs (_: t: t.project.plan-nix) haskell-tools); + }; } diff --git a/flake.nix b/flake.nix index b600ac7..fef4206 100644 --- a/flake.nix +++ b/flake.nix @@ -251,8 +251,9 @@ license = pkgs.lib.licenses.asl20; platforms = pkgs.lib.platforms.unix; }; - })) devShells) // { - }; + })) devShells) + // (pkgs.lib.mapAttrs' (name: drv: + pkgs.lib.nameValuePair "${name}-plans" drv.plans) devShells); packages.cabalProjectLocal.static = (import ./quirks.nix { pkgs = static-pkgs; static = true; }).template; packages.cabalProjectLocal.cross-js = (import ./quirks.nix { pkgs = js-pkgs; }).template; packages.cabalProjectLocal.cross-windows = (import ./quirks.nix { pkgs = windows-pkgs; }).template; diff --git a/static.nix b/static.nix index 73594fc..15ac681 100644 --- a/static.nix +++ b/static.nix @@ -2,6 +2,11 @@ let tool-version-map = import ./tool-map.nix; tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule]; cabal-install = pkgs.pkgsBuildBuild.haskell-nix.nix-tools-unchecked.exes.cabal; + haskell-tools = + pkgs.lib.optionalAttrs (withHLS && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name) "Haskell Language Server")) { hls = tool "haskell-language-server"; } + // pkgs.lib.optionalAttrs (withHlint && (compiler-not-in ( + pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name) "HLint")) { hlint = tool "hlint"; }; # add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler. compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true); @@ -144,10 +149,13 @@ pkgs.mkShell (rec { (pkgs.pkg-config or pkgconfig) stdenv.cc.cc.lib ]) ++ (with pkgs.buildPackages; [ ]) - ++ pkgs.lib.optional (withHLS && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name) "Haskell Language Server")) (tool "haskell-language-server") - ++ pkgs.lib.optional (withHlint && (compiler-not-in ( - pkgs.lib.optional (builtins.compareVersions compiler.version "9.8" >= 0) compiler-nix-name) "HLint")) (tool "hlint") + ++ builtins.attrValues haskell-tools ++ pkgs.lib.optional withIOG (with pkgs; [ cddl cbor-diag ]) ; + + passthru = { + plans = if haskell-tools == {} then {} else + pkgs.pkgsBuildBuild.linkFarm "plans" + (builtins.mapAttrs (_: t: t.project.plan-nix) haskell-tools); + }; })