summaryrefslogtreecommitdiff
path: root/flake.nix
blob: df7f8c423c885d97e40485561d3b030503288322 (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
74
75
76
77
78
79
80
{
  description = "getchoo's nix expressions";

  nixConfig = {
    extra-substituters = ["https://nix-community.cachix.org"];
    extra-trusted-public-keys = ["nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="];
  };

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable-small";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };

  outputs = {nixpkgs, ...}: let
    systems = [
      "x86_64-linux"
      "x86_64-darwin"
      "aarch64-linux"
      "aarch64-darwin"
    ];

    forAllSystems = nixpkgs.lib.genAttrs systems;
    nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;});

    packageSet = pkgs:
      with pkgs; {
        treefetch = callPackage ./pkgs/treefetch.nix {};
        swhkd = callPackage ./pkgs/swhkd {};
        vim-just = callPackage ./pkgs/vim-just.nix {};
      };

    overrides = prev: {
      discord = import ./pkgs/discord.nix prev;
      discord-canary = import ./pkgs/discord-canary.nix prev;
    };
  in {
    flakeModules = {
      default = import ./modules/flake;
      homeConfigurations = import ./modules/flake/homeConfigurations.nix;
    };

    formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra);

    herculesCI = {
      ciSystems = [
        "x86_64-linux"
        "aarch64-linux"
      ];
    };

    packages = forAllSystems (
      system: let
        pkgs = nixpkgsFor.${system};
        p = packageSet pkgs;
      in
        p // {default = p.treefetch;}
    );

    lib = import ./lib nixpkgs.lib;

    overlays.default = final: prev: packageSet final // overrides prev;

    templates = let
      # string -> string -> {}
      mkTemplate = name: description: {
        path = builtins.path {
          name = "${name}-template-src";
          path = ./templates/${name};
        };
        inherit description;
      };
    in {
      basic = mkTemplate "basic" "minimal boilerplate for my flakes";
      full = mkTemplate "full" "big template for complex flakes (using flake-parts)";
    };
  };
}