Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
7 changes: 5 additions & 2 deletions cabal2nix/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* In expressions generated by `cabal2nix --shell`, use the `inNixShell`
function argument instead of `pkgs.lib.inNixShell`. Note that this
requires [Nix 2.4 or later](https://github.com/NixOS/nix/pull/3168).

Note that this only works correctly if the generated expression is
the top level expression. If you want to use a wrapper expression,
make sure it has an `inNixShell` argument and pass that through
to the generated one.

* `hackage2nix` now supports an `excluded-packages` config option to
prevent creating expressions for specific packages entirely.

## 2.20.1

* Add support for Cabal `== 3.14.*` in the test suite.
Expand Down Expand Up @@ -131,7 +134,7 @@ see [#506](https://github.com/NixOS/cabal2nix/pull/506).
* Argument parsing logic in `cabal2nix` has been refactored
in [#544](https://github.com/NixOS/cabal2nix/pull/544).
**API breaking change** for the following modules:

* `Cabal2nix`
* `Distribution.Nixpkgs.Fetch`
* `Distribution.Nixpkgs.Haskell.Derivation` (removed instance)
Expand Down
11 changes: 6 additions & 5 deletions cabal2nix/hackage2nix/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ main = do
[ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(PackageVersionConstraint name _) <- extraPackages config ]

db :: PackageMultiSet
db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
, Map.map Set.singleton latestCorePackageSet
, Map.map Set.singleton latestOverridePackageSet
, extraPackageSet
]
db = flip Map.withoutKeys (excludedPackages config) $ Map.unionsWith Set.union
[ Map.map Set.singleton generatedDefaultPackageSet
, Map.map Set.singleton latestCorePackageSet
, Map.map Set.singleton latestOverridePackageSet
, extraPackageSet
]

haskellResolver :: HaskellResolver
haskellResolver (PackageVersionConstraint name vrange)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ data Configuration = Configuration
-- also disable their meta.hydraPlatforms attribute to avoid cluttering our
-- Hydra job with lots of failure messages.
, brokenPackages :: [Constraint]

-- |These packages have likely been broken for a long time and are unmaintained
-- upstream. To reduce the size of hackage-packages.nix, we don't even create
-- expressions for them.
, excludedPackages :: Set PackageName
}
deriving (Show, Generic)

Expand All @@ -79,6 +84,7 @@ instance Semigroup Configuration where
, unsupportedPlatforms = unsupportedPlatforms l <> unsupportedPlatforms r
, dontDistributePackages = dontDistributePackages l <> dontDistributePackages r
, brokenPackages = brokenPackages l <> brokenPackages r
, excludedPackages = excludedPackages l <> excludedPackages r
}

instance FromJSON Configuration where
Expand All @@ -92,6 +98,7 @@ instance FromJSON Configuration where
<*> o .:? "unsupported-platforms" .!= mempty
<*> o .:? "dont-distribute-packages" .!= mempty
<*> o .:? "broken-packages" .!= mempty
<*> o .:? "excluded-packages" .!= mempty
parseJSON _ = error "invalid Configuration"

instance FromJSON Identifier where
Expand All @@ -114,7 +121,11 @@ assertConsistency :: MonadFail m => Configuration -> m Configuration
assertConsistency cfg@Configuration {..} = do
let report msg = fail ("*** configuration error: " ++ msg)
maintainedPackages = Set.unions (Map.elems packageMaintainers)
disabledPackages = dontDistributePackages `Set.union` Set.fromList (constraintPkgName <$> brokenPackages)
disabledPackages = Set.unions
[ dontDistributePackages
, Set.fromList (constraintPkgName <$> brokenPackages)
, excludedPackages
]
disabledMaintainedPackages = maintainedPackages `Set.intersection` disabledPackages
unless (Set.null disabledMaintainedPackages) $
report ("disabled packages that have a maintainer: " ++ show disabledMaintainedPackages)
Expand Down
Loading