-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
98 lines (91 loc) · 3.21 KB
/
Copy pathflake.nix
File metadata and controls
98 lines (91 loc) · 3.21 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
description = "nixos-managed trollsystem";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.colmena.url = "github:zhaofengli/colmena/main";
inputs.colmena.inputs.nixpkgs.follows = "/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.sops-nix.url = "github:Mic92/sops-nix";
inputs.sops-nix.inputs.nixpkgs.follows = "/nixpkgs";
inputs.disko.url = "github:nix-community/disko";
inputs.disko.inputs.nixpkgs.follows = "/nixpkgs";
inputs.trollsystem.url = "tarball+https://codeberg.org/entropia/Trollsystem/archive/main.tar.gz";
inputs.trollsystem.inputs.nixpkgs.follows = "/nixpkgs";
outputs = { self, nixpkgs, colmena, flake-utils, sops-nix, disko, ...
}@inputs:
let
specialArgs = {
evalConfig = extraSpecial: system: config:
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
config
sops-nix.nixosModules.sops
disko.nixosModules.disko
];
specialArgs = {
inherit (specialArgs) evalConfig;
inherit hosts;
sources = inputs;
} // extraSpecial;
};
};
hostsDir = "${./.}/hosts";
hostNames = with nixpkgs.lib;
attrNames (filterAttrs (name: type: type == "directory")
(builtins.readDir hostsDir));
hostMeta = host:
if builtins.pathExists "${hostsDir}/${host}/meta.nix" then
(import "${hostsDir}/${host}/meta.nix")
(inputs // { inherit (specialArgs) evalConfig; })
else
{ };
hostConfig = host:
nixpkgs.lib.recursiveUpdateUntil (path: lhs: rhs:
!(builtins.isAttrs lhs && builtins.isAttrs rhs) || rhs == { }) {
nixosConfiguration = specialArgs.evalConfig { hostname = host; } "x86_64-linux" {
imports = [ "${hostsDir}/${host}/configuration.nix" ];
networking.hostName = host;
};
deployment = {
allowLocalDeployment = true;
targetHost = "${host}.gulas.ch";
targetUser = null;
};
} (hostMeta host);
hosts = with nixpkgs.lib;
listToAttrs
(map (name: nameValuePair name (hostConfig name)) hostNames);
colmenaHiveMeta = {
allowApplyAll = true;
description = "troll deployment";
machinesFile = null;
name = "hive";
};
nixosHosts = nixpkgs.lib.filterAttrs (_: c: !(c.meta.darwin or false)) hosts;
in {
nixosConfigurations = builtins.mapAttrs (host: config:
config.nixosConfiguration // {
meta = hostMeta host;
}) nixosHosts;
colmenaHive = import ./lib/colmena-compat.nix { inherit nixpkgs hosts colmena colmenaHiveMeta; };
} // flake-utils.lib.eachSystem ([
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
]) (system:
let
pkgs = (import nixpkgs {
inherit system;
});
in {
devShells.default = pkgs.mkShell {
buildInputs = [
colmena.packages.${system}.colmena
sops-nix.packages.${system}.sops-init-gpg-key
pkgs.age
pkgs.sops
];
};
});
}