summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 6dcce7cbd1450aeef049b8f4d60e2ae2501fe34e (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
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
  inputs.nixpkgs_unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

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

                  # Add unstable packages.
                  nixpkgs.overlays = [
                    (final: prev: { unstable = nixpkgs_unstable.legacyPackages."x86_64-linux"; })
                  ];
                })
              ];
          };
        };
        myMachines = [
          { hostName = "pincer"; module = ./machines/x1-pincer.nix; }
          { hostName = "dragon"; }
          { hostName = "firelink"; }
        ];
      in builtins.listToAttrs (map mkConfig myMachines);
    };
}