2026-04-21 10:53:35 +02:00

47 lines
1.3 KiB
Nix

{
# 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" ./. { };
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
];
};
checks.${system}.greeting = pkgs.runCommand "mini-haskell-greeting" { } ''
output="$(${self.packages.${system}.default}/bin/mini-haskell flakes)"
if [ "$output" = "hello, flakes, from Haskell and Nix" ]; then
echo ok > "$out"
else
echo "unexpected output: $output" >&2
exit 1
fi
'';
};
}