Skip to content

Commit 7a9c88e

Browse files
committed
default.nix: use (pkgs.haskell.lib -> hlib), (pkgs.lib -> lib)
1 parent e06bdd5 commit 7a9c88e

File tree

1 file changed

+26
-62
lines changed

1 file changed

+26
-62
lines changed

default.nix

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@
111111

112112
let
113113

114+
hlib = pkgs.haskell.lib;
115+
lib = pkgs.lib;
116+
114117
getDefaultGHC = "ghc${
115118
(
116119
# Remove '.' from the string 8.8.4 -> 884
117-
pkgs.lib.stringAsChars (c: if c == "." then "" else c)
120+
lib.stringAsChars (c: if c == "." then "" else c)
118121
# Get default GHC version,
119-
(pkgs.lib.getVersion pkgs.haskellPackages.ghc)
122+
(lib.getVersion pkgs.haskellPackages.ghc)
120123
)
121124
}";
122125

@@ -133,10 +136,10 @@ let
133136
# sha256 = "0fxig1ckzknm5g19jzg7rrcpz7ssn4iiv9bs9hff9gfy3ciq4zrs";
134137
# };
135138

136-
overlay = pkgs.lib.foldr pkgs.lib.composeExtensions (_: _: {}) [
137-
# (import "${hnix-store-src}/overlay.nix" pkgs pkgs.haskell.lib)
139+
overlay = lib.foldr lib.composeExtensions (_: _: {}) [
140+
# (import "${hnix-store-src}/overlay.nix" pkgs hlib)
138141
(self: super:
139-
pkgs.lib.optionalAttrs withHoogle {
142+
lib.optionalAttrs withHoogle {
140143
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
141144
ghcWithPackages = self.ghc.withPackages;
142145
})
@@ -146,7 +149,7 @@ let
146149
buildHaskellPackages =
147150
orig.buildHaskellPackages.override overrideHaskellPackages;
148151
overrides = if orig ? overrides
149-
then pkgs.lib.composeExtensions orig.overrides overlay
152+
then lib.composeExtensions orig.overrides overlay
150153
else overlay;
151154
};
152155

@@ -156,58 +159,19 @@ let
156159
# Application of functions from this list to the package in code here happens in the reverse order (from the tail). Some options depend on & override others, so if enabling options caused Nix error or not expected result - change the order, and please do not change this order without proper testing.
157160
listSwitchFunc =
158161
[
159-
{
160-
switch = sdistTarball;
161-
function = pkgs.haskell.lib.sdistTarball;
162-
}
163-
{
164-
switch = buildFromSdist;
165-
function = pkgs.haskell.lib.buildFromSdist;
166-
}
167-
{
168-
switch = buildStrictly;
169-
function = pkgs.haskell.lib.buildStrictly;
170-
}
171-
{
172-
switch = disableOptimization;
173-
function = pkgs.haskell.lib.disableOptimization;
174-
}
175-
{
176-
switch = doJailbreak;
177-
function = pkgs.haskell.lib.doJailBreak;
178-
}
179-
{
180-
switch = doStrip;
181-
function = pkgs.haskell.lib.doStrip;
182-
}
183-
{
184-
switch = enableDWARFDebugging;
185-
function = pkgs.haskell.lib.enableDWARFDebugging;
186-
}
187-
{
188-
switch = linkWithGold;
189-
function = pkgs.haskell.lib.linkWithGold;
190-
}
191-
{
192-
switch = failOnAllWarnings;
193-
function = pkgs.haskell.lib.failOnAllWarnings;
194-
}
195-
{
196-
switch = justStaticExecutables;
197-
function = pkgs.haskell.lib.justStaticExecutables;
198-
}
199-
{
200-
switch = checkUnusedPackages;
201-
function = pkgs.haskell.lib.checkUnusedPackages {};
202-
}
203-
{
204-
switch = generateOptparseApplicativeCompletions;
205-
function = pkgs.haskell.lib.generateOptparseApplicativeCompletions executableNamesToShellComplete;
206-
}
207-
{
208-
switch = doHyperlinkSource;
209-
function = pkgs.haskell.lib.doHyperlinkSource;
210-
}
162+
{ switch = sdistTarball; function = hlib.sdistTarball; }
163+
{ switch = buildFromSdist; function = hlib.buildFromSdist; }
164+
{ switch = buildStrictly; function = hlib.buildStrictly; }
165+
{ switch = disableOptimization; function = hlib.disableOptimization; }
166+
{ switch = doJailbreak; function = hlib.doJailBreak; }
167+
{ switch = doStrip; function = hlib.doStrip; }
168+
{ switch = enableDWARFDebugging; function = hlib.enableDWARFDebugging; }
169+
{ switch = linkWithGold; function = hlib.linkWithGold; }
170+
{ switch = failOnAllWarnings; function = hlib.failOnAllWarnings; }
171+
{ switch = justStaticExecutables; function = hlib.justStaticExecutables; }
172+
{ switch = checkUnusedPackages; function = hlib.checkUnusedPackages {}; }
173+
{ switch = generateOptparseApplicativeCompletions; function = hlib.generateOptparseApplicativeCompletions executableNamesToShellComplete; }
174+
{ switch = doHyperlinkSource; function = hlib.doHyperlinkSource; }
211175
];
212176

213177
# Function that applies enabled option to the package, used in the fold.
@@ -231,11 +195,11 @@ let
231195
# 2020-12-07 hnix-store-remote fails when trying to connect to a real hnix daemon.
232196
# probably due to nix sandbox restrictions.
233197
# Upstream issue @ https://github.com/haskell-nix/hnix-store/issues/80
234-
hnix-store-remote = pkgs.haskell.lib.unmarkBroken super.hnix-store-remote;
198+
hnix-store-remote = hlib.unmarkBroken super.hnix-store-remote;
235199

236200
};
237201

238-
modifier = drv: pkgs.haskell.lib.overrideCabal drv (attrs: {
202+
modifier = drv: hlib.overrideCabal drv (attrs: {
239203
buildTools = (attrs.buildTools or []) ++ [
240204
haskellPackages.cabal-install
241205
];
@@ -259,7 +223,7 @@ let
259223
inherit doCoverage;
260224
inherit doHaddock;
261225

262-
configureFlags = pkgs.stdenv.lib.optional doTracing "--flags=tracing";
226+
configureFlags = lib.optional doTracing "--flags=tracing";
263227

264228
passthru = {
265229
nixpkgs = pkgs;
@@ -273,7 +237,7 @@ let
273237
# One part of Haskell.lib options are argument switches, those are in `inherit`ed list.
274238
# Other part - are function wrappers over pkg. Fold allows to compose those.
275239
# composePackage = foldr (if switch then function) (package) ([{switch,function}]) == (functionN .. (function1 package))
276-
composedPackage = pkgs.lib.foldr (onSwitchApplyFunc) package listSwitchFunc;
240+
composedPackage = lib.foldr (onSwitchApplyFunc) package listSwitchFunc;
277241

278242
in composedPackage
279243

0 commit comments

Comments
 (0)