How to use Data.Default with Network.HTTP.Client - haskell

The aws package uses an instance of Default Request (in Aws/Core.hs). During the building of the package the compiler complains with the same error as below.
Here is something simple that fails the same way:
{-# LANGUAGE OverloadedStrings #-}
import Data.Default (def)
import Network.HTTP.Client (host)
main :: IO ()
main = do
print $ def { host = "http://foobar.com" }
The compiler complains:
No instance for (Data.Default.Default
http-client-0.3.8.2:Network.HTTP.Client.Types.Request)
arising from a use of `def'
Possible fix:
add an instance declaration for
(Data.Default.Default
http-client-0.3.8.2:Network.HTTP.Client.Types.Request)
But I can see that the instance is defined in http-client/Network/HTTP/Client/Request.hs:
instance Default Request where
def = Request
{ host = "localhost"
, port = 80
, secure = False
...
This is from a "clean" environment:
$ cd
$ rm -Rf .cabal .ghc
$ cabal install cabal cabal-install
$ cabal install http-client-0.3.8.2
How can I use Default with Request? Or better yet how can I build the aws package?
Edit: Output of ghc-pkg
$ ghc-pkg list
/var/lib/ghc/package.conf.d
Cabal-1.16.0
GLURaw-1.3.0.0
GLUT-2.4.0.0
HTTP-4000.2.8
HUnit-1.2.5.2
MonadCatchIO-mtl-0.3.0.5
OpenGL-2.8.0.0
OpenGLRaw-1.3.0.0
QuickCheck-2.6
X11-1.6.1.1
X11-xft-0.3.1
array-0.4.0.1
async-2.0.1.4
attoparsec-0.10.4.0
base-4.6.0.1
bin-package-db-0.0.0.0
binary-0.5.1.1
bytestring-0.10.0.2
case-insensitive-1.1.0.2
cgi-3001.1.8.3
containers-0.5.0.0
data-default-0.5.1
deepseq-1.3.0.1
directory-1.2.0.1
dlist-0.5
extensible-exceptions-0.1.1.4
fgl-5.4.2.4
filepath-1.3.0.1
ghc-7.6.3
ghc-prim-0.3.0.0
hashable-1.2.1.0
haskell-src-1.0.1.5
haskell2010-1.1.1.0
haskell98-2.0.0.2
hoopl-3.9.0.0
hpc-0.6.0.0
html-1.0.1.2
integer-gmp-0.5.0.0
mtl-2.1.2
network-2.4.1.2
old-locale-1.0.0.5
old-time-1.1.0.1
parallel-3.2.0.3
parsec-3.1.3
pretty-1.1.1.0
primitive-0.5.0.1
process-1.1.0.2
random-1.0.1.1
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.2
rts-1.0
split-0.2.2
stm-2.4.2
syb-0.4.0
template-haskell-2.8.0.0
text-0.11.3.1
time-1.4.0.1
transformers-0.3.0.0
unix-2.6.0.1
unordered-containers-0.2.3.0
utf8-string-0.3.7
vector-0.10.0.1
xhtml-3000.2.1
xmonad-0.11
xmonad-contrib-0.11.2
zlib-0.5.4.1
/home/ben/.ghc/i386-linux-7.6.3/package.conf.d
Cabal-1.20.0.2
asn1-encoding-0.8.1.3
asn1-parse-0.8.1
asn1-types-0.2.3
base64-bytestring-1.0.0.1
blaze-builder-0.3.3.4
byteable-0.1.1
cereal-0.4.0.1
cipher-aes-0.2.8
cipher-des-0.0.6
cipher-rc4-0.1.4
conduit-1.2.0.2
connection-0.2.3
cookie-0.4.1.3
cprng-aes-0.5.2
crypto-cipher-types-0.0.9
crypto-numbers-0.2.3
crypto-pubkey-0.2.4
crypto-pubkey-types-0.4.2.2
crypto-random-0.0.8
cryptohash-0.11.6
data-default-class-0.0.1
exceptions-0.6.1
http-client-0.4.0
http-client-tls-0.2.2
http-conduit-2.1.4.3
http-types-0.8.5
lifted-base-0.2.3.0
mime-types-0.1.0.4
mmorph-1.0.4
monad-control-0.3.3.0
nats-0.2
pem-0.2.2
publicsuffixlist-0.1
resourcet-1.1.2.3
securemem-0.1.3
semigroups-0.15.3
socks-0.5.4
streaming-commons-0.1.5
tls-1.2.9
transformers-base-0.4.3
void-0.6.1
x509-1.4.12
x509-store-1.4.4
x509-system-1.4.5
x509-validation-1.5.0

I'm guessing you have two different versions of data-default or data-default-class installed. Request is an instance for one of those classes, but not the other. This is unfortunately a very common problem, you can see a similar answer I provided on Reddit.

This should work:
{-# LANGUAGE OverloadedStrings #-}
-- | Main entry point to the application.
module Main where
import Network.HTTP.Conduit (def,host)
main :: IO ()
main = putStrLn $ show $ def { host = "http://foobar.com" }
I have posted a working code at FP Complete's Haskell IDE. Both the functions def and host are contained within the http-conduit package. It gives the following output:
Request {
host = "http://foobar.com"
port = 80
secure = False
clientCertificates = []
requestHeaders = []
path = "/"
queryString = ""
requestBody = RequestBodyLBS Empty
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = Just (-3425)
}
The thing to note here is that you don't need to use def from
Data.Default. The def has already been defined for the Request
record in http-conduit package and you should use that function.

Related

Trouble running ORC JIT llvm-hs examples

Dear StackOverflow Haskellers:
I tried asking this same question in reddit r/haskell but sadly I got no answers at all. I hope it does better here.
Maybe the answer is that llvm-hs isn't used that much. If you have experience using llvm with haskell, but don't use llvm-hs, I'd love to see how you use it.
I'm trying to run basic llvm-hs ORC JIT functionality, which has taken me to try and run the orc example of llvm-hs-examples. So far I've been unsuccessful in multiple ways (out of the four examples only the first one, basic, runs):
Trying to run examples with the shell.nix in https://github.com/llvm-hs/llvm-hs:
$ git clone https://github.com/llvm-hs/llvm-hs.git
$ git clone https://github.com/llvm-hs/llvm-hs-examples.git
$ cd llvm-hs
$ nix-shell shell.nix
$ cd ../llvm-hs-examples
$ cabal new-build
$ cabal run orc
which produces:
$ cabal run orc
Up to date
; ModuleID = 'basic'
source_filename = "<string>"
define i32 #add() {
entry:
ret i32 42
}
JITSymbolError ""
Eager JIT Result:
()
doing a default.nix a la haskell.nix and running with nix-build
llvm-hs-examples/default.nix:
let
examplesOverlays = [ (self: super: {
llvm-config = self.llvm_9;
}) ];
in
{ # Fetch the latest haskell.nix and import its default.nix
haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/ef6ca0f431fe3830c25cb2d185367245c1cce894.tar.gz") {}
# haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/c88f9eccc975b21ae1e6a6b8057a712b91e374f2.tar.gz") {}
# haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {}
# haskell.nix provides access to the nixpkgs pins which are used by our CI,
# hence you will be more likely to get cache hits when using these.
# But you can also just use your own, e.g. '<nixpkgs>'.
, nixpkgsSrc ? haskellNix.sources.nixpkgs-2003
# haskell.nix provides some arguments to be passed to nixpkgs, including some
# patches and also the haskell.nix functionality itself as an overlay.
, nixpkgsArgs ? haskellNix.nixpkgsArgs
# import nixpkgs with overlays
, pkgs ? (import nixpkgsSrc (nixpkgsArgs // { overlays = nixpkgsArgs.overlays ++ examplesOverlays;}))
# , pkgs ? import nixpkgsSrc nixpkgsArgs
}: pkgs.haskell-nix.project {
# 'cleanGit' cleans a source directory based on the files known by git
src = pkgs.haskell-nix.haskellLib.cleanGit {
name = "examples";
src = ./.;
};
# For `cabal.project` based projects specify the GHC version to use.
# compiler-nix-name = "ghc884"; # Not used for `stack.yaml` based projects.
}
in llvm-hs-examples's directory ran:
$ nix-build -A examples.components.exes.orc
$ ./result/bin/orc
; ModuleID = 'basic'
source_filename = "<string>"
define i32 #add() {
entry:
ret i32 42
}
JITSymbolError ""
Eager JIT Result:
()
which is the same output as before.
I believe the last (2) approach uses stack to build, but also tried manually with stack:
a) first failed approach:
In a nix-shell with llvm-config (I used the one in llvm-hs and the one I created with haskell.nix, but same result):
$ llvm-config --version
9.0.1
$ stack build examples:orc
No packages found in snapshot which provide a "llvm-config" executable, which is a build-tool dependency of llvm-hs
llvm-hs > configure
llvm-hs > [1 of 2] Compiling Main ( /run/user/1000/stack-2e6b46f4d38b8260/llvm-hs-9.0.1/Setup.hs, /run/user/1000/stack-2e6b46f4d38b8260/llvm-hs-9.0.1/.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup/Main.o )
llvm-hs > [2 of 2] Compiling StackSetupShim ( /home/hhefesto/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /run/user/1000/stack-2e6b46f4d38b8260/llvm-hs-9.0.1/.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup/StackSetupShim.o )
llvm-hs > Linking /run/user/1000/stack-2e6b46f4d38b8260/llvm-hs-9.0.1/.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup/setup ...
llvm-hs > setup: The program 'llvm-config' version ==9.0.* is required but it could not
llvm-hs > be found.
llvm-hs >
b) build-successful stack approach I also tried with stack's nix integration explicitly specifying llvm-config as part of buildInputs:
stack.yaml
# resolver: nightly-2020-01-30
resolver: lts-14.0
packages:
- '.'
extra-deps:
- llvm-hs-9.0.1
- llvm-hs-pure-9.0.0
- llvm-hs-pretty-0.9.0.0
flags:
llvm-hs:
shared-llvm: true
nix:
enable: true
shell-file: stackShell.nix
stackShell.nix:
let
examplesOverlays = [ (self: super: {
llvm-config = self.llvm_9;
}) ];
in
{ haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/ef6ca0f431fe3830c25cb2d185367245c1cce894.tar.gz") {}
, nixpkgsSrc ? haskellNix.sources.nixpkgs-2003
, nixpkgsArgs ? haskellNix.nixpkgsArgs
, pkgs ? (import nixpkgsSrc (nixpkgsArgs // { overlays = nixpkgsArgs.overlays ++ examplesOverlays;}))
}:
with pkgs;
haskell.lib.buildStackProject {
name = "llvm-hs";
buildInputs = [ llvm-config
];
inherit ghc;
}
Which was able to build successfully, but same error:
$ stack build examples:orc ghc-shell-for-examples
examples> configure (exe)
Configuring examples-1.0.0.0...
examples> build (exe)
Preprocessing executable 'orc' for examples-1.0.0.0..
Building executable 'orc' for examples-1.0.0.0..
examples> copy/register
Installing executable orc in /home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin
Installing executable basic in /home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin
Installing executable arith in /home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin
Installing executable irbuilder in /home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin
$ /home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin/orc ghc-shell-for-examples
; ModuleID = 'basic'
source_filename = "<string>"
define i32 #add() {
entry:
ret i32 42
}
JITSymbolError ""
Eager JIT Result:
()
A weird thing worth noting is that stack was unable to find what it had just built with stack exec examples:orc:
$ stack exec examples:orc
Executable named examples:orc not found on path: ["/home/hhefesto/src/llvm-hs-examples/.stack-work/install/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin","/home/hhefesto/.stack/snapshots/x86_64-linux-nix/2bab12248a943811dbc5aa23a88b887ce7aef1939551d21b69d96e3f64bfcbd7/8.6.5/bin","/home/hhefesto/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin","/nix/store/9wvsbqr57k9n6d8vv6b10d04j51f9ims-ghc-8.6.5/bin","/nix/store/4xb9z8vvk3fk2ciwqh53hzp72d0hx1da-bash-interactive-4.4-p23/bin","/nix/store/9wvsbqr57k9n6d8vv6b10d04j51f9ims-ghc-8.6.5/bin","/nix/store/m6h7zh8w6s52clnyskffj5lbkakqgywn-gcc-wrapper-9.2.0/bin","/nix/store/b3zsk4ihlpiimv3vff86bb5bxghgdzb9-gcc-9.2.0/bin","/nix/store/0k65d30z9xsixil10yw3bwajbdk4yskv-glibc-2.30-bin/bin","/nix/store/x0jla3hpxrwz76hy9yckg1iyc9hns81k-coreutils-8.31/bin","/nix/store/n48b8n251dwwb04q7f3fwxdmirsakllz-binutils-wrapper-2.31.1/bin","/nix/store/hrkc2sf2883l16d5yq3zg0y339kfw4xv-binutils-2.31.1/bin","/nix/store/0k65d30z9xsixil10yw3bwajbdk4yskv-glibc-2.30-bin/bin","/nix/store/x0jla3hpxrwz76hy9yckg1iyc9hns81k-coreutils-8.31/bin","/nix/store/6dacwd7ldb2jazc218d11v2w2g55hba8-pkg-config-0.29.2/bin","/nix/store/lb61dshvvqy1rgjhhlzaiiv2fv157lr5-stack-2.1.3.1/bin","/nix/store/71n1xcigc00w3z7yc836jqcx9cb2dys8-patchelf-0.9/bin","/nix/store/xhhkr936b9q5sz88jp4l29wljbbcg39k-ncurses-6.1-20190112/bin","/nix/store/khqyxflp8wbq038wdyv5sr8sjsfwlr72-llvm-9.0.1/bin","/nix/store/84g84bg47xxg01ba3nv0h418v5v3969n-ncurses-6.1-20190112-dev/bin","/nix/store/xhhkr936b9q5sz88jp4l29wljbbcg39k-ncurses-6.1-20190112/bin","/nix/store/x0jla3hpxrwz76hy9yckg1iyc9hns81k-coreutils-8.31/bin","/nix/store/97vambzyvpvrd9wgrrw7i7svi0s8vny5-findutils-4.7.0/bin","/nix/store/dqq1bvpi3g0h4v05111b3i0ymqj4v5x1-diffutils-3.7/bin","/nix/store/p34p7ysy84579lndk7rbrz6zsfr03y71-gnused-4.8/bin","/nix/store/b0vjq4r4sp9z4l2gbkc5dyyw5qfgyi3r-gnugrep-3.4/bin","/nix/store/c8balm59sxfkw9ik1fqbkadsvjqhmbx4-gawk-5.0.1/bin","/nix/store/g7dr83wnkx4gxa5ykcljc5jg04416z60-gnutar-1.32/bin","/nix/store/kkvgr3avpp7yd5hzmc4syh43jqj03sgb-gzip-1.10/bin","/nix/store/rw96psqzgyqrcd12qr6ivk9yiskjm3ab-bzip2-1.0.6.0.1-bin/bin","/nix/store/dp6y0n9cba79wwc54n1brg7xbjsq5hka-gnumake-4.2.1/bin","/nix/store/hrpvwkjz04s9i4nmli843hyw9z4pwhww-bash-4.4-p23/bin","/nix/store/xac1zfclx1xxgcd84vqb6hy3apl171n8-patch-2.7.6/bin","/nix/store/mm0w8jc58rn01c4kz2n9jvwd6bibcihs-xz-5.2.4-bin/bin"]
Other things worth noting: I tried everything stack related with two resolvers: lts-14.0 which was already there and nightly-2020-01-30 which was recently added in a commit to llvm-hs, but same result.
Also tried changing llvm-hs version restrictions to include the latest 9.0.1 in llvm-hs-examples' cabal file, but same result.
I'm on NixOS channel 20.03
If you want me to share or try something else, please let me know, and thank you for your help.
Lastly, thank you very much for your time!

Nix GLFW Haskell bindings missing library?

I'm trying to compile a Haskell program (https://hackage.haskell.org/package/gloss-export)
However I'm running into the following error:
<command line>: can't load .so/.DLL for: /nix/store/f2730k4icw6biaaw3k81x853sch2ig8k-bindings-GLFW-3.2.1.1/lib/ghc-8.6.5/x86_64-linux-ghc-8.6.5/libHSbindings-GLFW-3.2.1.1-HsSdzRmGNYCJBRDKgdT43y-ghc8.6.5.so (/nix/store/wx1vk75bpdr65g6xwxbj4rw0pk04v5j3-glibc-2.27/lib/libm.so.6: version `GLIBC_2.29' not found (required by /nix/store/f2730k4icw6biaaw3k81x853sch2ig8k-bindings-GLFW-3.2.1.1/lib/ghc-8.6.5/x86_64-linux-ghc-8.6.5/libHSbindings-GLFW-3.2.1.1-HsSdzRmGNYCJBRDKgdT43y-ghc8.6.5.so))
cabal: repl failed for exe:xmonad from my-xmonad-0.2.0.0.
How could I resolve this dependency?
What I've tried:
Adding the bindings-GLFW haskell package but this did not make any
difference.
Adding the glibc package via the following:
#(myHaskellPackages.callCabal2nix "HaskellNixCabalStarter" (./.) {}).overrideAttrs (oldAttrs: {
#buildInputs = (oldAttrs.buildInputs or []) ++ [ pkgs.glibc ];
#})
This seems to give me another error of:
nix build
builder for '/nix/store/kp5m6kfwjfr4w59ypcnqqqn9812q6vpy-my-xmonad-0.2.0.0.drv'
failed with exit code 1; last 10 log lines:
/nix/store/gwwycf3w6cbj0gd2mpgblrdjc24f3cys-binutils-wrapper-2.31.1/bin/ld.gold
No pkg-config found Using runghc version 8.6.5 found on system at:
/nix/store/hg3na12737n7wws1kndxvs95ai88fgn8-ghc-8.6.5/bin/runghc
Using strip version 2.31 found on system at:
/nix/store/ajrrkivdfvp8dp4vdg5hp1h5hblmanc9-binutils-2.31.1/bin/strip
Using tar found on system at:
/nix/store/aawf0q16ql39w2gwv52qyjfzgbg5f22r-gnutar-1.32/bin/tar No
uhc found
*** abort because of serious configure-time warning from Cabal [1 built (1 failed), 0.0 MiB DL] error: build of
'/nix/store/kp5m6kfwjfr4w59ypcnqqqn9812q6vpy-my-xmonad-0.2.0.0.drv'
failed ```
My entire nix expression:
{
nixpkgs ? import <nixpkgs> {}
, compiler ? "ghc865"
, sources ? import ./nix/sources.nix
} :
let
niv = import sources.nixpkgs {
overlays = [
(_ : _ : { niv = import sources.niv {}; })
] ;
config = {};
};
pkgs = niv.pkgs;
myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
overrides = self: super: rec {
gloss-export = pkgs.haskell.lib.dontCheck (import /home/chris/NewProjects/gloss-export/default.nix {});
};
};
in
(myHaskellPackages.callCabal2nix "HaskellNixCabalStarter" (./.) {}).overrideAttrs (oldAttrs: {
buildInputs = (oldAttrs.buildInputs or []) ++ [ pkgs.glibc ];
})

How do I figure out which version of Cabal library ends up in my GHC packages inside a nix shell?

I have a problem which boils down to this simplified example. Say I have the following shell.nix file:
let
base = import <nixpkgs> {};
pinnedVersion = base.pkgs.lib.importJSON ./nixpkgs.json;
nixpkgs = base.pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
inherit (pinnedVersion) rev sha256;
};
pkgs = import nixpkgs { };
p = ({ mkDerivation, base }:
mkDerivation {
pname = "foo";
version = "0.0.0.1";
src = ./.;
isLibrary = true;
license = "GPL";
isExecutable = true;
libraryHaskellDepends = [ base ];
libraryToolDepends = [ ];
executableHaskellDepends = [ base ];
testHaskellDepends = [ base ];
});
in
pkgs.haskellPackages.callPackage p {}
this is just a dummy derivation. I fire off 'nix-shell' and inside the shell:
$ ghc-pkg list
/nix/store/f520j7wfgp9h2mmq6rk36r6vgsb279sf-ghc-8.8.3/lib/ghc-8.8.3/package.conf.d
Cabal-3.0.1.0
...
So version 3.0.1.0 of the Cabal library is in the ghc package set.. ok but the thing is, the version of Nixpkgs I am using above (i.e. the one pinned in the following JSON) ...
{
"url": "https://github.com/nixos/nixpkgs.git",
"rev": "6cf0ed0c04fb3aa7f81b46d0c90bae6457964b3f",
"date": "2020-07-02T07:24:47+02:00",
"path": "/nix/store/gkilcm4l6qsp31lapirjxd1mn1dnn100-nixpkgs",
"sha256": "0sp8108j70f3kz3r8hagiyq21sjwr46n0dqg16gb27k7761bcvpg",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}
... only has Cabal library versions 3.2.0.0, 2.4.1.0 and 2.2.0.1 available. See below:
$ nix repl
Welcome to Nix version 2.3.1. Type :? for help.
nix-repl> base = import <nixpkgs> {}
nix-repl> pinnedVersion = base.pkgs.lib.importJSON ./nixpkgs.json
nix-repl> nixpkgs = base.pkgs.fetchFromGitHub { owner = "NixOS"; repo = "nixpkgs"; inherit (pinnedVersion) rev sha256; }
nix-repl> pkgs=import nixpkgs { }
nix-repl> pkgs.haskellPackages.Cabal *<tab> <tab>*
pkgs.haskellPackages.Cabal pkgs.haskellPackages.Cabal_2_4_1_0
pkgs.haskellPackages.Cabal-ide-backend pkgs.haskellPackages.Cabal_3_2_0_0
pkgs.haskellPackages.CabalSearch
pkgs.haskellPackages.Cabal_2_2_0_1
nix-repl> pkgs.haskellPackages.Cabal
pkgs.haskellPackages.Cabal pkgs.haskellPackages.Cabal_2_4_1_0
pkgs.haskellPackages.Cabal-ide-backend pkgs.haskellPackages.Cabal_3_2_0_0
pkgs.haskellPackages.CabalSearch
pkgs.haskellPackages.Cabal_2_2_0_1
nix-repl> pkgs.haskell.packages.ghc883.Cabal *<tab> <tab>*
pkgs.haskell.packages.ghc883.Cabal
pkgs.haskell.packages.ghc883.Cabal-ide-backend
pkgs.haskell.packages.ghc883.CabalSearch
pkgs.haskell.packages.ghc883.Cabal_2_2_0_1
pkgs.haskell.packages.ghc883.Cabal_2_4_1_0
pkgs.haskell.packages.ghc883.Cabal_3_2_0_0
So this is getting pulled into my nix-shell environment "somehow" and I think I am simply hitting the limit of my understanding on how Haskell nix packages are put together and in particular the GHC package set etc. Can someone shed some light into the apparently missing gap? Thanks!
EDIT: I am not sure if the question is actually clear.. the actual question is: why is there a Cabal_3_0_1_0 library in my GHC packages when everything in this Nixpkgs version suggests it should have a Cabal_3_2_0_0 and furthermore, how can I override this? Thanks!

nix-env and nix-shell have different versions of snap

I was following directions on reflex-platfrom project development,trying to test servant-reflex as a submodule.
My project is here.
In my backend.cabal, I have a built-depend:
snap >= 1.1.1.0 && < 1.2
When I nix-shell -A shells.ghc --run "cabal new-build all", it tries to install heist-1.0.1.0 and snap-1.0.0.2, then failed at
Configuring heist-1.0.1.0...
Setup: Encountered missing dependencies:
aeson >=0.6 && <1.2
To see what in my nixos-unstable, I:
`nix-channel --list`
nixos https://nixos.org/channels/nixos-unstable
`nix-env -f "<nixpkgs>" -qaP -A haskellPackages.aeson`
warning: Nix search path entry '/home/demo/.nix-defexpr/channels' does not exist, ignoring
haskellPackages.aeson aeson-1.2.4.0
`nix-env -f "<nixpkgs>" -qaP -A haskellPackages.snap`
warning: Nix search path entry '/home/demo/.nix-defexpr/channels' does not exist, ignoring
haskellPackages.snap snap-1.1.0.0
`nix-env -f "<nixpkgs>" -qaP -A haskellPackages.heist`
warning: Nix search path entry '/home/demo/.nix-defexpr/channels' does not exist, ignoring
haskellPackages.heist heist-1.0.1.2
Q: Why does nix-shell install heist-1.0.1.0 and snap-1.0.0.2, instead of heist-1.0.1.2 and snap-1.1.0.0, which then can dependent on aeson-1.2.4.0?
Got an answer from elvishjerricco on IRC #nixos.
To doJailbreak heist, you'd use the overrides argument to
project
packages is for just declaring directories that you want to turn
into haskell packages; it'll run cabal2nix for you. overrides is for
doing derivation changes to the haskell package set.
default.nix
(import ./reflex-platform {}).project ({ pkgs, ... }: {
overrides = self: super: {
heist = pkgs.haskell.lib.doJailbreak super.heist;
map-syntax = pkgs.haskell.lib.doJailbreak super.map-syntax;
};
packages = {
common = ./common;
backend = ./backend;
frontend = ./frontend;
google-maps-reflex = ./google-maps-reflex;
};
shells = {
ghc = ["common" "backend" "frontend" "heist"]; # "backend" "frontend"];
ghcjs = ["common" "frontend"];
};
})

Creating a sandbox to build a package that has a dependency for libxcb

I am trying to build https://github.com/SaschaWillems/Vulkan. I wrote a small default.nix file:
{ stdenv, libxcb, pkgconfig, cmake, vulkan-loader, assimp }:
stdenv.mkDerivation rec {
name = "VulkanExamples";
buildDepends = [ cmake libxcb.dev pkgconfig vulkan-loader assimp ];
}
which I call with
nix-shell -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'
But when I call cmake . I get
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find xcb (missing: XCB_INCLUDE_DIR XCB_LIBRARY
What do I need to specify so that the cmake script can find the correct header files?
I finally got it working, it seems I had to use buildInputs
{ stdenv, libxcb, pkgconfig, cmake, vulkan-loader, assimp }:
with import <nixpkgs> {}; {
vulkanEnv = stdenv.mkDerivation {
name = "vulkan";
buildInputs = [ stdenv cmake libxcb pkgconfig vulkan-loader assimp ];
};
}

Resources