-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
122 lines (111 loc) · 3.75 KB
/
flake.nix
File metadata and controls
122 lines (111 loc) · 3.75 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-glitchtip.url = "github:NixOS/nixpkgs";
deploy-sh.url = "git+https://radicle.defelo.de/z392ZFR7AcScpaQqmTKUDkDj9FWMq.git";
sops-nix.url = "github:Mic92/sops-nix";
nfnix = {
url = "git+https://radicle.defelo.de/z38ibAcVXcV86bVdfdMY9JXJcX5ZN.git";
inputs.nixpkgs.follows = "nixpkgs";
};
disko.url = "github:nix-community/disko";
impermanence.url = "github:nix-community/impermanence";
sandkasten.url = "git+https://radicle.defelo.de/zKBbWZxz73j7BZMbutM7TMMT4v5K.git";
skills-ms.url = "github:Bootstrap-Academy/skills-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";
backend.url = "github:Bootstrap-Academy/backend/develop";
skills-ms-develop.url = "github:Bootstrap-Academy/skills-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;
systems = [
"x86_64-linux"
"aarch64-linux"
];
eachSystem = f: lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s});
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
{ _module.args.env = import ./env.nix; }
];
};
in
{
packages = eachSystem (pkgs: {
checks =
let
hosts = pkgs.linkFarm "checks-hosts" (
lib.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations
);
devShells = pkgs.linkFarm "checks-devShells" self.devShells.${pkgs.stdenv.hostPlatform.system};
in
pkgs.linkFarmFromDrvs "checks" [
hosts
devShells
];
});
nixosConfigurations = lib.pipe ./hosts [
builtins.readDir
(lib.filterAttrs (_: type: type == "directory"))
(builtins.mapAttrs (name: _: mkHost name (getSystemFromHardwareConfiguration name)))
];
deploy-sh.hosts = self.nixosConfigurations;
devShells = eachSystem (pkgs: {
default = pkgs.callPackage ./dev.nix { inherit inputs; };
});
formatter = eachSystem (
pkgs:
pkgs.treefmt.withConfig {
settings = lib.mkMerge [
./treefmt.nix
{ _module.args = { inherit pkgs; }; }
];
}
);
};
}