HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulecabal2nix-2.20.1Haskell2010

Distribution.Nixpkgs.Haskell.Platform

This module defines conversions from the (autoconf-derived) platform strings nixpkgs uses into Cabal's Platform type. This is intended to facilitate later evaluation of .cabal files. For this conversion Cabal's Permissive heuristics are used as well as a logic equivalent to the GHC_CONVERT_* macros from GHC's configure script.

Since the process is inherently lossy because Cabal ignores certain factors like endianness, conversion from Platform to nixpkgs' platform strings. For this usecase, try Distribution.Nixpkgs.Meta from distribution-nixpkgs.

  • 2 values
  • Packagecabal2nix-2.20.1
  • Exports2
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePlatform.hs

Convert a platform string of two or three(-ish) components to Platform.

For this, the following logic is utilized:

  • If the string has one dash, the form cpu-os is assumed where os may only have a single component. The vendor part is ignored.

  • Otherwise cpu-vendor-os is assumed where os may have any number of components separated by dashes to accomodate its two component kernel-system form.

Note: This behavior is different from nixpkgs' lib.systems.elaborate: Because we have no knowledge of the legal contents of the different parts, we only decide how to parse it based on what form the string has. This can give different results compared to autoconf or nixpkgs. It will also never reject an invalid platform string that has a valid form.

Example3 expressions
parsePlatformLenient "x86_64-unknown-linux"Just (Platform X86_64 Linux)parsePlatformLenient "x86_64-pc-linux-gnu"Just (Platform X86_64 Linux)parsePlatformLenient "x86_64-linux"Just (Platform X86_64 Linux)

Note also that this conversion sometimes looses information nixpkgs would retain:

Example2 expressions
parsePlatformLenient "powerpc64-unknown-linux"Just (Platform PPC64 Linux)parsePlatformLenient "powerpc64le-unknown-linux"Just (Platform PPC64 Linux)

Convert a Nix style system tuple into a Cabal Platform. The tuple is assumed to be of the form cpu-os, any extra components are assumed to be part of os to accomodate its kernel-system form.

The same caveats about validation and lossiness apply as for parsePlatformLenient.

Example3 expressions
parsePlatformFromSystemLenient "x86_64-linux"Just (Platform X86_64 Linux)parsePlatformFromSystemLenient "x86_64-linux-musl"Just (Platform X86_64 Linux)parsePlatformFromSystemLenient "i686-netbsd"Just (Platform I386 NetBSD)