flake.nix

 1{
 2  description = "workspace configuration for git-bug";
 3
 4  inputs = {
 5    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
 6    flake-utils.url = "github:numtide/flake-utils";
 7    flake-parts.url = "github:hercules-ci/flake-parts";
 8
 9    treefmt-nix = {
10      url = "github:numtide/treefmt-nix";
11      inputs.nixpkgs.follows = "nixpkgs";
12    };
13
14    # A workaround for the currently-broken mdformat packages
15    fmt-pkgs.url = "github:nixos/nixpkgs/b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef";
16  };
17
18  outputs =
19    { nixpkgs, ... }@inputs:
20    let
21      systems = inputs.flake-utils.lib.defaultSystems;
22    in
23    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
24      inherit systems;
25
26      imports = [ inputs.treefmt-nix.flakeModule ];
27
28      perSystem =
29        { pkgs, system, ... }:
30        let
31          fp = inputs.fmt-pkgs.legacyPackages.${system};
32        in
33        {
34          treefmt = import ./treefmt.nix { pkgs = fp; };
35
36          checks = pkgs.lib.attrsets.mapAttrs' (f: _: {
37            name = pkgs.lib.strings.removeSuffix ".nix" f;
38            value = import ./nix/checks/${f} {
39              inherit pkgs;
40              src = ./.;
41            };
42          }) (pkgs.lib.attrsets.filterAttrs (_: t: t == "regular") (builtins.readDir ./nix/checks));
43
44          devShells.default = pkgs.mkShell {
45            packages = with pkgs; [
46              codespell
47              delve
48              gh
49              git
50              go
51              golangci-lint
52              gopls
53              nodejs
54              pinact
55            ];
56
57            shellHook = builtins.readFile ./flake-hook.bash;
58          };
59        };
60    };
61}