@@ -56,10 +56,10 @@ flags = "flags"
56
56
buildDepError , sysDepError , pkgConfDepError , exeDepError , legacyExeDepError , buildToolDepError :: Text
57
57
buildDepError = " buildDepError"
58
58
sysDepError = " sysDepError"
59
- pkgConfDepError = " pkgConfDepError"
59
+ pkgConfDepError = " pkgConfDepError"
60
60
exeDepError = " exeDepError"
61
61
legacyExeDepError = " legacyExeDepError"
62
- buildToolDepError = " buildToolDepError"
62
+ buildToolDepError = " buildToolDepError"
63
63
64
64
($//?) :: NExpr -> Maybe NExpr -> NExpr
65
65
lhs $//? (Just e) = lhs $// e
@@ -87,17 +87,17 @@ genExtra Hpack = mkNonRecSet [ "cabal-generator" $= mkStr "hpack" ]
87
87
88
88
data CabalDetailLevel = MinimalDetails | FullDetails deriving (Show , Eq )
89
89
90
- cabal2nix :: CabalDetailLevel -> Maybe Src -> CabalFile -> IO NExpr
91
- cabal2nix fileDetails src = \ case
92
- (OnDisk path) -> gpd2nix fileDetails src Nothing
90
+ cabal2nix :: Bool -> CabalDetailLevel -> Maybe Src -> CabalFile -> IO NExpr
91
+ cabal2nix isLocal fileDetails src = \ case
92
+ (OnDisk path) -> gpd2nix isLocal fileDetails src Nothing
93
93
<$> readGenericPackageDescription normal path
94
- (InMemory gen _ body) -> gpd2nix fileDetails src (genExtra <$> gen)
94
+ (InMemory gen _ body) -> gpd2nix isLocal fileDetails src (genExtra <$> gen)
95
95
<$> case runParseResult (parseGenericPackageDescription body) of
96
96
(_, Left (_, err)) -> error (" Failed to parse in-memory cabal file: " ++ show err)
97
97
(_, Right desc) -> pure desc
98
98
99
- gpd2nix :: CabalDetailLevel -> Maybe Src -> Maybe NExpr -> GenericPackageDescription -> NExpr
100
- gpd2nix fileDetails src extra gpd = mkLets errorFunctions $ mkFunction args $ toNix' fileDetails gpd $//? (toNix <$> src) $//? extra
99
+ gpd2nix :: Bool -> CabalDetailLevel -> Maybe Src -> Maybe NExpr -> GenericPackageDescription -> NExpr
100
+ gpd2nix isLocal fileDetails src extra gpd = mkLets errorFunctions $ mkFunction args $ toNixGenericPackageDescription isLocal fileDetails gpd $//? (toNix <$> src) $//? extra
101
101
where args :: Params NExpr
102
102
args = mkParamset [ (" system" , Nothing )
103
103
, (" compiler" , Nothing )
@@ -108,44 +108,44 @@ gpd2nix fileDetails src extra gpd = mkLets errorFunctions $ mkFunction args $ to
108
108
True
109
109
110
110
errorFunctions :: [Binding NExpr ]
111
- errorFunctions =
112
- [ buildDepError $= mkFunction " pkg" (mkThrow $
113
- Fix $ NStr $ Indented 0
114
- [ Plain " The Haskell package set does not contain the package: "
111
+ errorFunctions =
112
+ [ buildDepError $= mkFunction " pkg" (mkThrow $
113
+ Fix $ NStr $ Indented 0
114
+ [ Plain " The Haskell package set does not contain the package: "
115
115
, Antiquoted " pkg"
116
116
, Plain " (build dependency).\n\n "
117
117
, Plain haskellUpdateSnippet
118
118
])
119
- , sysDepError $= mkFunction " pkg" (mkThrow $
120
- Fix $ NStr $ Indented 0
121
- [ Plain " The Nixpkgs package set does not contain the package: "
119
+ , sysDepError $= mkFunction " pkg" (mkThrow $
120
+ Fix $ NStr $ Indented 0
121
+ [ Plain " The Nixpkgs package set does not contain the package: "
122
122
, Antiquoted " pkg"
123
123
, Plain " (system dependency).\n\n "
124
124
, Plain systemUpdateSnippet
125
125
])
126
- , pkgConfDepError $= mkFunction " pkg" (mkThrow $
127
- Fix $ NStr $ Indented 0
128
- [ Plain " The pkg-conf packages does not contain the package: "
126
+ , pkgConfDepError $= mkFunction " pkg" (mkThrow $
127
+ Fix $ NStr $ Indented 0
128
+ [ Plain " The pkg-conf packages does not contain the package: "
129
129
, Antiquoted " pkg"
130
130
, Plain " (pkg-conf dependency).\n\n "
131
131
, Plain " You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found."
132
132
])
133
- , exeDepError $= mkFunction " pkg" (mkThrow $
134
- Fix $ NStr $ Indented 0
135
- [ Plain " The local executable components do not include the component: "
133
+ , exeDepError $= mkFunction " pkg" (mkThrow $
134
+ Fix $ NStr $ Indented 0
135
+ [ Plain " The local executable components do not include the component: "
136
136
, Antiquoted " pkg"
137
137
, Plain " (executable dependency)."
138
138
])
139
- , legacyExeDepError $= mkFunction " pkg" (mkThrow $
140
- Fix $ NStr $ Indented 0
141
- [ Plain " The Haskell package set does not contain the package: "
139
+ , legacyExeDepError $= mkFunction " pkg" (mkThrow $
140
+ Fix $ NStr $ Indented 0
141
+ [ Plain " The Haskell package set does not contain the package: "
142
142
, Antiquoted " pkg"
143
143
, Plain " (executable dependency).\n\n "
144
144
, Plain haskellUpdateSnippet
145
145
])
146
- , buildToolDepError $= mkFunction " pkg" (mkThrow $
147
- Fix $ NStr $ Indented 0
148
- [ Plain " Neither the Haskell package set or the Nixpkgs package set contain the package: "
146
+ , buildToolDepError $= mkFunction " pkg" (mkThrow $
147
+ Fix $ NStr $ Indented 0
148
+ [ Plain " Neither the Haskell package set or the Nixpkgs package set contain the package: "
149
149
, Antiquoted " pkg"
150
150
, Plain " (build tool dependency).\n\n "
151
151
, Plain " If this is a system dependency:\n "
@@ -213,9 +213,6 @@ capitalize = transformFst toUpper
213
213
class ToNixExpr a where
214
214
toNix :: a -> NExpr
215
215
216
- class ToNixExpr' a where
217
- toNix' :: CabalDetailLevel -> a -> NExpr
218
-
219
216
class ToNixBinding a where
220
217
toNixBinding :: a -> Binding NExpr
221
218
@@ -242,8 +239,8 @@ instance ToNixExpr PackageIdentifier where
242
239
toNix ident = mkNonRecSet [ " name" $= mkStr (fromString (show (disp (pkgName ident))))
243
240
, " version" $= mkStr (fromString (show (disp (pkgVersion ident))))]
244
241
245
- instance ToNixExpr' PackageDescription where
246
- toNix' detailLevel pd = mkNonRecSet $
242
+ toNixPackageDescription :: Bool -> CabalDetailLevel -> PackageDescription -> NExpr
243
+ toNixPackageDescription isLocal detailLevel pd = mkNonRecSet $
247
244
[ " specVersion" $= mkStr (fromString (show (disp (specVersion pd))))
248
245
, " identifier" $= toNix (package pd)
249
246
, " license" $= mkStr (fromString (show (pretty (license pd))))
@@ -260,6 +257,8 @@ instance ToNixExpr' PackageDescription where
260
257
261
258
, " buildType" $= mkStr (fromString (show (pretty (buildType pd))))
262
259
] ++
260
+ [ " isLocal" $= mkBool True | isLocal
261
+ ] ++
263
262
[ " setup-depends" $= toNix (BuildToolDependency . depPkgName <$> deps) | Just deps <- [setupDepends <$> setupBuildInfo pd ]] ++
264
263
if detailLevel == MinimalDetails
265
264
then []
@@ -279,10 +278,10 @@ newtype BuildToolDependency = BuildToolDependency { unBuildToolDependency :: Pac
279
278
mkSysDep :: String -> SysDependency
280
279
mkSysDep = SysDependency
281
280
282
- instance ToNixExpr' GenericPackageDescription where
283
- toNix' detailLevel gpd = mkNonRecSet
281
+ toNixGenericPackageDescription :: Bool -> CabalDetailLevel -> GenericPackageDescription -> NExpr
282
+ toNixGenericPackageDescription isLocal detailLevel gpd = mkNonRecSet
284
283
[ " flags" $= (mkNonRecSet . fmap toNixBinding $ genPackageFlags gpd)
285
- , " package" $= toNix' detailLevel (packageDescription gpd)
284
+ , " package" $= toNixPackageDescription isLocal detailLevel (packageDescription gpd)
286
285
, " components" $= components ]
287
286
where _packageName :: IsString a => a
288
287
_packageName = fromString . show . disp . pkgName . package . packageDescription $ gpd
0 commit comments