Skip to content

Commit db7ea17

Browse files
authored
Add hint to reproduce the devshell flavor locally if within GitHub Action (#138)
Co-authored by @angerman that got the original idea and improve the style of the Nix expressions
1 parent bb543f0 commit db7ea17

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

cross-js.nix

+9-2
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ pkgs.mkShell ({
6161

6262
inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;
6363

64-
shellHook = with pkgs; ''
64+
shellHook =
65+
with pkgs;
66+
let flavor = "${compiler-nix-name}-js"
67+
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
68+
+ lib.optionalString withIOG "-iog"
69+
;
70+
in ''
6571
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
6672
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
6773
${figlet}/bin/figlet -f small "*= JS edition =*"
6874
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
6975
export CABAL_DIR=$HOME/.cabal-js
7076
echo "CABAL_DIR set to $CABAL_DIR"
71-
'' + quirks.shellHook;
77+
echo ""
78+
'' + (quirks.hint flavor) + quirks.shellHook;
7279
buildInputs = [];
7380

7481
nativeBuildInputs = [ wrapped-hsc2hs wrapped-cabal compiler ] ++ (with pkgs; [

cross-windows.nix

+9-2
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,21 @@ pkgs.pkgsBuildBuild.mkShell ({
143143

144144
inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;
145145

146-
shellHook = with pkgs; ''
146+
shellHook =
147+
with pkgs;
148+
let flavor = "${compiler-nix-name}-windows"
149+
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
150+
+ lib.optionalString withIOG "-iog"
151+
;
152+
in ''
147153
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
148154
${pkgsBuildBuild.figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
149155
${pkgsBuildBuild.figlet}/bin/figlet -f small "*= Windows =*"
150156
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
151157
export CABAL_DIR=$HOME/.cabal-windows
152158
echo "CABAL_DIR set to $CABAL_DIR"
153-
'' + quirks.shellHook;
159+
echo ""
160+
'' + (quirks.hint flavor) + quirks.shellHook;
154161
buildInputs = [];
155162

156163
nativeBuildInputs = [ wrapped-ghc wrapped-hsc2hs wrapped-cabal wine-test-wrapper compiler ] ++ (with pkgs; [

dynamic.nix

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ let tool-version-map = import ./tool-map.nix;
4545
esac
4646
'';
4747
};
48+
quirks = (import ./quirks.nix { inherit pkgs; });
4849
in
4950
pkgs.mkShell {
5051
# The `cabal` overrride in this shell-hook doesn't do much yet. But
5152
# we may need to massage cabal a bit, so we'll leave it in here for
5253
# consistency with the one in static.nix.
53-
shellHook = with pkgs; ''
54+
shellHook =
55+
with pkgs;
56+
let flavor = "${compiler-nix-name}"
57+
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
58+
+ lib.optionalString withIOG "-iog"
59+
+ lib.optionalString withIOGFull "-full"
60+
;
61+
in ''
5462
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
5563
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
5664
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
@@ -59,7 +67,8 @@ pkgs.mkShell {
5967
# incompatbile.
6068
export CABAL_DIR=$HOME/.cabal-devx
6169
echo "CABAL_DIR set to $CABAL_DIR"
62-
''
70+
echo ""
71+
'' + (quirks.hint flavor)
6372
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
6473
# The build will error with -6 due to "loading libcrypto in an unsafe way"
6574
+ lib.optionalString stdenv.hostPlatform.isMacOS

quirks.nix

+8
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,13 @@
1818
function patchProjectLocal() {
1919
cat ${template} >> "$1"
2020
}
21+
echo ""
22+
'';
23+
hint = flavor: ''
24+
if [ "$GITHUB_ACTIONS" = "true" ]; then
25+
echo "::notice::Hint: to reproduce this environment locally, use either:" \
26+
"\`nix develop github:input-output-hk/devx#${flavor}\`, or" \
27+
"\`docker run -it -v \$(pwd):/workspaces ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.${flavor}\`"
28+
fi
2129
'';
2230
}

static.nix

+9-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ pkgs.mkShell (rec {
8787
# the system path.
8888
DYLD_LIBRARY_PATH= with pkgs; "${lib.getLib openssl}/lib";
8989

90-
shellHook = with pkgs; ''
90+
shellHook =
91+
with pkgs;
92+
let flavor = "${compiler-nix-name}-static"
93+
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
94+
+ lib.optionalString withIOG "-iog"
95+
;
96+
in ''
9197
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
9298
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}";
9399
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
@@ -97,7 +103,8 @@ pkgs.mkShell (rec {
97103
export CABAL_DIR=$HOME/.cabal-static
98104
echo "CABAL_DIR set to $CABAL_DIR"
99105
echo "DYLD_LIBRARY_PATH set to $DYLD_LIBRARY_PATH"
100-
'' + quirks.shellHook;
106+
echo ""
107+
'' + (quirks.hint flavor) + quirks.shellHook;
101108
# these are _target_ libs, e.g. ones we want to link the build
102109
# product against. These are also the ones that showup in the
103110
# PKG_CONFIG_PATH.

0 commit comments

Comments
 (0)