nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 375 lines 13 kB view raw
1# TODO(@Ericson2314): Remove `pkgs` param, which is only used for 2# `buildStackProject`, `justStaticExecutables` and `checkUnusedPackages` 3{ pkgs, lib }: 4 5rec { 6 /* 7 The same functionality as this haskell.lib, except that the derivation 8 being overridden is always the last parameter. This permits more natural 9 composition of several overrides, i.e. without having to nestle one call 10 between the function name and argument of another. haskell.lib.compose is 11 preferred for any new code. 12 */ 13 compose = import ./compose.nix { inherit pkgs lib; }; 14 15 /* 16 This function takes a file like `hackage-packages.nix` and constructs 17 a full package set out of that. 18 */ 19 makePackageSet = compose.makePackageSet; 20 21 /* 22 The function overrideCabal lets you alter the arguments to the 23 mkDerivation function. 24 25 Example: 26 27 First, note how the aeson package is constructed in hackage-packages.nix: 28 29 "aeson" = callPackage ({ mkDerivation, attoparsec, <snip> 30 }: 31 mkDerivation { 32 pname = "aeson"; 33 <snip> 34 homepage = "https://github.com/bos/aeson"; 35 }) 36 37 The mkDerivation function of haskellPackages will take care of putting 38 the homepage in the right place, in meta. 39 40 > haskellPackages.aeson.meta.homepage 41 "https://github.com/bos/aeson" 42 43 > x = haskell.lib.overrideCabal haskellPackages.aeson (old: { homepage = old.homepage + "#readme"; }) 44 > x.meta.homepage 45 "https://github.com/bos/aeson#readme" 46 */ 47 overrideCabal = drv: f: compose.overrideCabal f drv; 48 49 # : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet 50 # Given a set whose values are either paths or version strings, produces 51 # a package override set (i.e. (self: super: { etc. })) that sets 52 # the packages named in the input set to the corresponding versions 53 packageSourceOverrides = compose.packageSourceOverrides; 54 55 /* 56 doCoverage modifies a haskell package to enable the generation 57 and installation of a coverage report. 58 59 See https://wiki.haskell.org/Haskell_program_coverage 60 */ 61 doCoverage = compose.doCoverage; 62 63 /* 64 dontCoverage modifies a haskell package to disable the generation 65 and installation of a coverage report. 66 */ 67 dontCoverage = compose.dontCoverage; 68 69 /* 70 doHaddock modifies a haskell package to enable the generation and 71 installation of API documentation from code comments using the 72 haddock tool. 73 */ 74 doHaddock = compose.doHaddock; 75 76 /* 77 dontHaddock modifies a haskell package to disable the generation and 78 installation of API documentation from code comments using the 79 haddock tool. 80 */ 81 dontHaddock = compose.dontHaddock; 82 83 /* 84 doJailbreak enables the removal of version bounds from the cabal 85 file. You may want to avoid this function. 86 87 This is useful when a package reports that it can not be built 88 due to version mismatches. In some cases, removing the version 89 bounds entirely is an easy way to make a package build, but at 90 the risk of breaking software in non-obvious ways now or in the 91 future. 92 93 Instead of jailbreaking, you can patch the cabal file. 94 95 Note that jailbreaking at this time, doesn't lift bounds on 96 conditional branches. 97 https://github.com/peti/jailbreak-cabal/issues/7 (krank:ignore-line) 98 has further details. 99 */ 100 doJailbreak = compose.doJailbreak; 101 102 /* 103 dontJailbreak restores the use of the version bounds the check 104 the use of dependencies in the package description. 105 */ 106 dontJailbreak = compose.dontJailbreak; 107 108 /* 109 doCheck enables dependency checking, compilation and execution 110 of test suites listed in the package description file. 111 */ 112 doCheck = compose.doCheck; 113 /* 114 dontCheck disables dependency checking, compilation and execution 115 of test suites listed in the package description file. 116 */ 117 dontCheck = compose.dontCheck; 118 /* 119 The dontCheckIf variant sets doCheck = false if the condition 120 applies. In any other case the previously set/default value is used. 121 This prevents accidentally re-enabling tests in a later override. 122 */ 123 dontCheckIf = drv: condition: compose.dontCheckIf condition drv; 124 125 /* 126 doBenchmark enables dependency checking, compilation and execution 127 for benchmarks listed in the package description file. 128 */ 129 doBenchmark = compose.doBenchmark; 130 /* 131 dontBenchmark disables dependency checking, compilation and execution 132 for benchmarks listed in the package description file. 133 */ 134 dontBenchmark = compose.dontBenchmark; 135 136 /* 137 doDistribute enables the distribution of binaries for the package 138 via hydra. 139 */ 140 doDistribute = compose.doDistribute; 141 /* 142 dontDistribute disables the distribution of binaries for the package 143 via hydra. 144 */ 145 dontDistribute = compose.dontDistribute; 146 147 /* 148 appendConfigureFlag adds a single argument that will be passed to the 149 cabal configure command, after the arguments that have been defined 150 in the initial declaration or previous overrides. 151 152 Example: 153 154 > haskell.lib.appendConfigureFlag haskellPackages.servant "--profiling-detail=all-functions" 155 */ 156 appendConfigureFlag = drv: x: compose.appendConfigureFlag x drv; 157 appendConfigureFlags = drv: xs: compose.appendConfigureFlags xs drv; 158 159 appendBuildFlag = drv: x: compose.appendBuildFlag x drv; 160 appendBuildFlags = drv: xs: compose.appendBuildFlags xs drv; 161 162 /* 163 removeConfigureFlag drv x is a Haskell package like drv, but with 164 all cabal configure arguments that are equal to x removed. 165 166 > haskell.lib.removeConfigureFlag haskellPackages.servant "--verbose" 167 */ 168 removeConfigureFlag = drv: x: compose.removeConfigureFlag x drv; 169 170 addBuildTool = drv: x: compose.addBuildTool x drv; 171 addBuildTools = drv: xs: compose.addBuildTools xs drv; 172 173 addExtraLibrary = drv: x: compose.addExtraLibrary x drv; 174 addExtraLibraries = drv: xs: compose.addExtraLibraries xs drv; 175 176 addBuildDepend = drv: x: compose.addBuildDepend x drv; 177 addBuildDepends = drv: xs: compose.addBuildDepends xs drv; 178 179 addTestToolDepend = drv: x: compose.addTestToolDepend x drv; 180 addTestToolDepends = drv: xs: compose.addTestToolDepends xs drv; 181 182 addPkgconfigDepend = drv: x: compose.addPkgconfigDepend x drv; 183 addPkgconfigDepends = drv: xs: compose.addPkgconfigDepends xs drv; 184 185 addSetupDepend = drv: x: compose.addSetupDepend x drv; 186 addSetupDepends = drv: xs: compose.addSetupDepends xs drv; 187 188 enableCabalFlag = drv: x: compose.enableCabalFlag x drv; 189 disableCabalFlag = drv: x: compose.disableCabalFlag x drv; 190 191 markBroken = compose.markBroken; 192 unmarkBroken = compose.unmarkBroken; 193 markBrokenVersion = compose.markBrokenVersion; 194 markUnbroken = compose.markUnbroken; 195 196 disableParallelBuilding = compose.disableParallelBuilding; 197 198 enableLibraryProfiling = compose.enableLibraryProfiling; 199 disableLibraryProfiling = compose.disableLibraryProfiling; 200 201 enableExecutableProfiling = compose.enableExecutableProfiling; 202 disableExecutableProfiling = compose.disableExecutableProfiling; 203 204 enableSharedExecutables = compose.enableSharedExecutables; 205 disableSharedExecutables = compose.disableSharedExecutables; 206 207 enableSharedLibraries = compose.enableSharedLibraries; 208 disableSharedLibraries = compose.disableSharedLibraries; 209 210 enableDeadCodeElimination = compose.enableDeadCodeElimination; 211 disableDeadCodeElimination = compose.disableDeadCodeElimination; 212 213 enableStaticLibraries = compose.enableStaticLibraries; 214 disableStaticLibraries = compose.disableStaticLibraries; 215 216 enableSeparateBinOutput = compose.enableSeparateBinOutput; 217 218 appendPatch = drv: x: compose.appendPatch x drv; 219 appendPatches = drv: xs: compose.appendPatches xs drv; 220 221 /* 222 Set a specific build target instead of compiling all targets in the package. 223 For example, imagine we have a .cabal file with a library, and 2 executables "dev" and "server". 224 We can build only "server" and not wait on the compilation of "dev" by using setBuildTarget as follows: 225 226 setBuildTarget (callCabal2nix "thePackageName" thePackageSrc {}) "server" 227 */ 228 setBuildTargets = drv: xs: compose.setBuildTargets xs drv; 229 setBuildTarget = drv: x: compose.setBuildTarget x drv; 230 231 doHyperlinkSource = compose.doHyperlinkSource; 232 dontHyperlinkSource = compose.dontHyperlinkSource; 233 234 disableHardening = drv: flags: compose.disableHardening flags drv; 235 236 /* 237 Let Nix strip the binary files. 238 This removes debugging symbols. 239 */ 240 doStrip = compose.doStrip; 241 242 /* 243 Stop Nix from stripping the binary files. 244 This keeps debugging symbols. 245 */ 246 dontStrip = compose.dontStrip; 247 248 /* 249 Useful for debugging segfaults with gdb. 250 This includes dontStrip. 251 */ 252 enableDWARFDebugging = compose.enableDWARFDebugging; 253 254 /* 255 Create a source distribution tarball like those found on hackage, 256 instead of building the package. 257 */ 258 sdistTarball = compose.sdistTarball; 259 260 /* 261 Create a documentation tarball suitable for uploading to Hackage instead 262 of building the package. 263 */ 264 documentationTarball = compose.documentationTarball; 265 266 /* 267 Use the gold linker. It is a linker for ELF that is designed 268 "to run as fast as possible on modern systems" 269 */ 270 linkWithGold = compose.linkWithGold; 271 272 /* 273 link executables statically against haskell libs to reduce 274 closure size 275 */ 276 justStaticExecutables = compose.justStaticExecutables; 277 278 /* 279 Build a source distribution tarball instead of using the source files 280 directly. The effect is that the package is built as if it were published 281 on hackage. This can be used as a test for the source distribution, 282 assuming the build fails when packaging mistakes are in the cabal file. 283 */ 284 buildFromSdist = compose.buildFromSdist; 285 286 /* 287 Build the package in a strict way to uncover potential problems. 288 This includes buildFromSdist and failOnAllWarnings. 289 */ 290 buildStrictly = compose.buildStrictly; 291 292 # Disable core optimizations, significantly speeds up build time 293 disableOptimization = compose.disableOptimization; 294 295 /* 296 Turn on most of the compiler warnings and fail the build if any 297 of them occur. 298 */ 299 failOnAllWarnings = compose.failOnAllWarnings; 300 301 /* 302 Add a post-build check to verify that dependencies declared in 303 the cabal file are actually used. 304 305 The first attrset argument can be used to configure the strictness 306 of this check and a list of ignored package names that would otherwise 307 cause false alarms. 308 */ 309 checkUnusedPackages = compose.checkUnusedPackages; 310 311 buildStackProject = compose.buildStackProject; 312 313 /* 314 Add a dummy command to trigger a build despite an equivalent 315 earlier build that is present in the store or cache. 316 */ 317 triggerRebuild = drv: i: compose.triggerRebuild i drv; 318 319 /* 320 Override the sources for the package and optionally the version. 321 This also takes of removing editedCabalFile. 322 */ 323 overrideSrc = drv: src: compose.overrideSrc src drv; 324 325 # Get all of the build inputs of a haskell package, divided by category. 326 getBuildInputs = compose.getBuildInputs; 327 328 # Extract the haskell build inputs of a haskell package. 329 # This is useful to build environments for developing on that 330 # package. 331 getHaskellBuildInputs = compose.getHaskellBuildInputs; 332 333 # Under normal evaluation, simply return the original package. Under 334 # nix-shell evaluation, return a nix-shell optimized environment. 335 shellAware = compose.shellAware; 336 337 # Utility to convert a directory full of `cabal2nix`-generated files into a 338 # package override set 339 # 340 # packagesFromDirectory : { directory : Directory, ... } -> HaskellPackageOverrideSet 341 packagesFromDirectory = compose.packagesFromDirectory; 342 343 /* 344 Modify a Haskell package to add shell completion scripts for the 345 given executable produced by it. These completion scripts will be 346 picked up automatically if the resulting derivation is installed, 347 e.g. by `nix-env -i`. 348 349 Invocation: 350 generateOptparseApplicativeCompletions command pkg 351 352 command: name of an executable 353 pkg: Haskell package that builds the executables 354 */ 355 generateOptparseApplicativeCompletion = compose.generateOptparseApplicativeCompletion; 356 357 /* 358 Modify a Haskell package to add shell completion scripts for the 359 given executables produced by it. These completion scripts will be 360 picked up automatically if the resulting derivation is installed, 361 e.g. by `nix-env -i`. 362 363 Invocation: 364 generateOptparseApplicativeCompletions commands pkg 365 366 commands: name of an executable 367 pkg: Haskell package that builds the executables 368 */ 369 generateOptparseApplicativeCompletions = compose.generateOptparseApplicativeCompletions; 370 371 # Don't fail at configure time if there are multiple versions of the 372 # same package in the (recursive) dependencies of the package being 373 # built. Will delay failures, if any, to compile time. 374 allowInconsistentDependencies = compose.allowInconsistentDependencies; 375}