aboutsummaryrefslogtreecommitdiff
path: root/modules/flake/nixos.nix
blob: 40145ea7fd3503ba2d80e285f988228f4358f460 (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
{
  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.backupFileExtension = "backup";
      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)
      ];
    };
  };
}