reflex and obelisk question - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Rizary

I have 2 problem when dealing with reflex-platform and obelisk:

  1. when I use reflex-platform.nixpkgs.haskellPackages, it means that I use the ghc865 right? Because I can't see the haskellPackages mentioned anywhere in reflex-platform's default.nix. What I see is only ghc here https://github.com/reflex-frp/reflex-platform/blob/develop/default.nix#L192.

  2. When I put haskell package inside

obelisk.project ./. ({ pkgs, ... }@args:
  let
    inherit (obelisk.reflex-platform) hackGet;

  in {
    staticFiles = pkgs.callPackage ./static { pkgs = obelisk.nixpkgs; };
    # staticFilesImpure = toString ./result-static;
    packages = {
      ........  # My thunk packages
    };

    overrides = pkgs.lib.composeExtensions rhyolite.haskellOverrides (self: super: with pkgs.haskell.lib; {
       ....... # My custom packages
    });
  })

are packages both in packages and overrides become accessible? How do I have haskellPackages contains those packages set?

Reflex FRP is a composable, cross-platform functional reactive programming framework for Haskell. It allows you to build interactive components in pure functional style, working in harmony with es...
Ben Kolera

Packages specifically has some extra magic in it to do with Thunks getting properly handled. Overrides is for your usual dontCheck / jailbreak, callHackage, etc.

Ben Kolera

Ghc and ghcjs are both compilerWithPackages.

Ben Kolera

Like haskell.packages.ghc864.ghcWithPackages(ps: [ps.zlib ps.HsOpenSSL]) but for all the stuff that goes into the build across backend/frontend/common.

Ben Kolera

I believe the packages being different is something to do with making sure they are in the ghcid repl properly when unpacked. But that may be wrong. :slight_smile:

Rizary

Packages specifically has some extra magic in it to do with Thunks getting properly handled. Overrides is for your usual dontCheck / jailbreak, callHackage, etc.

Did package that in the packages will be built using callCabal2nixin the directory that contains .cabal file? Or it will pick the default.nix if it is exists?

For example, the directory structure is:

src-packages
|----> packages
           |------> packages.cabal
           |------> default.nix
           |------> ...

and it seems using hackGet in the packages ignores the default.nix

Ben Kolera

Yeah, it does a callCabal2nix on it iirc.

Ben Kolera

Hackget itself doesn't do that, but something in obelisk does. Hackget is pretty simple and not magical: https://github.com/reflex-frp/reflex-platform/blob/develop/nixpkgs-overlays/hack-get/default.nix

Reflex FRP is a composable, cross-platform functional reactive programming framework for Haskell. It allows you to build interactive components in pure functional style, working in harmony with es...
Rizary

Hackget itself doesn't do that, but something in obelisk does. Hackget is pretty simple and not magical: https://github.com/reflex-frp/reflex-platform/blob/develop/nixpkgs-overlays/hack-get/default.nix

I see. I have seen some of OS project which only using hackGet on all the package that goes into packages attribute like here: https://gitlab.com/obsidian.systems/kiln/blob/develop/tezos-bake-central/default.nix#L42

So the case that I am facing right now is I try to include hasktorch in my obelisk project (without obelisk, it builds fine). But I want to put it in the packages attribute. But, according to this https://github.com/hasktorch/hasktorch/tree/master/libtorch-ffi and this https://github.com/hasktorch/hasktorch/blob/master/nix/shared.nix#L40, I realized that I cannot rely only on hackGet. I already try to modifydefault.nixinside libtorch-ffi, but as I mentioned in my previous chat, when I build the project with nix-build -A ghc.backend, the default.nixwas ignored, and it uses libtorch-ffi.cabal to build the package.

I'm getting anonymus function at ... called without required argument c10. So what is my best option here? Since I still want to put libtorch-ffi in my package.

Tensors and neural networks in Haskell. Contribute to hasktorch/hasktorch development by creating an account on GitHub.
Tensors and neural networks in Haskell. Contribute to hasktorch/hasktorch development by creating an account on GitHub.
Rizary

I just realized that obelisk still uses ghc 8.4?

Rizary

okay, I just realized I use obelisk master branch instead of develop branch. I write here for my self reminder.

Sridhar Ratnakumar

I always use the develop branch.

Sridhar Ratnakumar

And then switch over the skeleton to that of develop's skeleton.

Rizary

And then switch over the skeleton to that of develop's skeleton.

Yeah, that is what I am missing until I see the .obelisk/impl folder in kiln package.

Rizary

Hackget itself doesn't do that, but something in obelisk does. Hackget is pretty simple and not magical: https://github.com/reflex-frp/reflex-platform/blob/develop/nixpkgs-overlays/hack-get/default.nix

I see. I have seen some of OS project which only using hackGet on all the package that goes into packages attribute like here: https://gitlab.com/obsidian.systems/kiln/blob/develop/tezos-bake-central/default.nix#L42

So the case that I am facing right now is I try to include hasktorch in my obelisk project (without obelisk, it builds fine). But I want to put it in the packages attribute. But, according to this https://github.com/hasktorch/hasktorch/tree/master/libtorch-ffi and this https://github.com/hasktorch/hasktorch/blob/master/nix/shared.nix#L40, I realized that I cannot rely only on hackGet. I already try to modifydefault.nixinside libtorch-ffi, but as I mentioned in my previous chat, when I build the project with nix-build -A ghc.backend, the default.nixwas ignored, and it uses libtorch-ffi.cabal to build the package.

I'm getting anonymus function at ... called without required argument c10. So what is my best option here? Since I still want to put libtorch-ffi in my package.

I think I finally able to build this library with obelisk. One thing that I notice (as for my reminder here) is that package and overrides attribute is tied together. what I did is I hackGet hasktorch, and since it fails some test, I put the package in overrides and put dontCheck to avoid the test.

I'm not sure how it works though. I thought that package and overrides will be evaluated together and package mentiond in package attribute can't be override anymore.