Skip to content

Commit

Permalink
Change boolattr to always write to the attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Oct 31, 2022
1 parent 8e97f51 commit 65302c5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
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 fromJust derivSubmodule)
]
, rbrace PP.<> semi
]
Expand Down
16 changes: 8 additions & 8 deletions cabal2nix/src/Distribution/Nixpkgs/Haskell/Derivation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ 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 "isLibrary" _isLibrary
, boolattr "isExecutable" _isExecutable
, boolattr "enableSeparateDataOutput" _enableSeparateDataOutput _enableSeparateDataOutput
, onlyIf (_setupDepends /= mempty) $ pPrintBuildInfo "setup" _setupDepends
, onlyIf (_libraryDepends /= mempty) $ pPrintBuildInfo "library" _libraryDepends
Expand All @@ -130,13 +130,13 @@ instance Pretty Derivation where
, 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 "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

0 comments on commit 65302c5

Please sign in to comment.