Pure Nix flake utility functions for haskell cabal packages
Go to file
2024-02-13 11:29:32 +04:00
examples Add extShellBuildInputs parameter 2023-11-02 19:22:33 +04:00
.gitignore Initial fork of https://github.com/numtide/flake-utils 2021-10-11 21:07:57 +04:00
default.nix New simpleHs2flake 2023-10-28 01:47:05 +04:00
flake.lock Do not call flake-utils.lib.eachSystem for user 2022-02-15 03:33:37 +04:00
flake.nix simpleHs2flake example 2023-10-31 21:41:22 +04:00
LICENSE Adapted for haskell cabal packages 2021-10-11 21:46:46 +04:00
README.md simpleHs2flake example 2023-10-31 21:41:22 +04:00
simpleCabal2flake.nix simple with src 2024-02-13 11:29:32 +04:00
simpleCabalProject2flake.nix default of simpleCabalProject2flake is symlinkJoin of all 2022-12-30 19:02:35 +04:00
simpleHs2flake.nix Add extShellBuildInputs parameter 2023-11-02 19:22:33 +04:00

haskell-flake-utils

STATUS: experimental

Pure Nix flake utility functions for haskell cabal packages.

Usage

simpleCabal2flake -> attrs -> attrs

This function should be useful for most common use-cases where you have a simple flake that builds a haskell cabal package. It takes nixpkgs and a bunch of other parameters and outputs a value that is compatible as a flake output with overlay that overrides haskellPackages and adds current package to it.

Input:

{
  # pass an instance of self
  self
, # pass an instance of the nixpkgs flake
  nixpkgs
, # systems to pass to flake-utils.lib.eachSystem
  systems ? flake-utils.lib.defaultSystems
, # package name
  name
, # nixpkgs config
  config ? { }
, # add another haskell flakes as requirements
  haskellFlakes ? [ ]
, # use this to load other flakes overlays to supplement nixpkgs
  preOverlays ? [ ]
, # pass either a function or a file
  preOverlay ? null
, # override haskell packages
  hpPreOverrides ? ({...}: _: _: { })
, # arguments for callCabal2nix. It could be a function which accepts a set with pkgs.
  cabal2nixArgs ? { }
, # maps to the devShell output. Pass in a shell.nix file or function.
  shell ? null
, # additional build intputs of the default shell. It could be a function which accepts a set with pkgs.
  shellExtBuildInputs ? []
, # wether to build hoogle in the default shell
  shellwithHoogle ? true
, # we can choose compiler from pkgs.haskell.packages
  compiler ? null
, # overlays that will be used to build the package but will not be added to self.overlay
  localOverlays ? []
}: null

Example

flake.nix

Here is how it looks like in practice:

{
description = "Haskell cabal package";

inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    haskell-flake-utils.url = "github:ivanovs-4/haskell-flake-utils";
};

outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs:
    haskell-flake-utils.lib.simpleCabal2flake {
      inherit self nixpkgs;
      systems = [ "x86_64-linux" ];

      name = "cabal-package-name";

    };
}

Nix flake template available:

nix flake init -t github:ivanovs-4/haskell-flake-utils#simple-cabal-flake

This makes the following commands available

nix develop
cabal build
nix develop -c cabal repl
nix develop -c ghcid
nix build
./result/bin/<binary-name>

Also this new flake may be used in haskellFlakes from other such flakes.

simpleHs2flake

Example

flake.nix

Nix flake template available:

nix flake init -t github:ivanovs-4/haskell-flake-utils#simple-hs2flake