diff options
Diffstat (limited to 'nixpkgs/pkgs/development/tools/haskell')
13 files changed, 540 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix new file mode 100644 index 000000000000..66341d2c8c50 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix @@ -0,0 +1,25 @@ +{ mkDerivation, base, containers, emojis, fetchgit, hedgehog, lib +, optparse-applicative, parsec, template-haskell, text +}: +mkDerivation { + pname = "dconf2nix"; + version = "0.0.12"; + src = fetchgit { + url = "https://github.com/gvolpe/dconf2nix.git"; + sha256 = "0cy47g6ksxf7p0qnzljg0c5dv65r79krkzw6iasivv8czc2lv8sc"; + rev = "101e102c6a3aa79d1787e2ae77fa3379153d29f8"; + fetchSubmodules = true; + }; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + base containers emojis optparse-applicative parsec text + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + base containers hedgehog parsec template-haskell text + ]; + description = "Convert dconf files to Nix, as expected by Home Manager"; + license = lib.licenses.asl20; + mainProgram = "dconf2nix"; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix new file mode 100644 index 000000000000..4cc137b54f75 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix @@ -0,0 +1,32 @@ +{ haskell, haskellPackages, lib, runCommand }: + +let + dconf2nix = + haskell.lib.compose.justStaticExecutables + (haskell.lib.compose.overrideCabal (oldAttrs: { + maintainers = (oldAttrs.maintainers or []) ++ [ + lib.maintainers.gvolpe + ]; + }) haskellPackages.dconf2nix); +in + +dconf2nix.overrideAttrs (oldAttrs: { + passthru = (oldAttrs.passthru or {}) // { + updateScript = ./update.sh; + + # These tests can be run with the following command. + # + # $ nix-build -A dconf2nix.passthru.tests + tests = + runCommand + "dconf2nix-tests" + { + nativeBuildInputs = [ + dconf2nix + ]; + } + '' + dconf2nix > $out + ''; + }; +}) diff --git a/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh new file mode 100755 index 000000000000..8129824e256b --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p cabal2nix curl jq +# +# This script will update the dconf2nix derivation to the latest version using +# cabal2nix. + +set -eo pipefail + +# This is the directory of this update.sh script. +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# dconf2nix derivation created with cabal2nix. +dconf2nix_derivation_file="${script_dir}/dconf2nix.nix" + +# This is the current revision of dconf2nix in Nixpkgs. +old_version="$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$dconf2nix_derivation_file")" + +# This is the latest release version of dconf2nix on GitHub. +new_version=$(curl --silent "https://api.github.com/repos/gvolpe/dconf2nix/releases" | jq '.[0].tag_name' --raw-output) + +echo "Updating dconf2nix from old version $old_version to new version $new_version." +echo "Running cabal2nix and outputting to ${dconf2nix_derivation_file}..." + +cabal2nix --revision "$new_version" "https://github.com/gvolpe/dconf2nix.git" > "$dconf2nix_derivation_file" + +echo "Finished." diff --git a/nixpkgs/pkgs/development/tools/haskell/hadrian/default.nix b/nixpkgs/pkgs/development/tools/haskell/hadrian/default.nix new file mode 100644 index 000000000000..1801d63cf8b9 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/hadrian/default.nix @@ -0,0 +1,50 @@ +{ # GHC source tree to build hadrian from + ghcSrc ? null, ghcVersion ? null +, mkDerivation, base, bytestring, Cabal, containers, directory +, extra, filepath, lib, mtl, parsec, shake, text, transformers +, unordered-containers, cryptohash-sha256, base16-bytestring +, userSettings ? null +# Whether to pass --hyperlinked-source to haddock or not. This is a custom +# workaround as we wait for this to be configurable via userSettings or similar. +# https://gitlab.haskell.org/ghc/ghc/-/issues/23625 +, enableHyperlinkedSource ? true +, writeText +}: + +if ghcSrc == null || ghcVersion == null +then throw "hadrian: need to specify ghcSrc and ghcVersion arguments manually" +else + +mkDerivation { + pname = "hadrian"; + version = ghcVersion; + src = ghcSrc; + postUnpack = '' + sourceRoot="$sourceRoot/hadrian" + ''; + patches = lib.optionals (!enableHyperlinkedSource) [ + ./disable-hyperlinked-source.patch + ]; + # Overwrite UserSettings.hs with a provided custom one + postPatch = lib.optionalString (userSettings != null) '' + install -m644 "${writeText "UserSettings.hs" userSettings}" src/UserSettings.hs + ''; + configureFlags = [ + # avoid QuickCheck dep which needs shared libs / TH + "-f-selftest" + # Building hadrian with -O1 takes quite some time with little benefit. + # Additionally we need to recompile it on every change of UserSettings.hs. + # See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/1190 + "-O0" + ]; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + base bytestring Cabal containers directory extra filepath mtl + parsec shake text transformers unordered-containers + ] ++ lib.optionals (lib.versionAtLeast ghcVersion "9.7") [ + cryptohash-sha256 base16-bytestring + ]; + description = "GHC build system"; + license = lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch b/nixpkgs/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch new file mode 100644 index 000000000000..72010f85cddc --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/hadrian/disable-hyperlinked-source.patch @@ -0,0 +1,12 @@ +diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs +index 902b2f85e2..429a441c3b 100644 +--- a/src/Settings/Builders/Haddock.hs ++++ b/src/Settings/Builders/Haddock.hs +@@ -57,7 +57,6 @@ haddockBuilderArgs = mconcat + , arg $ "--odir=" ++ takeDirectory output + , arg $ "--dump-interface=" ++ output + , arg "--html" +- , arg "--hyperlinked-source" + , arg "--hoogle" + , arg "--quickjump" + , arg $ "--title=" ++ pkgName pkg ++ "-" ++ version diff --git a/nixpkgs/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix b/nixpkgs/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix new file mode 100644 index 000000000000..a6f287c37b3f --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix @@ -0,0 +1,61 @@ +{ lib +, stdenv +, supportedGhcVersions ? [ "94" ] +, dynamic ? true +, haskellPackages +, haskell +}: +# +# The recommended way to override this package is +# +# pkgs.haskell-language-server.override { supportedGhcVersions = [ "90" "92"]; } +# +# for example. Read more about this in the haskell-language-server section of the nixpkgs manual. +# +let + inherit (lib) concatStringsSep concatMapStringsSep take splitString pipe optionals; + inherit (haskell.lib.compose) justStaticExecutables overrideCabal enableCabalFlag disableCabalFlag; + getPackages = version: haskell.packages."ghc${version}"; + tunedHls = hsPkgs: + lib.pipe hsPkgs.haskell-language-server ([ + (haskell.lib.compose.overrideCabal (old: { + enableSharedExecutables = dynamic; + ${if !dynamic then "postInstall" else null} = '' + ${old.postInstall or ""} + + remove-references-to -t ${hsPkgs.ghc} $out/bin/haskell-language-server + ''; + })) + ((if dynamic then enableCabalFlag else disableCabalFlag) "dynamic") + ] ++ optionals (!dynamic) [ + justStaticExecutables + ]); + targets = version: + let packages = getPackages version; + in [ + "haskell-language-server-${packages.ghc.version}" + ]; + makeSymlinks = version: + concatMapStringsSep "\n" (x: + "ln -s ${ + tunedHls (getPackages version) + }/bin/haskell-language-server $out/bin/${x}") (targets version); +in assert supportedGhcVersions != []; stdenv.mkDerivation { + pname = "haskell-language-server"; + version = haskellPackages.haskell-language-server.version; + buildCommand = '' + mkdir -p $out/bin + ln -s ${tunedHls (getPackages (builtins.head supportedGhcVersions))}/bin/haskell-language-server-wrapper $out/bin/haskell-language-server-wrapper + ${concatMapStringsSep "\n" makeSymlinks supportedGhcVersions} + ''; + meta = haskellPackages.haskell-language-server.meta // { + maintainers = [ lib.maintainers.maralorn ]; + longDescription = '' + This package provides the executables ${ + concatMapStringsSep ", " (x: concatStringsSep ", " (targets x)) + supportedGhcVersions + } and haskell-language-server-wrapper. + You can choose for which ghc versions to install hls with pkgs.haskell-language-server.override { supportedGhcVersions = [ "90" "92" ]; }. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/default.nix b/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/default.nix new file mode 100644 index 000000000000..2b3fb76903e5 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/default.nix @@ -0,0 +1,53 @@ +{ lib, stdenvNoCC, fetchFromGitHub, jshon, electron_10 +, runtimeShell, hyper-haskell-server, extra-packages ? [] }: + +let + binPath = lib.makeBinPath ([ hyper-haskell-server ] ++ extra-packages); + electron = electron_10; +in stdenvNoCC.mkDerivation rec { + pname = "hyper-haskell"; + version = "0.2.3.0"; + + src = fetchFromGitHub { + owner = "HeinrichApfelmus"; + repo = "hyper-haskell"; + rev = "v${version}"; + sha256 = "1nmkry4wh6a2dy98fcs81mq2p7zhxp1k0f4m3szr6fm3j1zwrd43"; + }; + + propagatedBuildInputs = extra-packages; + + dontBuild = true; + + installPhase = '' + mkdir -p $out/bin $out/share/hyper-haskell/worksheets $out/share/applications $out/share/icons/hicolor/scalable/apps $out/share/mime/packages + + # Electron app + cp -R app $out + + # Desktop Launcher + cp resources/hyper-haskell.desktop $out/share/applications/hyper-haskell.desktop + cp resources/icons/icon.svg $out/share/icons/hicolor/scalable/apps/hyper-haskell.svg + cp resources/shared-mime-info.xml $out/share/mime/packages/hyper-haskell.xml + + # install example worksheets with backend set to nix + for worksheet in "worksheets/"*.hhs; do + ${jshon}/bin/jshon -e settings -s nix -i packageTool -p < $worksheet > $out/share/hyper-haskell/worksheets/`basename $worksheet` + done + + # install electron wrapper script + cat > $out/bin/hyper-haskell <<EOF + #!${runtimeShell} + export PATH="${binPath}:\$PATH" + exec ${electron}/bin/electron $out/app "\$@" + EOF + chmod 755 $out/bin/hyper-haskell + ''; + + meta = with lib; { + description = "The strongly hyped graphical interpreter for the Haskell programming language"; + homepage = "https://github.com/HeinrichApfelmus/hyper-haskell"; + license = licenses.bsd3; + maintainers = [ maintainers.rvl ]; + }; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/server.nix b/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/server.nix new file mode 100644 index 000000000000..ca272eb36262 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/hyper-haskell/server.nix @@ -0,0 +1,29 @@ +{ stdenv, ghcWithPackages, makeWrapper, packages, lib }: + +let +hyperHaskellEnv = ghcWithPackages (self: [ self.hyper-haskell-server ] ++ packages self); +in stdenv.mkDerivation { + pname = "hyper-haskell-server-with-packages"; + version = hyperHaskellEnv.version; + + nativeBuildInputs = [ makeWrapper ]; + + buildCommand = '' + mkdir -p $out/bin + makeWrapper ${hyperHaskellEnv}/bin/hyper-haskell-server $out/bin/hyper-haskell-server \ + --set NIX_GHC ${hyperHaskellEnv}/bin/ghc \ + --set NIX_GHCPKG ${hyperHaskellEnv}/bin/ghc-pkg \ + --set NIX_GHC_LIBDIR ${hyperHaskellEnv}/lib/ghc-* + ''; + + # trivial derivation + preferLocalBuild = true; + allowSubstitutes = false; + + meta = { + # Marked as broken because the underlying + # haskellPackages.hyper-haskell-server is marked as broken. + hydraPlatforms = lib.platforms.none; + broken = true; + }; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/ihaskell/wrapper.nix b/nixpkgs/pkgs/development/tools/haskell/ihaskell/wrapper.nix new file mode 100644 index 000000000000..b5ea07dde147 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/ihaskell/wrapper.nix @@ -0,0 +1,29 @@ +{ lib, stdenv, writeScriptBin, makeWrapper, buildEnv, haskell, ghcWithPackages, jupyter, packages }: +let + ihaskellEnv = ghcWithPackages (self: [ + self.ihaskell + self.ihaskell-blaze + # Doesn't work with latest ihaskell versions missing an unrelated change + # https://github.com/IHaskell/IHaskell/issues/1378 + # self.ihaskell-diagrams + ] ++ packages self); + ihaskellSh = writeScriptBin "ihaskell-notebook" '' + #! ${stdenv.shell} + export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH" + export PATH="${lib.makeBinPath ([ ihaskellEnv jupyter ])}''${PATH:+:}$PATH" + ${ihaskellEnv}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${jupyter}/bin/jupyter notebook + ''; +in +buildEnv { + name = "ihaskell-with-packages"; + nativeBuildInputs = [ makeWrapper ]; + paths = [ ihaskellEnv jupyter ]; + postBuild = '' + ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/ + for prg in $out/bin"/"*;do + if [[ -f $prg && -x $prg ]]; then + wrapProgram $prg --set PYTHONPATH "$(echo ${jupyter}/lib/*/site-packages)" + fi + done + ''; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/lambdabot/custom-config.patch b/nixpkgs/pkgs/development/tools/haskell/lambdabot/custom-config.patch new file mode 100644 index 000000000000..db467f8dd29b --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/lambdabot/custom-config.patch @@ -0,0 +1,49 @@ +diff --git a/src/Main.hs b/src/Main.hs +index 61da2f3..39e5c9b 100644 +--- a/src/Main.hs ++++ b/src/Main.hs +@@ -73,11 +73,14 @@ main = do + config' <- sequence config + dir <- P.getDataDir + exitWith <=< lambdabotMain modulesInfo $ +- [dataDir ==> dir, lbVersion ==> P.version] ++ config' ++ [dataDir ==> dir, lbVersion ==> P.version] ++ configInfo ++ config' + + -- special online target for ghci use + online :: [String] -> IO () + online strs = do + dir <- P.getDataDir +- void $ lambdabotMain modulesInfo +- [dataDir ==> dir, lbVersion ==> P.version, onStartupCmds ==> strs] ++ void $ lambdabotMain modulesInfo $ ++ [dataDir ==> dir, lbVersion ==> P.version, onStartupCmds ==> strs] ++ configInfo ++ ++configInfo :: [DSum Config Identity] ++configInfo = @config@ +diff --git a/src/Modules.hs b/src/Modules.hs +index 036ea1f..eaafa50 100644 +--- a/src/Modules.hs ++++ b/src/Modules.hs +@@ -14,10 +14,15 @@ import Lambdabot.Plugin.Reference + import Lambdabot.Plugin.Social + + modulesInfo :: Modules +-modulesInfo = $(modules $ corePlugins +- ++ haskellPlugins +- ++ ["irc", "localtime", "topic"] -- ircPlugins +- ++ ["dummy", "fresh", "todo"] -- miscPlugins +- ++ ["bf", "dice", "elite", "filter", "quote", "slap", "unlambda", "vixen"] -- noveltyPlugins +- ++ referencePlugins +- ++ socialPlugins) ++modulesInfo = ++ $(modules $ ++ let oldDefaultModules = ++ corePlugins ++ ++ haskellPlugins ++ ++ ["irc", "localtime", "topic"] -- ircPlugins ++ ++ ["dummy", "fresh", "todo"] -- miscPlugins ++ ++ ["bf", "dice", "elite", "filter", "quote", "slap", "unlambda", "vixen"] -- noveltyPlugins ++ ++ referencePlugins ++ ++ socialPlugins ++ in @modules@ ++ ) diff --git a/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix b/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix new file mode 100644 index 000000000000..b563fa4b7a75 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/lambdabot/default.nix @@ -0,0 +1,41 @@ +{ lib, haskellLib, makeWrapper, haskellPackages +, mueval +, withDjinn ? true +, aspell ? null +, packages ? (pkgs: []) +, modules ? "oldDefaultModules" +, configuration ? "[]" +}: + +let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ packages pkgs; + mueval' = mueval.override { + inherit haskellPackages; + packages = allPkgs; + }; + bins = lib.makeBinPath ([ mueval' + (haskellPackages.ghcWithHoogle allPkgs) + haskellPackages.unlambda + haskellPackages.brainfuck + ] + ++ lib.optional withDjinn haskellPackages.djinn + ++ lib.optional (aspell != null) aspell + ); + modulesStr = lib.replaceStrings ["\n"] [" "] modules; + configStr = lib.replaceStrings ["\n"] [" "] configuration; + +in haskellLib.overrideCabal (self: { + patches = (self.patches or []) ++ [ ./custom-config.patch ]; + postPatch = (self.postPatch or "") + '' + substituteInPlace src/Main.hs \ + --replace '@config@' '${configStr}' + substituteInPlace src/Modules.hs \ + --replace '@modules@' '${modulesStr}' + ''; + + buildTools = (self.buildTools or []) ++ [ makeWrapper ]; + + postInstall = (self.postInstall or "") + '' + wrapProgram $out/bin/lambdabot \ + --prefix PATH ":" '${bins}' + ''; +}) haskellPackages.lambdabot diff --git a/nixpkgs/pkgs/development/tools/haskell/mueval/default.nix b/nixpkgs/pkgs/development/tools/haskell/mueval/default.nix new file mode 100644 index 000000000000..3b4a6406f703 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/mueval/default.nix @@ -0,0 +1,32 @@ +{ stdenv, makeWrapper, haskellPackages, packages ? (pkgs: []) +}: + +let defaultPkgs = pkgs: [ pkgs.show + pkgs.simple-reflect + pkgs.QuickCheck + pkgs.mtl + ]; + env = haskellPackages.ghcWithPackages + (pkgs: defaultPkgs pkgs ++ packages pkgs); + libDir = "${env}/lib/ghc-${env.version}"; + +in stdenv.mkDerivation { + name = "mueval-env"; + + inherit (haskellPackages) mueval; + + nativeBuildInputs = [ makeWrapper ]; + + buildCommand = '' + mkdir -p $out/bin + + makeWrapper $mueval/bin/mueval $out/bin/mueval \ + --prefix PATH ":" "$out/bin" + + makeWrapper $mueval/bin/mueval-core $out/bin/mueval \ + --set "NIX_GHC_LIBDIR" "${libDir}" + + ''; + + passthru = { inherit defaultPkgs; }; +} diff --git a/nixpkgs/pkgs/development/tools/haskell/vaultenv/default.nix b/nixpkgs/pkgs/development/tools/haskell/vaultenv/default.nix new file mode 100644 index 000000000000..e3adef875245 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/haskell/vaultenv/default.nix @@ -0,0 +1,101 @@ +{ mkDerivation +, async +, base +, bytestring +, connection +, containers +, directory +, hpack +, hspec +, hspec-discover +, hspec-expectations +, http-client +, http-conduit +, lens +, lens-aeson +, megaparsec +, mtl +, optparse-applicative +, parser-combinators +, retry +, lib +, quickcheck-instances +, text +, unix +, unordered-containers +, utf8-string +, fetchFromGitHub +, dotenv +}: +mkDerivation rec { + pname = "vaultenv"; + version = "0.16.0"; + + src = fetchFromGitHub { + owner = "channable"; + repo = "vaultenv"; + rev = "v${version}"; + sha256 = "sha256-EPu4unzXIg8naFUEZwbJ2VJXD/TeCiKzPHCXnRkdyBE="; + }; + + buildTools = [ hpack ]; + + prePatch = '' + substituteInPlace package.yaml \ + --replace -Werror "" + ''; + + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + async + base + bytestring + connection + containers + http-client + http-conduit + lens + lens-aeson + megaparsec + mtl + optparse-applicative + parser-combinators + retry + text + unix + unordered-containers + utf8-string + dotenv + ]; + testHaskellDepends = [ + async + base + bytestring + connection + containers + directory + hspec + hspec-discover + hspec-expectations + http-client + http-conduit + lens + lens-aeson + megaparsec + mtl + optparse-applicative + parser-combinators + retry + quickcheck-instances + text + unix + unordered-containers + utf8-string + ]; + preConfigure = "hpack"; + homepage = "https://github.com/channable/vaultenv#readme"; + description = "Runs processes with secrets from HashiCorp Vault"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ lnl7 manveru ]; +} |