Skip to content

Commit

Permalink
Add hint to reproduce the devshell flavor locally if within GitHub Ac…
Browse files Browse the repository at this point in the history
…tion

Co-authored by @angerman that got the original idea and improve the style of the Nix expressions
  • Loading branch information
yvan-sraka committed Apr 4, 2024
1 parent bb543f0 commit 6541d98
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
11 changes: 9 additions & 2 deletions cross-js.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ pkgs.mkShell ({

inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;

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

nativeBuildInputs = [ wrapped-hsc2hs wrapped-cabal compiler ] ++ (with pkgs; [
Expand Down
11 changes: 9 additions & 2 deletions cross-windows.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,21 @@ pkgs.pkgsBuildBuild.mkShell ({

inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;

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

nativeBuildInputs = [ wrapped-ghc wrapped-hsc2hs wrapped-cabal wine-test-wrapper compiler ] ++ (with pkgs; [
Expand Down
13 changes: 11 additions & 2 deletions dynamic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ let tool-version-map = import ./tool-map.nix;
esac
'';
};
quirks = (import ./quirks.nix { inherit pkgs; });
in
pkgs.mkShell {
# The `cabal` overrride in this shell-hook doesn't do much yet. But
# we may need to massage cabal a bit, so we'll leave it in here for
# consistency with the one in static.nix.
shellHook = with pkgs; ''
shellHook =
with pkgs;
let flavor = "${compiler-nix-name}"
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
+ lib.optionalString withIOG "-iog"
+ lib.optionalString withIOGFull "-full"
;
in ''
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
Expand All @@ -59,7 +67,8 @@ pkgs.mkShell {
# incompatbile.
export CABAL_DIR=$HOME/.cabal-devx
echo "CABAL_DIR set to $CABAL_DIR"
''
echo ""
'' + (quirks.hint flavor)
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
# The build will error with -6 due to "loading libcrypto in an unsafe way"
+ lib.optionalString stdenv.hostPlatform.isMacOS
Expand Down
8 changes: 8 additions & 0 deletions quirks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@
function patchProjectLocal() {
cat ${template} >> "$1"
}
echo ""
'';
hint = flavor: ''
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "::notice::Hint: to reproduce this environment locally, use either:" \
"\`nix develop github:input-output-hk/devx#${flavor}\`, or" \
"\`docker run -it -v \$(pwd):/workspaces ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.${flavor}\`"
fi
'';
}
11 changes: 9 additions & 2 deletions static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ pkgs.mkShell (rec {
# the system path.
DYLD_LIBRARY_PATH= with pkgs; "${lib.getLib openssl}/lib";

shellHook = with pkgs; ''
shellHook =
with pkgs;
let flavor = "${compiler-nix-name}-static"
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
+ lib.optionalString withIOG "-iog"
;
in ''
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}";
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
Expand All @@ -97,7 +103,8 @@ pkgs.mkShell (rec {
export CABAL_DIR=$HOME/.cabal-static
echo "CABAL_DIR set to $CABAL_DIR"
echo "DYLD_LIBRARY_PATH set to $DYLD_LIBRARY_PATH"
'' + quirks.shellHook;
echo ""
'' + (quirks.hint flavor) + quirks.shellHook;
# these are _target_ libs, e.g. ones we want to link the build
# product against. These are also the ones that showup in the
# PKG_CONFIG_PATH.
Expand Down

0 comments on commit 6541d98

Please sign in to comment.