2026-04-21 10:53:35 +02:00
|
|
|
{
|
|
|
|
|
# Builds a tiny Haskell executable from a local Cabal package, and
|
|
|
|
|
# provides a matching dev shell for editing and running it.
|
|
|
|
|
description = "A minimal Haskell project with Cabal and flakes";
|
|
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
|
{ self, nixpkgs, ... }:
|
|
|
|
|
let
|
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
|
inherit (pkgs) haskellPackages;
|
|
|
|
|
project = haskellPackages.callCabal2nix "mini-haskell" ./. { };
|
2026-04-21 13:01:03 +02:00
|
|
|
checkedProject = pkgs.haskell.lib.doCheck project;
|
2026-04-21 10:53:35 +02:00
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
packages.${system}.default = project;
|
|
|
|
|
|
|
|
|
|
apps.${system}.default = {
|
|
|
|
|
type = "app";
|
|
|
|
|
program = "${self.packages.${system}.default}/bin/mini-haskell";
|
|
|
|
|
meta.description = "Run the minimal Haskell example.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
|
|
|
packages = [
|
|
|
|
|
haskellPackages.ghc
|
|
|
|
|
pkgs.cabal-install
|
|
|
|
|
pkgs.haskell-language-server
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-21 13:01:03 +02:00
|
|
|
# `doCheck` turns on the Cabal test suite when this derivation is built.
|
|
|
|
|
checks.${system}.test-suite = checkedProject;
|
2026-04-21 10:53:35 +02:00
|
|
|
};
|
|
|
|
|
}
|