summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 98bb672d0d01e2d697c95c3c6a3236575b4db5ce (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
{
  inputs = {
    nixpkgsUnstable.url = "nixpkgs/nixos-unstable";
    getchoo = {
      url = "github:getchoo/overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    lanzaboote = {
      url = "github:nix-community/lanzaboote";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixos-wsl = {
      url = "github:nix-community/NixOS-WSL/main";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixos-hardware.url = "github:NixOS/nixos-hardware";
    nur.url = "github:nix-community/NUR";
  };

  outputs = inputs @ {
    nixpkgs,
    nixpkgsUnstable,
    ...
  }: let
    supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
    forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

    mkPkgsFor = pkgs: forAllSystems (system: import pkgs {inherit system;});
    channels = {
      nixpkgs = mkPkgsFor nixpkgs;
      nixpkgsUnstable = mkPkgsFor nixpkgsUnstable;
    };

    util = import ./util {
      inherit (nixpkgs) lib;
      inherit inputs;
    };
    inherit (util.host) mapHosts;
    inherit (util.user) mapHMUsers;

    users = import ./users {inherit inputs;};
    hosts = import ./hosts {inherit inputs;};
  in {
    homeConfigurations = forAllSystems (system: mapHMUsers (users.users {inherit system;}));

    nixosConfigurations = mapHosts hosts;

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