Skip to content

Commit 46846bf

Browse files
committed
Merge remote-tracking branch 'origin/master' into hkm/combined-derivations
2 parents ba5bc4e + 2fbc026 commit 46846bf

File tree

6 files changed

+77
-15
lines changed

6 files changed

+77
-15
lines changed

builder/shell-for.nix

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ let
7878
++ lib.optionals packageSetupDeps (map (p: p.setup.config)
7979
(lib.filter (p: p.buildType != "Simple") selectedPackages));
8080

81-
name = if lib.length selectedPackages == 1
81+
identifierName = if lib.length selectedPackages == 1
8282
then "ghc-shell-for-${(lib.head selectedPackages).identifier.name}"
8383
else "ghc-shell-for-packages";
8484

85+
name = if (mkDrvArgs.name or null) == null then identifierName else mkDrvArgs.name;
86+
8587
# We need to remove any dependencies which would bring in selected components (see above).
8688
packageInputs = removeSelectedInputs (lib.concatMap (cfg: cfg.depends) selectedConfigs)
8789
++ additionalPackages;
@@ -90,8 +92,18 @@ let
9092
# We need to remove any inputs which are selected components (see above).
9193
# `buildInputs`, `propagatedBuildInputs`, and `executableToolDepends` contain component
9294
# derivations, not packages, so we use `removeSelectedInputs`).
93-
systemInputs = removeSelectedInputs (lib.concatMap
94-
(c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents);
95+
#
96+
# Also, we take care to keep duplicates out of the list, otherwise we may see
97+
# "Argument list too long" errors from bash when entering a shell.
98+
#
99+
# Version of `lib.unique` that should be fast if the name attributes are unique
100+
uniqueWithName = list:
101+
lib.concatMap lib.unique (
102+
builtins.attrValues (
103+
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list));
104+
allSystemInputs = lib.concatMap (c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents;
105+
systemInputs = removeSelectedInputs (uniqueWithName allSystemInputs);
106+
95107
nativeBuildInputs = removeSelectedInputs
96108
(lib.concatMap (c: c.executableToolDepends) selectedComponents);
97109

@@ -104,14 +116,14 @@ let
104116
doExactConfig = false;
105117
};
106118
configFiles = makeConfigFiles {
107-
fullName = args.name or name;
108-
identifier.name = name;
119+
fullName = name;
120+
identifier.name = identifierName;
109121
inherit component enableDWARF;
110122
chooseDrv = p: if withHaddock && p ? haddock then p.haddock else p;
111123
};
112124
ghcEnv = ghcForComponent {
113125
inherit configFiles;
114-
componentName = name;
126+
componentName = identifierName;
115127
postInstall = lib.optionalString withHoogle' ''
116128
ln -s ${hoogleIndex}/bin/hoogle $out/bin
117129
'';
@@ -145,7 +157,7 @@ let
145157
mkDrvArgs = builtins.removeAttrs args ["packages" "components" "additional" "withHoogle" "tools"];
146158
in
147159
mkShell (mkDrvArgs // {
148-
name = mkDrvArgs.name or name;
160+
inherit name;
149161

150162
buildInputs = systemInputs
151163
++ mkDrvArgs.buildInputs or [];

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/system-nixpkgs-map.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ in
121121
ole32 = null; rpcrt4 = null;
122122
winmm = null; userenv = null;
123123
kernel32 = null; ws2_32 = null;
124+
opengl32 = null; glu32 = null;
124125
# this should be bundled with gcc.
125126
# if it's not we have more severe
126127
# issues anyway.

modules/shell.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{ projectConfig }:
22
{ lib, config, pkgs, haskellLib, ... }: {
33
options = {
4+
name = lib.mkOption {
5+
type = lib.types.nullOr lib.types.str;
6+
default = null;
7+
};
48
packages = lib.mkOption {
59
type = lib.types.unspecified;
610
default = ps: builtins.attrValues (haskellLib.selectLocalPackages ps);
@@ -41,5 +45,29 @@
4145
type = lib.types.unspecified;
4246
default = projectConfig.crossPlatforms;
4347
};
48+
49+
# mkShell args
50+
inputsFrom = lib.mkOption {
51+
type = lib.types.listOf lib.types.unspecified;
52+
default = [];
53+
};
54+
shellHook = lib.mkOption {
55+
type = lib.types.str;
56+
default = "";
57+
};
58+
59+
# mkDerivation args
60+
buildInputs = lib.mkOption {
61+
type = lib.types.listOf lib.types.unspecified;
62+
default = [];
63+
};
64+
nativeBuildInputs = lib.mkOption {
65+
type = lib.types.listOf lib.types.unspecified;
66+
default = [];
67+
};
68+
passthru = lib.mkOption {
69+
type = lib.types.attrsOf lib.types.unspecified;
70+
default = {};
71+
};
4472
};
4573
}

test/nix.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
allow-import-from-derivation = true
2+
allowed-users = *
3+
builders-use-substitutes = true
4+
experimental-features = nix-command flakes
5+
keep-derivations = true
6+
keep-outputs = true
7+
max-jobs = auto
8+
substituters = https://cache.iog.io https://cache.nixos.org https://cache.ngi0.nixos.org/ https://cache.nixos.org/
9+
system-features = nixos-test benchmark big-parallel kvm
10+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo=

test/tests.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/env nix-shell
2-
#! nix-shell -i bash -p bash jq nix gnused
2+
#! nix-shell -i "bash -x" -p bash jq nix gnused
33

44
set -euo pipefail
55

@@ -10,7 +10,7 @@ NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}"
1010
cd $(dirname $0)
1111

1212
if [ "$#" != "1" ]; then
13-
echo "Please pass a compiler-nix-name to use. For example: ./test/test.sh ghc884"
13+
echo "Please pass a compiler-nix-name to use. For example: ./test/tests.sh ghc884"
1414
exit 1
1515
fi
1616

@@ -20,6 +20,17 @@ printf "*** Cleaning package build directories..." >& 2
2020
rm -rvf */cabal.project.local */.ghc.environment* */dist */dist-newstyle */.stack-work
2121
echo >& 2
2222

23+
# This was needed is first place to make hix template / flake devShell examples
24+
# not require interactive user confirmation. Because the IOG nix cache settings
25+
# are defined in the `nixConfig` flake attribute.
26+
if [ ! -z ${CI+x} ]; then
27+
printf "*** Set custom nix.conf for CI ..." >& 2
28+
export XDG_CONFIG_HOME=$HOME/.config
29+
mkdir -p $XDG_CONFIG_HOME/nix
30+
cp ./nix.conf $XDG_CONFIG_HOME/nix
31+
echo >& 2
32+
fi
33+
2334
printf "*** Running the nix-build tests...\n" >& 2
2435
nix build $NIX_BUILD_ARGS \
2536
-I . -I .. \

0 commit comments

Comments
 (0)