aboutsummaryrefslogtreecommitdiff
path: root/modules/flake/nixos.nix
blob: efc6d15ebc7b307d7426f7a477e1cccdc3ff562f (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
{ inputs, config, self, ... }:

let
  inherit (inputs.nixpkgs) lib;
  import-tree = inputs.import-tree.withLib lib;

  # Use import-tree.leafs to get list of NixOS module paths
  nixosModuleFiles = import-tree.leafs (self + /modules/nixos);

  # Common NixOS modules for all hosts
  commonNixosModules = nixosModuleFiles ++ [
    {
      nixpkgs.config.allowUnfree = true;
      nix.settings.experimental-features = [ "nix-command" "flakes" ];
    }
  ];

  # Home-manager modules for hosts that use it
  homeManagerModules = [
    inputs.home-manager.nixosModules.home-manager
    {
      home-manager.extraSpecialArgs = { inherit inputs; };
      home-manager.sharedModules = [ config.flake.homeModules.default ];
    }
  ];
in
{
  flake.nixosConfigurations = {
    adam = lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; host = "adam"; };
      modules = commonNixosModules ++ homeManagerModules ++ [
        (self + /hosts/adam/configuration.nix)
      ];
    };

    sachiel = lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; host = "sachiel"; };
      modules = commonNixosModules ++ [
        (self + /hosts/sachiel/configuration.nix)
      ];
    };
  };
}