Skip to content

Commit

Permalink
Distribution.Nixpkgs.PackageMap: examples from doctest
Browse files Browse the repository at this point in the history
Since both haskell-ci (even with cabal-docspec) and doctest insist that
there should be no way to skip even a single example in the
documentation that may not be doctest-able because of impurities or
requirements in terms of environment, we have to use code blocks instead
of the more semantic example entries in haddock markup to prevent it
from trying to invoke nix-instantiate in CI which won't work in an
ubuntu docker container.

In the future we may be able to skip the file altogether either via a
patch to the generated output or whatever resolves this issue:
haskell-CI/haskell-ci#519
  • Loading branch information
sternenseemann committed Jun 5, 2021
1 parent 0df1039 commit 8331e78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Distribution/Nixpkgs/PackageMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ type PackageMap = Map Identifier (Set Path)
-- Note: Evaluation of nixpkgs is very expensive (takes multiple
-- seconds), so cache the result of this function if possible.
--
-- >>> readNixpkgPackageMap "<nixpkgs>" (Just "{ config = { allowAliases = false; }; }")
-- @
-- >>> readNixpkgPackageMap "\<nixpkgs\>" (Just "{ config = { allowAliases = false; }; }")
-- fromList [ … ]
-- @
readNixpkgPackageMap :: String
-- ^ Path to nixpkgs, must be a valid nix path
-- (absolute, relative or @NIX_PATH@ lookup)
Expand Down Expand Up @@ -77,8 +79,10 @@ parsePackage x
-- | Finds the shortest 'Path' in a 'PackageMap' that has the
-- given 'Identifier' as its last component.
--
-- @
-- >>> resolve nixpkgs (ident # "pam")
-- Just (Bind (Identifier "pam") (Path [Identifier "pam"]))
-- @
resolve :: PackageMap -> Identifier -> Maybe Binding
resolve nixpkgs i = case Map.lookup i nixpkgs of
Nothing -> Nothing
Expand Down

0 comments on commit 8331e78

Please sign in to comment.