skeleton flake w/ precommit hooks
flake.nix
edited
1# SPDX-FileCopyrightText: atproto-nix.org 2026
2# SPDX-License-Identifier: CC0-1.0 OR Unlicense
3{
4 description = "atproto-nix.org nix user repository for atproto projects";
5 inputs = {
6 nixpkgs.url = "github:NixOS/nixpkgs?rev=25.11";
7 git-hooks.url = "github:cachix/git-hooks.nix";
8 alejandra.url = "github:kamadorueda/alejandra/4.0.0";
9 alejandra.inputs.nixpkgs.follows = "nixpkgs";
10 statix.url = "git+https://tangled.org/oppi.li/statix";
11 deadnix.url = "github:astro/deadnix";
12 };
13 outputs = inputs @ {
14 self,
15 nixpkgs,
16 alejandra,
17 ...
18 }: let
19 outputSystems = nixpkgs.lib.systems.flakeExposed;
20 forAllSystems = function:
21 nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
22 system:
23 function (
24 import nixpkgs {
25 inherit system;
26 config.allowUnfree = true;
27 }
28 )
29 );
30 in {
31 packages = forAllSystems (pkgs: {});
32
33 formatter = forAllSystems (
34 pkgs: let
35 config = self.checks.${pkgs.system}.pre-commit-check.config;
36 inherit (config) package configFile;
37 script = ''
38 ${pkgs.lib.getExe package} run --all-files --config ${configFile}
39 '';
40 in
41 pkgs.writeShellScriptBin "pre-commit-run" script
42 );
43
44 checks = forAllSystems (pkgs: {
45 pre-commit-check = inputs.git-hooks.lib.${pkgs.system}.run {
46 src = ./.;
47 hooks = {
48 alejandra.enable = true;
49 reuse.enable = true;
50 statix.enable = true;
51 deadnix.enable = true;
52 };
53 };
54 });
55
56 devShells = forAllSystems (pkgs: {
57 default = let
58 inherit (self.checks.${pkgs.system}.pre-commit-check) shellHook enabledPackages;
59 in
60 pkgs.mkShell {
61 inherit shellHook;
62 buildInputs = enabledPackages;
63 };
64 });
65 };
66}