diff --git a/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs b/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs index 1f2891e0c..a427355a6 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Fetch.hs @@ -90,7 +90,7 @@ instance PP.Pretty DerivationSource where [ attr "url" $ string derivUrl , attr "sha256" $ string derivHash , if derivRevision /= "" then attr "rev" (string derivRevision) else PP.empty - , boolattr "fetchSubmodules" (isJust derivSubmodule) (fromJust derivSubmodule) + , boolattr "fetchSubmodules" (maybe True id derivSubmodule) ] , rbrace PP.<> semi ] diff --git a/cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs b/cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs index aa489f6cf..d9c16d230 100644 --- a/cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs +++ b/cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs @@ -120,23 +120,22 @@ instance Pretty Derivation where , onlyIf (_revision > 0) $ attr "revision" $ doubleQuotes $ int _revision , onlyIf (not (null _editedCabalFile) && _revision > 0) $ attr "editedCabalFile" $ string _editedCabalFile , listattr "configureFlags" empty (map (show . show) renderedFlags) - , boolattr "isLibrary" (not _isLibrary || _isExecutable) _isLibrary - , boolattr "isExecutable" (not _isLibrary || _isExecutable) _isExecutable - , boolattr "enableSeparateDataOutput" _enableSeparateDataOutput _enableSeparateDataOutput + , boolattr "isLibrary" _isLibrary + , boolattr "isExecutable" _isExecutable + , boolattr "enableSeparateDataOutput" _enableSeparateDataOutput , onlyIf (_setupDepends /= mempty) $ pPrintBuildInfo "setup" _setupDepends , onlyIf (_libraryDepends /= mempty) $ pPrintBuildInfo "library" _libraryDepends , onlyIf (_executableDepends /= mempty) $ pPrintBuildInfo "executable" _executableDepends , onlyIf (_testDepends /= mempty) $ pPrintBuildInfo "test" _testDepends , onlyIf (_benchmarkDepends /= mempty) $ pPrintBuildInfo "benchmark" _benchmarkDepends - , boolattr "enableLibraryProfiling" _enableLibraryProfiling _enableLibraryProfiling - , boolattr "enableExecutableProfiling" _enableExecutableProfiling _enableExecutableProfiling - , boolattr "enableSplitObjs" (not _enableSplitObjs) _enableSplitObjs - , boolattr "doHaddock" (not _runHaddock) _runHaddock - , boolattr "jailbreak" _jailbreak _jailbreak - , boolattr "doCheck" (not _doCheck) _doCheck - , boolattr "doBenchmark" _doBenchmark _doBenchmark + , boolattr "enableLibraryProfiling" _enableLibraryProfiling + , boolattr "enableExecutableProfiling" _enableExecutableProfiling + , boolattr "doHaddock" _runHaddock + , boolattr "jailbreak" _jailbreak + , boolattr "doCheck" _doCheck + , boolattr "doBenchmark" _doBenchmark , onlyIf (not (null _testTarget)) $ attr "testTarget" $ string _testTarget - , boolattr "hyperlinkSource" (not _hyperlinkSource) _hyperlinkSource + , boolattr "hyperlinkSource" _hyperlinkSource , onlyIf (not (null _phaseOverrides)) $ vcat ((map text . lines) _phaseOverrides) , pPrint _metaSection , vcat [ attr k (text v) | (k,v) <- Map.toList _extraAttributes ] diff --git a/distribution-nixpkgs/src/Distribution/Nixpkgs/Meta.hs b/distribution-nixpkgs/src/Distribution/Nixpkgs/Meta.hs index 32d88b162..c523284f6 100644 --- a/distribution-nixpkgs/src/Distribution/Nixpkgs/Meta.hs +++ b/distribution-nixpkgs/src/Distribution/Nixpkgs/Meta.hs @@ -288,7 +288,7 @@ instance Pretty Meta where , maybe mempty (renderPlatforms "hydraPlatforms") _hydraPlatforms , maybe mempty (attr "mainProgram" . string) _mainProgram , listattrDoc "maintainers" mempty $ renderMaintainers _maintainers - , boolattr "broken" _broken _broken + , boolattr "broken" _broken ] -- | This function renders an Nix attribute binding suitable for use in diff --git a/distribution-nixpkgs/src/Language/Nix/PrettyPrinting.hs b/distribution-nixpkgs/src/Language/Nix/PrettyPrinting.hs index fa3a7db93..e64e6301f 100644 --- a/distribution-nixpkgs/src/Language/Nix/PrettyPrinting.hs +++ b/distribution-nixpkgs/src/Language/Nix/PrettyPrinting.hs @@ -34,8 +34,8 @@ attr n v = text n <+> equals <+> v <> semi onlyIf :: Bool -> Doc -> Doc onlyIf b d = if b then d else empty -boolattr :: String -> Bool -> Bool -> Doc -boolattr n p v = if p then attr n (bool v) else empty +boolattr :: String -> Bool -> Doc +boolattr n v = attr n (bool v) listattrDoc :: String -> Doc -> [Doc] -> Doc listattrDoc n prefix vs = onlyIf (not (null vs)) $