-
Notifications
You must be signed in to change notification settings - Fork 710
feature request: Nix Integration support for flake.nix
#9046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! Cabal's nix integration is for see issues labelled nix integration |
Correct. And v1 is deprecated. I think spending energy on improving v1-only features it's not the best... Also, I don't remember seeing many project that have flake.nix but no default.nix |
xmonad does, for what little that's worth. Flakes are, as I understand it, still a new feature. |
no
no --enable-nix just runs commands through a nix shell, nothing more. As written by others it isn't supported by v2- commands, and I think there are better ways to do that anyway, such as direnv and similar tools, or hooks (#7394) I have plans for a deeper nix integration but that's still in my head |
@peterbecich Your questions sound like you're looking for how to have Nix provide the environment for Cabal; if I'm understanding that correctly, I've written up a basic example on that. https://gist.github.com/ScottFreeCode/9b0ea3e52fa56c93ea8ca14791e55bb4 (You'll probably want the "one package" variant and ignore the "monorepo" and "+preprocessing" versions unless and until you need them, and I expect you'll know if/when that is.) @fgaz I'd be curious how that compares to your ideas about Nix integration; it turns out that the crux of it is a simple use of the Anyway now that I've got these examples up I should go share it around to various issues that it's relevant to (the bugs that affect it, issues where people are looking for a way to use Haskell in Nix with Nix providing the environment but without changing how they use Haskell, etc.). I just saw this issue when I was checking that nobody had already filed another bug I needed to file, and figured I'd drop in and offer the suggestion in answer to the questions. |
Thanks everybody, apologies for my late response. @ScottFreeCode , thank you. I am not sure https://gist.github.com/ScottFreeCode/87bec0c569598014053579990a5bef6e is what I'm attempting to describe. Your gist here "Cabal v2 Build inside Nix Shell does not see executables such as Alex, Happy (BNFC?)" is part of what I'm attempting to describe: https://gist.github.com/ScottFreeCode/ef9f254e2dd91544bba4a068852fc81f Inside a To my knowledge, the only way to accomplish this today is by Right now a.f.a.i.k. most Haskell projects with a
and there is no link between the inputs of these two. Regarding Cabal |
@peterbecich Both cabal v1-build and cabal v2-build use Nix-provided packages. It's only Nix-provided executables that don't work in v2-build. Triple-checked this, details below. (Caveat: I don't know for certain about Phase OneFirst, to make sure I have a package that is not provided with GHC. We'll test this with a script, no Sanity Check with a GHC-provided packageFor example, this script saved as #! /usr/bin/env nix-shell
#! nix-shell -i runhaskell --packages ghc
module Main where
import System.Process (callProcess)
main = callProcess "pwd" [] Sanity Check that if Nix provides the additional package, it worksThis one also works (saved as #! /usr/bin/env nix-shell
#! nix-shell -i runhaskell --packages "haskellPackages.ghcWithPackages (ps: [ps.shh])"
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Shh
loadExe SearchPath "pwd"
main = pwd But if we use that package without Nix providing it, it does not workThis one, which does not specify the package #! /usr/bin/env nix-shell
#! nix-shell -i runhaskell --packages ghc
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Shh
loadExe SearchPath "pwd"
main = pwd It gives me this error: shh.notincluded.hs:7:1: error:
Could not find module `Shh'
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
7 | import Shh
| ^^^^^^^^^^ Phase TwoNow we have a package that will only compile if something provides it, and we have a Main module that uses that package.
Both
I don't see any evidence that It should build and run OK, however. It appears that both Alternative Phase OneInstead of saving all those scripts, you could instead do a version of Phase Two but skipping step 2 (don't modify the .cabal file) to see that it fails to build if What about flakes and
|
Currently
https://cabal.readthedocs.io/en/stable/nix-integration.html#nix-integration
flake.nix
can do everything thatshell.nix
anddefault.nix
can do, as I understand it. Some projects only haveflake.nix
.Can we support Nix Flake Integration in Cabal?
Question:
default.nix
is present, will Cabal pull Haskell library dependencies from the Nix project?or
openssl
orlibjpeg
?or
If Cabal's Nix Integration is intended to provide system dependencies, not Haskell library dependencies, I think Nix Flake Integration is unnecessary. The reason is, working in a
nix develop
shell provided byflake.nix
, Cabal will already have access to the system dependencies provided byflake.nix
.The text was updated successfully, but these errors were encountered: