Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/cabal2nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c6118bc8c1f1
Choose a base ref
...
head repository: NixOS/cabal2nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d15b0f23655e
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 13, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ea513a7 View commit details
  2. Add support for "extraAttributes" to the Derivation type.

    This allows us to set basically anything we want and we'll probably remove most
    of the other attributes (doJailbreak, doHaddock, etc.) in favor of this
    catch-all. We actually don't need parsed, type-safe access to these attributes
    in cabal2nix. We just pretty-print them when generating the output.
    peti committed Jun 13, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    192782e View commit details
  3. cabal2nix.cabal: minor version bump

    Per module diff:
    
      * Distribution.Nixpkgs.Haskell
        Added exports:
          ExportedFunction "extraAttributes"
    
      * Distribution.Nixpkgs.Haskell.Derivation
        Added exports:
          ExportedFunction "extraAttributes"
    peti committed Jun 13, 2020
    Copy the full SHA
    d15b0f2 View commit details
Showing with 11 additions and 8 deletions.
  1. +1 −1 cabal2nix.cabal
  2. +1 −1 src/Distribution/Nixpkgs/Fetch.hs
  3. +8 −6 src/Distribution/Nixpkgs/Haskell/Derivation.hs
  4. +1 −0 src/Distribution/Nixpkgs/Haskell/FromCabal.hs
2 changes: 1 addition & 1 deletion cabal2nix.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cabal2nix
version: 2.15.4
version: 2.15.5
synopsis: Convert Cabal files into Nix build instructions.
description:
Convert Cabal files into Nix build instructions. Users of Nix can install the latest
2 changes: 1 addition & 1 deletion src/Distribution/Nixpkgs/Fetch.hs
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ instance PP.Pretty DerivationSource where
pPrint DerivationSource {..} =
let isHackagePackage = "mirror://hackage/" `L.isPrefixOf` derivUrl
fetched = derivKind /= ""
in if isHackagePackage then attr "sha256" $ string derivHash
in if isHackagePackage then if derivHash /= "" then attr "sha256" $ string derivHash else mempty
else if not fetched then attr "src" $ text derivUrl
else vcat
[ text "src" <+> equals <+> text ("fetch" ++ derivKind) <+> lbrace
14 changes: 8 additions & 6 deletions src/Distribution/Nixpkgs/Haskell/Derivation.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
@@ -9,13 +8,17 @@ module Distribution.Nixpkgs.Haskell.Derivation
, extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags
, cabalFlags, runHaddock, jailbreak, doCheck, doBenchmark, testTarget, hyperlinkSource, enableSplitObjs
, enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection
, dependencies, setupDepends, benchmarkDepends, enableSeparateDataOutput
, dependencies, setupDepends, benchmarkDepends, enableSeparateDataOutput, extraAttributes
)
where

import Prelude hiding ((<>))

import Control.DeepSeq
import Control.Lens
import Data.List ( isPrefixOf )
import Data.Map ( Map )
import qualified Data.Map as Map
import Data.Set ( Set )
import qualified Data.Set as Set
import Data.Set.Lens
@@ -29,10 +32,6 @@ import GHC.Generics ( Generic )
import Language.Nix
import Language.Nix.PrettyPrinting

#if MIN_VERSION_base(4,11,0)
import Prelude hiding ((<>))
#endif

-- | A represtation of Nix expressions for building Haskell packages.
-- The data type correspond closely to the definition of
-- 'PackageDescription' from Cabal.
@@ -45,6 +44,7 @@ data Derivation = MkDerivation
, _isLibrary :: Bool
, _isExecutable :: Bool
, _extraFunctionArgs :: Set Binding
, _extraAttributes :: Map String String
, _setupDepends :: BuildInfo
, _libraryDepends :: BuildInfo
, _executableDepends :: BuildInfo
@@ -77,6 +77,7 @@ nullDerivation = MkDerivation
, _isLibrary = error "undefined Derivation.isLibrary"
, _isExecutable = error "undefined Derivation.isExecutable"
, _extraFunctionArgs = error "undefined Derivation.extraFunctionArgs"
, _extraAttributes = error "undefined Derivation.extraAttributes"
, _setupDepends = error "undefined Derivation.setupDepends"
, _libraryDepends = error "undefined Derivation.libraryDepends"
, _executableDepends = error "undefined Derivation.executableDepends"
@@ -138,6 +139,7 @@ instance Pretty Derivation where
, boolattr "hyperlinkSource" (not _hyperlinkSource) _hyperlinkSource
, onlyIf (not (null _phaseOverrides)) $ vcat ((map text . lines) _phaseOverrides)
, pPrint _metaSection
, vcat [ attr k (text v) | (k,v) <- Map.toList _extraAttributes ]
]
, rbrace
]
1 change: 1 addition & 0 deletions src/Distribution/Nixpkgs/Haskell/FromCabal.hs
Original file line number Diff line number Diff line change
@@ -83,6 +83,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
& isLibrary .~ isJust library
& isExecutable .~ not (null executables)
& extraFunctionArgs .~ mempty
& extraAttributes .~ mempty
& libraryDepends .~ foldMap (convertBuildInfo . libBuildInfo) (maybeToList library ++ subLibraries)
& executableDepends .~ mconcat (map (convertBuildInfo . buildInfo) executables)
& testDepends .~ mconcat (map (convertBuildInfo . testBuildInfo) testSuites)