]> Git — Sourcephile - webc.git/blob - flake.nix
7af77bbce55a16b1b9f6517f4046abe9e1439c69
[webc.git] / flake.nix
1 {
2 inputs = {
3 nixpkgs.url = "flake:nixpkgs";
4 pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
5 pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
6 #symantic-base.url = "git+https://git.code.sourcephile.fr/~julm/symantic-base?ref=main";
7 symantic-base.url = "git://git.sourcephile.fr/haskell/symantic-base";
8 symantic-base.inputs.nixpkgs.follows = "nixpkgs";
9 url-slug.url = "github:srid/url-slug";
10 url-slug.inputs.nixpkgs.follows = "nixpkgs";
11 };
12 outputs = inputs:
13 let
14 pkg = "webc";
15 lib = inputs.nixpkgs.lib;
16 forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
17 inherit system;
18 pkgs = inputs.nixpkgs.legacyPackages.${system};
19 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; hfinal: hsuper: {
20 ${pkg} = buildFromSdist (hfinal.callCabal2nix pkg ./. { });
21 symantic-base = buildFromSdist (hfinal.callCabal2nix "symantic-base" inputs.symantic-base { });
22 url-slug = buildFromSdist (hfinal.callCabal2nix "url-slug" inputs.url-slug { });
23 });
24 });
25 in
26 rec {
27 # nix -L build
28 defaultPackage = forAllSystems ({ haskellPackages, ... }: haskellPackages.${pkg});
29 # nix -L develop or direnv allow
30 devShell = forAllSystems ({ pkgs, haskellPackages, system, ... }:
31 haskellPackages.shellFor {
32 packages = ps: [ ps.${pkg} ];
33 nativeBuildInputs = [
34 haskellPackages.cabal-install
35 haskellPackages.ghcid
36 haskellPackages.haskell-language-server
37 haskellPackages.hlint
38 pkgs.git-chglog
39 pkgs.reuse
40 ];
41 withHoogle = false;
42 inherit (checks.${system}.pre-commit-check) shellHook;
43 });
44 # nix flake check
45 checks = forAllSystems (args: with args; {
46 pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
47 src = ./.;
48 settings.ormolu.defaultExtensions = [
49 "ImportQualifiedPost"
50 "TypeApplications"
51 ];
52 hooks = {
53 hlint.enable = true;
54 nixpkgs-fmt.enable = true;
55 fourmolu.enable = true;
56 cabal-fmt.enable = true;
57 };
58 };
59 });
60 };
61 }