Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Change boolattr to always write to the attributes
  • Loading branch information
locallycompact committed Oct 31, 2022
commit 1183456755ea6bdd409852d972ab08eafb9a91d5
2 changes: 1 addition & 1 deletion cabal2nix/src/Distribution/Nixpkgs/Fetch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
22 changes: 11 additions & 11 deletions cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,23 @@ 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 "enableSplitObjs" _enableSplitObjs
, 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 ]
Expand Down
2 changes: 1 addition & 1 deletion distribution-nixpkgs/src/Distribution/Nixpkgs/Meta.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions distribution-nixpkgs/src/Language/Nix/PrettyPrinting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) $
Expand Down