summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 2de484b78241148ea90abd06d3178aca7a76eb73 (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
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
  inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.nixos-hardware.url = github:NixOS/nixos-hardware/master;
  inputs.home-manager.url = "github:rycee/home-manager/master";
  inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";

  # TODO: Remove nix overlay when pull request is resolved:
  # https://github.com/NixOS/nix/pull/4566
  inputs.nix.url = "github:orbekk/nix/master";
  inputs.nix.inputs.nixpkgs.follows = "nixpkgs";

  outputs = { self, nixpkgs, nixpkgs-unstable, nix, nixos-hardware, home-manager }:
    {
      nixosConfigurations = let
        mkConfig = { hostName
                   , module ? (./. + "/machines/${hostName}.nix")
                   , system ? "x86_64-linux" }: {
          name = hostName;
          value = nixpkgs.lib.nixosSystem {
            system = "x86_64-linux";
            modules =
              [
                module
                nixpkgs.nixosModules.notDetected
                ({config, pkgs, ...}: {
                  # Let 'nixos-version --json' know about the Git revision
                  # of this flake.
                  system.configurationRevision =
                    if self ? rev then self.rev else "DIRTY";

                  nixpkgs.overlays = [
                    # Add unstable packages.
                    (final: prev: {
                      my-extras = {
                        inherit nixpkgs;
                        inherit nixpkgs-unstable;
                        inherit nixos-hardware;
                      };
                    })
                    # For git+file support with bare repo.
                    nix.overlay
                    (final: prev: { nixFlakes = final.nix; })
                  ];
                })
              ];
          };
        };
        myMachines = [
          { hostName = "pincer"; module = ./machines/x1-pincer.nix; }
          { hostName = "dragon"; }
          { hostName = "firelink"; }
        ];
      in builtins.listToAttrs (map mkConfig myMachines);
    };
}