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
  • Loading branch information
yvan-sraka committed Apr 3, 2024
1 parent e489b1b commit 6ab8463
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
9 changes: 7 additions & 2 deletions cross-js.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ pkgs.mkShell ({

inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;

shellHook = with pkgs; ''
shellHook =
let flavor = ''${compiler-nix-name}-js${
(if !withHLS && !withHlint then "-minimal" else "") +
(if withIOG then "-iog" else "")
}''; in with pkgs; ''
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
9 changes: 7 additions & 2 deletions cross-windows.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,19 @@ pkgs.pkgsBuildBuild.mkShell ({

inherit (quirks) CABAL_PROJECT_LOCAL_TEMPLATE;

shellHook = with pkgs; ''
shellHook =
let flavor = ''${compiler-nix-name}-windows${
(if !withHLS && !withHlint then "-minimal" else "") +
(if withIOG then "-iog" else "")
}''; in with pkgs; ''
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
10 changes: 8 additions & 2 deletions dynamic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ 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 =
let flavor = ''${compiler-nix-name}${
(if !withHLS && !withHlint then "-minimal" else "") +
(if withIOG then "-iog" else "")
}''; in with pkgs; ''
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 +64,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
9 changes: 9 additions & 0 deletions quirks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,14 @@
function patchProjectLocal() {
cat ${template} >> "$1"
}
echo ""
'';
hint = flavor: ''
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "Hint: to reproduce this environment locally, use either:"
echo "$ nix develop github:input-output-hk/devx#${flavor}"
echo "$ docker run -it -v \$(pwd):/workspaces ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.${flavor}"
echo ""
fi
'';
}
9 changes: 7 additions & 2 deletions static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ pkgs.mkShell (rec {
# the system path.
DYLD_LIBRARY_PATH= with pkgs; "${lib.getLib openssl}/lib";

shellHook = with pkgs; ''
shellHook =
let flavor = ''${compiler-nix-name}-static${
(if !withHLS && !withHlint then "-minimal" else "") +
(if withIOG then "-iog" else "")
}''; in with pkgs; ''
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 @@ -96,7 +100,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 6ab8463

Please sign in to comment.