tk2mqtt/flake.nix

82 lines
2.2 KiB
Nix

{
description = "Tankerkönig-to-MQTT gateway";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
ghcv = "ghc96";
pkgs = nixpkgs.legacyPackages.${system};
overlay = final: prev: {
tk2mqtt = final.callCabal2nix "tk2mqtt" ./. { };
};
haskellPackages = pkgs.haskell.packages.${ghcv}.extend overlay;
in
{
packages.default = haskellPackages.tk2mqtt;
apps = {
# run with: nix run #.tk2mqtt
tk2mqtt = {
type = "app";
program = "${self.packages.${system}.default}/bin/tk2mqtt";
};
# run with: nix run
default = self.apps.${system}.tk2mqtt;
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
hpack.enable = true;
hlint.enable = true;
ormolu = {
enable = true;
settings.defaultExtensions = [ "GHC2021" ];
};
doctest = {
enable = false;
name = "Run documentation tests";
entry = "${haskellPackages.doctest}/bin/doctest src app";
files = "\\.l?hs$";
pass_filenames = false;
};
};
};
};
devShells.default = haskellPackages.shellFor {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = p: [ p.tk2mqtt ];
withHoogle = true;
nativeBuildInputs = with pkgs; [
haskellPackages.haskell-language-server
# haskellPackages.fourmolu
haskellPackages.hspec-discover
haskellPackages.doctest
cabal-install
ghcid
nixfmt-rfc-style
hpack
hlint
yaml-language-server
];
};
});
}