input-output-hk / devx

The Developer Experience Shell - This repo contains a nix develop shell for haskell. Its primary purpose is to help get a development shell for haskell quickly and across multiple operating systems (and architectures).
Apache License 2.0
37 stars 9 forks source link

Expose `CABAL_PROJECT_LOCAL_TEMPLATE` as a `/nix/store/` file #97

Closed yvan-sraka closed 10 months ago

yvan-sraka commented 10 months ago
% nix develop ".#ghc962-static-minimal"

 _____ _____ _____    _____         _       _ _    _____ _       _ _ 
|     |     |   __|  |  |  |___ ___| |_ ___| | |  |   __| |_ ___| | |
|-   -|  |  |  |  |  |     | .'|_ -| '_| -_| | |  |__   |   | -_| | |
|_____|_____|_____|  |__|__|__,|___|_,_|___|_|_|  |_____|_|_|___|_|_|

             _        _   _             _ _ _   _                   
_/\____   __| |_ __ _| |_(_)__   ___ __| (_) |_(_)___ _ _    ____/\_
>  <___| (_-<  _/ _` |  _| / _| / -_) _` | |  _| / _ \ ' \  |___>  <
 \/|___| /__/\__\__,_|\__|_\__| \___\__,_|_|\__|_\___/_||_| |___|\/ 

Revision (input-output-hk/devx): 9fb95ac431622597fb663d5c00525bb42845bc51.
NOTE (macos): you can use fixup-nix-deps FILE, to fix iconv, ffi, and zlib dependencies that point to the /nix/store
CABAL_DIR set to /Users/yvan/.cabal-static
DYLD_LIBRARY_PATH set to /nix/store/jc495w1m1z7ph6hhad875kj66q3mggr1-openssl-3.0.8/lib
Quirks:
        if you have the zlib, HsOpenSSL, or digest package in your dependency tree, please make sure to
        cat /nix/store/4yrk2l4kp94xyh8mb9hsa9mx84sgifmy-cabal.project.local >> cabal.project.local
[~/IOHK/devx]$ cat /nix/store/4yrk2l4kp94xyh8mb9hsa9mx84sgifmy-cabal.project.local
package digest
  extra-lib-dirs: /nix/store/7n13ddp1m3340ls4x3zx9qkjhqidi08x-zlib-1.2.13/lib /nix/store/zb8jg7p56k0071svhqa3hqgl40d1h93m-pcre-8.45-bin/lib
constraints:
  HsOpenSSL +use-pkg-config,
  zlib +pkg-config,
  pcre-lite +pkg-config
yvan-sraka commented 10 months ago

@KtorZ is that PR a correct fix for your issue?

KtorZ commented 10 months ago

@yvan-sraka that sounds slightly better indeed, but still sub-optimal if I can say as we still only know about the location of that file after entering the shell. And there's not much scripting possible from it.

What could be nice would be to be able to build that file as a standalone derivation? So that we can pre-build the cabal.project.local prior to entering the nix shell.

angerman commented 10 months ago

So if this was instead a function that was exposed

function patchProjectLocal() {
  cat /nix/store/... >> "$1"
}

Would that do?

exposing it outside of the DevX shell might be a bit tricky as that's our single entry point for GH Actions.

We could probably expose it as separate attributes in the flake though if someone wanted to

nix build .#ghc810-iog-cabalProjectLocal

or something?

KtorZ commented 10 months ago

I like the idea of a separate attribute more than the function.

angerman commented 10 months ago

I like the idea of a separate attribute more than the function.

It could be both, but you wouldn't be able to use the separate attribute from the devx GitHub actions.

yvan-sraka commented 10 months ago

I updated the PR, now you have e.g. nix build ".#cabalProjectLocal.static" :)