Skip to content

Commit 97cd059

Browse files
committed
Move projectOverlays.devhshell to haskellLib.devshellFor
1 parent 7fa35bf commit 97cd059

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

lib/default.nix

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ in {
343343
projectOverlays = import ./project-overlays.nix {
344344
inherit lib haskellLib;
345345
};
346-
346+
347347
# Use by `prefixFlake` to add a prefix to every attribute
348348
prefixAttrs = prefix: x:
349349
__listToAttrs (map (n:{
@@ -540,4 +540,28 @@ in {
540540
devShells
541541
devShell; # TODO remove devShell once everyone has nix that supports `devShells.default`
542542
};
543+
544+
# Adapt a standard project shell (`project.shell` or `haskell-nix.shellFor`)
545+
# into a devshell module (https://github.com/numtide/devshell)
546+
# that should provide the same environnement.
547+
devshellFor = shell: {
548+
packages = lib.filter lib.isDerivation (shell.nativeBuildInputs
549+
# devshell does not use pkgs.mkShell / pkgs.stdenv.mkDerivation,
550+
# so we need to explicit required dependencies which
551+
# are provided implicitely by stdenv when using the normal shell:
552+
++ shell.stdenv.defaultNativeBuildInputs)
553+
++ [shell.stdenv.cc.bintools];
554+
# We need to expose all the necessary env variables:
555+
env = [
556+
{
557+
name = "PKG_CONFIG_PATH";
558+
value = lib.makeSearchPath "lib/pkgconfig" shell.buildInputs;
559+
}
560+
] ++ lib.mapAttrsToList lib.nameValuePair ({
561+
inherit (shell) NIX_GHC_LIBDIR;
562+
# CABAL_CONFIG is only set if the shell was built with exactDeps=true
563+
} // lib.optionalAttrs (final.shell ? CABAL_CONFIG) {
564+
inherit (shell) CABAL_CONFIG;
565+
});
566+
};
543567
}

lib/project-overlays.nix

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,11 @@
22
lib
33
, haskellLib
44
}: {
5-
# Provide a devshell profile (https://github.com/numtide/devshell),
6-
# adapted from the project normal shell.
5+
6+
# TODO: remove by end of 2022.
77
devshell = final: prev: {
8-
devshell = let
9-
in {
10-
packages = lib.filter lib.isDerivation (final.shell.nativeBuildInputs
11-
# devshell does not use pkgs.mkShell / pkgs.stdenv.mkDerivation,
12-
# so we need to explicit required dependencies which
13-
# are provided implicitely by stdenv when using the normal shell:
14-
++ final.shell.stdenv.defaultNativeBuildInputs)
15-
++ lib.optional final.shell.stdenv.targetPlatform.isGnu final.pkgs.buildPackages.binutils;
16-
# We need to expose all the necessary env variables:
17-
env = [
18-
{
19-
name = "PKG_CONFIG_PATH";
20-
value = lib.makeSearchPath "lib/pkgconfig" final.shell.buildInputs;
21-
}
22-
] ++ lib.mapAttrsToList lib.nameValuePair ({
23-
inherit (final.shell) NIX_GHC_LIBDIR;
24-
# CABAL_CONFIG is only set if the shell was built with exactDeps=true
25-
} // lib.optionalAttrs (final.shell ? CABAL_CONFIG) {
26-
inherit (final.shell) CABAL_CONFIG;
27-
});
28-
};
8+
devshell = builtins.trace "WARNING: `projectOverlays.devshell` is deprecated in favor of `haskellLib.devshellFor`"
9+
(haskellLib.devshellFor final.shell);
2910
};
3011

3112
# Provides easily accessible attrset for each type of

0 commit comments

Comments
 (0)