-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
101 lines (90 loc) · 3.32 KB
/
flake.nix
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
99
100
101
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
deploy-sh.url = "github:Defelo/deploy-sh";
sops-nix.url = "github:Mic92/sops-nix";
nfnix.url = "github:Defelo/nfnix";
disko.url = "github:nix-community/disko";
impermanence.url = "github:nix-community/impermanence";
sandkasten.url = "github:Defelo/sandkasten";
buildbot-nix.url = "github:nix-community/buildbot-nix";
auth-ms.url = "github:Bootstrap-Academy/auth-ms/latest";
skills-ms.url = "github:Bootstrap-Academy/skills-ms/latest";
shop-ms.url = "github:Bootstrap-Academy/shop-ms/latest";
jobs-ms.url = "github:Bootstrap-Academy/jobs-ms/latest";
events-ms.url = "github:Bootstrap-Academy/events-ms/latest";
challenges-ms.url = "github:Bootstrap-Academy/challenges-ms/latest";
auth-ms-develop.url = "github:Bootstrap-Academy/auth-ms/develop";
skills-ms-develop.url = "github:Bootstrap-Academy/skills-ms/develop";
shop-ms-develop.url = "github:Bootstrap-Academy/shop-ms/develop";
jobs-ms-develop.url = "github:Bootstrap-Academy/jobs-ms/develop";
events-ms-develop.url = "github:Bootstrap-Academy/events-ms/develop";
challenges-ms-develop.url = "github:Bootstrap-Academy/challenges-ms/develop";
backend-develop.url = "github:Bootstrap-Academy/backend/develop";
};
outputs = {
self,
nixpkgs,
deploy-sh,
sops-nix,
disko,
impermanence,
...
} @ inputs: let
inherit (nixpkgs) lib;
defaultSystems = [
"x86_64-linux"
"aarch64-linux"
];
eachDefaultSystem = lib.genAttrs defaultSystems;
extra-pkgs = system:
lib.pipe inputs [
(lib.filterAttrs (k: _: lib.hasPrefix "nixpkgs-" k))
(lib.mapAttrs' (k: v: {
name = lib.removePrefix "nix" k;
value = import v {inherit system;};
}))
];
getSystemFromHardwareConfiguration = hostName: let
f = import ./hosts/${hostName}/hardware-configuration.nix;
args = builtins.functionArgs f // {lib.mkDefault = lib.id;};
in
(f args).nixpkgs.hostPlatform;
mkHost = name: system:
lib.nixosSystem {
inherit system;
specialArgs = inputs // (extra-pkgs system) // {inherit inputs system name;};
modules = [
disko.nixosModules.default
impermanence.nixosModule
./hosts/${name}
./hosts/${name}/hardware-configuration.nix
./modules
];
};
in {
nixosConfigurations = lib.pipe ./hosts [
builtins.readDir
(lib.filterAttrs (_: type: type == "directory"))
(builtins.mapAttrs (name: _: mkHost name (getSystemFromHardwareConfiguration name)))
];
deploy-sh.hosts = self.nixosConfigurations;
devShells = eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
default = import ./dev.nix (inputs // {inherit pkgs system;});
ci = pkgs.mkShell {
packages = [self.formatter.${system}];
};
});
formatter = eachDefaultSystem (system: (import nixpkgs {inherit system;}).alejandra);
checks = let
nixosConfigurations =
lib.mapAttrsToList (name: config: {
${getSystemFromHardwareConfiguration name}.${name} = config.config.system.build.toplevel;
})
self.nixosConfigurations;
in
builtins.foldl' lib.recursiveUpdate {} nixosConfigurations;
};
}