cabal2nix-2.21.0: Convert Cabal files into Nix build instructions.
Safe HaskellNone
LanguageHaskell2010

Distribution.Nixpkgs.Haskell.FromCabal.Name

Synopsis

Documentation

toNixName :: PackageName -> Identifier Source #

Map Cabal names to Nix identifiers that don't need to be quoted.

Currently this only supports PackageNames that consist of nothing but ASCII characters (as needs to be the case with all Hackage packages). Cabal package names are not changed if they already are a Nix identifier that doesn't need quoting (with some notable exceptions). If they would need quoting, they are prefixed with an underscore.

>>> toNixName $ mkPackageName "cabal2nix"
Identifier "cabal2nix"
>>> toNixName $ mkPackageName "4Blocks"
Identifier "_4Blocks"
>>> toNixName $ mkPackageName "assert"
Identifier "_assert"

Package names that clash with attribute names that have a special meaning to the Nix evaluator are also prefixed (e.g. type is evaluated eagerly).

The mapping is intended to be reversible, but this isn't implemented by cabal2nix yet (and untested). It also should not be considered stable yet, in particular the following may be changed:

  • Future versions of cabal2nix may prefix more PackageNames.
  • The mapping may be extended to support all possible PackageNames.

See also:

libNixName :: String -> [Identifier] Source #

Map library names specified in Cabal files to Nix package identifiers.

TODO: This list should not be hard-coded here; it belongs into the Nixpkgs repository.

TODO: Re-use hook matching system from PostProcess.hs here.

buildToolNixName :: String -> [Identifier] Source #

Map build tool names to Nix attribute names.