git.iko.soy/typeable/cabal2nix
on master help sign in
Fail with an error if the set does not contain the binding we're trying to replace.

The 'replace' function is used to fix bindings in 'Derivation' that the 'resolveInNixpkgs' lookup failed to figure out. Now, one problem we encountered is that the (bogus) binding we assumed to be there actually doesn't exist any more because Nixpkgs has changed, and in such a case 'replace' silently did nothing, resulting in a potentially broken build. Instead, we interpret "replace old new bs" to imply that "old `elem` bs" is true and fail if it's not to indicate that the post-process code must be adapted to the new situation.

commit0e1f29ca39eebb7ecf54812a2178e142a978c8e5 authorPeter Simons <simons@cryp.to> dateMon 23 Jul 2018, 11:32 (8 years ago) parent0e482ab
1 file changed+10−2
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+10−2
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+10−2
@@ -190,10 +190,18 @@ bind s = binding # (i, path # is)
190190 is = map (review ident) (splitOn "." s)
191191 i = last is
192192
193+-- | @replace old new bset@ replaces the Nix binding @old@ with @new@ in the
194+-- set of bindings @bset@. If @old@ is not found in @bset@, then the function
195+-- fails with an 'error'.
193196replace :: Binding -> Binding -> Set Binding -> Set Binding
194−replace old new bs = if old `Set.member` bs then Set.insert new (Set.delete old bs) else bs
197+replace old new bs
198+ | old `Set.member` bs = Set.insert new (Set.delete old bs)
199+ | otherwise = error (unwords [ "post-process: cannot replace name binding"
200+ , show old, "by", show new
201+ , "because it's not found in set"
202+ , show bs
203+ ])
195204
196−-- TODO: I need to figure out how to conveniently replace a binding in a set.
197205gtk3Hook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145
198206gtk3Hook = set (libraryDepends . pkgconfig . contains (pkg "gtk3")) True
199207 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "gtk3"))