cabal2nix icon indicating copy to clipboard operation
cabal2nix copied to clipboard

nix file generated with attribute name containing dots

Open yaitskov opened this issue 1 year ago • 2 comments

Hi,

if cabal contains line:

   extra-libraries:  HSrts-ghc9.4.7

cabal2nix generates following nix:

     error: syntax error, unexpected FLOAT_LIT, expecting '}'
       at /nix/store/3hxh6fwnqhbkgghf77gr3l5ibss5rrki-cabal2nix-foo/default.nix:1:45:
            1| { mkDerivation, base, containers, HSrts-ghc9.4.7, lib, mtl
             |                                             ^

Is it possible to replace dots with underbar or exclude form pattern matching problematic name?

cabal build resolves rts dependency somehow even when nix-shell is called with commented extra-libraries line and uncommented before cabal run.

Current workaround:

cabal:

extra-source-files:  configure
extra-tmp-files:      eval.buildinfo
build-type:              Configure

configure:

#!/bin/sh

while [ $# -ne 0 ]; do
    case $1 in
        --with-compiler=*)
            v=`${1#--with-compiler=} --numeric-version`
            cat > eval.buildinfo <<EOF
extra-libraries: HSrts-ghc$v
EOF
            break
        ;;
        *)
            shift
    esac
done

yaitskov avatar Feb 06 '25 05:02 yaitskov

This is basically https://github.com/NixOS/cabal2nix/issues/164. With extra-libraries we have the advantage that cabal2nix can already rewrite the names via libNixName (e.g. for supc++ from https://github.com/NixOS/cabal2nix/issues/164#issuecomment-2231412441, the correct fix is probably to add a mapping to the nixpkgs package in libNixName).

However, I find it questionable having HSrts-ghc9.4.7 in extra-libraries. You should basically never need to do anything so that GHC links the underlying shared library of the rts.

sternenseemann avatar Feb 06 '25 13:02 sternenseemann

You should basically never need to do anything so that GHC links the underlying shared library of the rts.

I develop a dynamic module for Emacs to interpret embedded Haskell via hint library.

Also I guess cabal2nix miss all dependencies if instead of library keyword foreign-library is used, though these sections share most of the children attributes.

yaitskov avatar Feb 07 '25 04:02 yaitskov