Skip to content

How to use this pattern for project with libraries, but without executables? #368

Description

@ArtemChandragupta

Hi. There is a project waterfall-cad, it consists of two libraries - main library waterfall-cad (adds functional language in Haskell for 3d modelling) and it's dependency - opencascade-hs (adds Haskell bindings to opencascade-hs). The last is broken in nixpkgs, so my friend created a fork fixing the issue.

I tried to build it using a pattern described here, using "hello world" placeholder executable which "depends" on opencascade-hs and waterfall-cad:

Details

flake.nix:

{

inputs = {
  nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  flake-parts.url = "github:hercules-ci/flake-parts";
  haskell-flake.url = "github:srid/haskell-flake";
  opencascade-hs-fork = {
    url = "github:KovalevDima/opencascade-hs";
    flake = false;
  };
};

outputs=inputs@{self,nixpkgs,flake-parts,...}:flake-parts.lib.mkFlake{inherit inputs;}{
  systems = nixpkgs.lib.systems.flakeExposed;
  imports = [ inputs.haskell-flake.flakeModule ];

  perSystem = { self', pkgs, ... }: {
    haskellProjects.default = {
      packages = {
        opencascade-hs.source = inputs.opencascade-hs-fork + /opencascade-hs;
      };
    };
    packages.default = self'.packages.example;
  };
};

}

example.cabal:

cabal-version:   3.0
name:            example
version:         0.1.0.0
license:         NONE
author:          Joe
maintainer:      joe@example.com
build-type:      Simple

common warnings
    ghc-options: -Wall

executable example
    import:           warnings
    main-is:          Main.hs
    build-depends:
        base,
        opencascade-hs,
        waterfall-cad
    hs-source-dirs:   src
    default-language: Haskell2010

src/Main.hs:

module Main where

main :: IO ()
main = putStrLn "Hello, Haskell!"

It builds up, but have two problems:

  1. There is useless executable
  2. Haskell don't know about the libraries (modules does not exported?)
    2024-10-26-221538-window

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions