summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 9b2975a267a5c848011513d57d17e5c28ada5a07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  inputs = {
    utils.url = "github:numtide/flake-utils";
    naersk = {
      url = "github:nix-community/naersk";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    pre-commit-hooks = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "utils";
    };
  };

  outputs = {
    self,
    nixpkgs,
    utils,
    naersk,
    pre-commit-hooks,
    ...
  }: let
    supportedSystems = with utils.lib.system; [
      x86_64-linux
      x86_64-darwin
      aarch64-linux
      aarch64-darwin
    ];
    packageSet = pkgs:
      with pkgs; rec {
        treefetch = callPackage ./pkgs/treefetch.nix {inherit naersk;};
        material-color-utilities = callPackage ./pkgs/material-color-utilities.nix {};
        gradience = callPackage ./pkgs/gradience.nix {inherit material-color-utilities;};
        swhkd = callPackage ./pkgs/swhkd.nix {inherit naersk;};
        vim-just = callPackage ./pkgs/vim-just.nix {};
      };
    overrides = prev: {
      discord-canary = import ./pkgs/discord-canary.nix prev;
    };
  in
    utils.lib.eachSystem supportedSystems (system: let
      pkgs = import nixpkgs {inherit system;};
    in {
      checks = {
        pre-commit-check = pre-commit-hooks.lib.${system}.run {
          src = ./.;
          hooks = {
            # formatting is taken care of by gh actions :)
            deadnix.enable = true;
            markdownlint.enable = true;
          };
        };
      };

      devShells.default = pkgs.mkShell {
        inherit (self.checks.${system}.pre-commit-check) shellHook;
        packages = with pkgs; [
          nodePackages.markdownlint-cli
          deadnix
        ];
      };

      formatter = pkgs.alejandra;

      packages = let
        p = packageSet pkgs;
      in
        p // {default = p.treefetch;};
    })
    // {
      overlays.default = final: prev: packageSet final // overrides prev;
    };
}