diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2024-05-15 18:01:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 18:01:24 +0000 |
commit | d85d40bf55c0c0142584ecfee18b64ba7c4ecdd2 (patch) | |
tree | 8804c4fa7e668764919708ee8f3ac7ff69c103ee /doc | |
parent | 3a4faefddfe09fe565bd02d4c6beaa49d771ca96 (diff) | |
parent | bb81a9932e984fe5dccb6b6399c9a2b18f12051a (diff) |
Merge staging-next into staging
Diffstat (limited to 'doc')
-rw-r--r-- | doc/languages-frameworks/haskell.section.md | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/doc/languages-frameworks/haskell.section.md b/doc/languages-frameworks/haskell.section.md index 5d7796b554de4..dde55c329a4ac 100644 --- a/doc/languages-frameworks/haskell.section.md +++ b/doc/languages-frameworks/haskell.section.md @@ -230,7 +230,7 @@ completely incompatible with packages from `haskellPackages`. Every haskell package set has its own haskell-aware `mkDerivation` which is used to build its packages. Generally you won't have to interact with this builder -since [cabal2nix][cabal2nix] can generate packages +since [cabal2nix](#haskell-cabal2nix) can generate packages using it for an arbitrary cabal package definition. Still it is useful to know the parameters it takes when you need to [override](#haskell-overriding-haskell-packages) a generated Nix expression. @@ -1123,17 +1123,74 @@ for [this to work][optparse-applicative-completions]. Note that this feature is automatically disabled when cross-compiling, since it requires executing the binaries in question. +## Import-from-Derivation helpers {#haskell-import-from-derivation} + +### cabal2nix {#haskell-cabal2nix} + +[`cabal2nix`][cabal2nix] can generate Nix package definitions for arbitrary +Haskell packages using [import from derivation][import-from-derivation]. +`cabal2nix` will generate Nix expressions that look like this: + +```nix +# cabal get mtl-2.2.1 && cd mtl-2.2.1 && cabal2nix . +{ mkDerivation, base, lib, transformers }: +mkDerivation { + pname = "mtl"; + version = "2.2.1"; + src = ./.; + libraryHaskellDepends = [ base transformers ]; + homepage = "http://github.com/ekmett/mtl"; + description = "Monad classes, using functional dependencies"; + license = lib.licenses.bsd3; +} +``` + +This expression should be called with `haskellPackages.callPackage`, which will +supply [`haskellPackages.mkDerivation`](#haskell-mkderivation) and the Haskell +dependencies as arguments. + +`callCabal2nix name src args` +: Create a package named `name` from the source derivation `src` using + `cabal2nix`. + + `args` are extra arguments provided to `haskellPackages.callPackage`. + +`callCabal2nixWithOptions name src opts args` +: Create a package named `name` from the source derivation `src` using + `cabal2nix`. + + `opts` are extra options for calling `cabal2nix`. If `opts` is a string, it + will be used as extra command line arguments for `cabal2nix`, e.g. `--subpath + path/to/dir/containing/cabal-file`. Otherwise, `opts` should be an AttrSet + which can contain the following attributes: + + `extraCabal2nixOptions` + : Extra command line arguments for `cabal2nix`. + + `srcModifier` + : A function which is used to modify the given `src` instead of the default + filter. + + The default source filter will remove all files from `src` except for + `.cabal` files and `package.yaml` files. + <!-- -TODO(@NixOS/haskell): finish these planned sections -### Overriding the entire package set +`callHackage` +: TODO +`callHackageDirect` +: TODO -## Import-from-Derivation helpers +`developPackage` +: TODO -* `callCabal2nix` -* `callHackage`, `callHackageDirect` -* `developPackage` +--> + +<!-- + +TODO(@NixOS/haskell): finish these planned sections +### Overriding the entire package set ## Contributing {#haskell-contributing} @@ -1309,3 +1366,4 @@ relevant. [profiling]: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/profiling.html [search.nixos.org]: https://search.nixos.org [turtle]: https://hackage.haskell.org/package/turtle +[import-from-derivation]: https://nixos.org/manual/nix/stable/language/import-from-derivation |