devx/quirks.nix
Yvan Sraka db7ea17fbb
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
2024-04-04 10:46:24 +00:00

31 lines
1.0 KiB
Nix

{ pkgs, static ? false }: rec {
CABAL_PROJECT_LOCAL_TEMPLATE = with pkgs; ''
package digest
${if static then "extra-lib-dirs: ${zlib}/lib ${pcre}/lib" else ""}
constraints:
HsOpenSSL +use-pkg-config,
zlib +pkg-config,
pcre-lite +pkg-config
'';
template = pkgs.writeTextFile {
name = "cabal.project.local";
text = CABAL_PROJECT_LOCAL_TEMPLATE;
};
shellHook = ''
echo "Quirks:"
echo -e "\tif you have the zlib, HsOpenSSL, or digest package in your dependency tree, please make sure to"
echo -e "\tcat ${template} >> cabal.project.local"
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
'';
}