Skip to content

haskellPackages.mkDerivation: passthru attributes for executables, testExecutables and benchExecutables #315129

@mrcjkb

Description

@mrcjkb

Hey 👋

I've recently migrated a project from haskell.nix to nixpkgs/cabal2nix.
One thing I found quite useful in haskell.nix was the ability to directly reference executables, test executables and benchmark executables, e.g.:

Cabal:

executable my-package-foo
  main-is: MyPackageFoo.hs

executable my-package-bar
  main-is: MyPackageBar.hs
my-package-foo = my-package.exes.my-package-foo
my-package-bar = my-package.exes.my-package-bar

I had a look at fromPackageDescription, as well as the Pretty instance of Derivation,
and I think it wouldn't be too hard to generate something like this:

mkDerivation {
  # ...
  passthru = {
    executables = {
      my-package-foo = haskell.lib.compose.setBuildTarget "my-package-foo" my-package;
      my-package-bar = haskell.lib.compose.setBuildTarget "my-package-foo" my-package;
    };
    testExecutables = {
      my-package-foo-spec = haskell.lib.compose.setBuildTarget "my-package-foo-spec" my-package;
      my-package-bar-integration = haskell.lib.compose.setBuildTarget "my-package-bar-intergration" my-package;
    };
    benchExecutables = # ...
  };
}

What do you think?
Am I missing something? Would you consider this a useful feature?

An obvious downside would be the need for my-package to be passed in via callPackage.
This could be mitigated by providing executable names instead of derivations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancementAdd something new or improve an existing system.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: haskellGeneral-purpose, statically typed, purely functional programming language

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions