-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
52 lines (47 loc) · 1.95 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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixos-generators, ... }: let
architectures = builtins.fromJSON (builtins.readFile ./architectures.json);
configurations = builtins.map (filename: builtins.replaceStrings [".nix"] [""] filename) (builtins.attrNames (builtins.readDir ./configurations));
in
{
nixosModules.customFormats = {config, lib, ...}: {
formatConfigs.amazon = {config, lib, ...}: {
amazonImage.sizeMB = "auto";
};
formatConfigs.do = {config, lib, ...}: {
# https://github.com/NixOS/nixpkgs/issues/308404
# set both, else module merge rules lead to duplicate entries in boot.loader.grub.devices
boot.loader.grub.devices = lib.mkForce [ "/dev/vda" ];
boot.loader.grub.device = "/dev/vda";
};
formatConfigs.docker = {config, lib, ...}: {
services.resolved.enable = false;
};
formatConfigs.oracle = {config, modulesPath, ...}: {
imports = [
"${toString modulesPath}/virtualisation/oci-image.nix"
];
formatAttr = "OCIImage";
fileExtension = ".qcow2";
};
formatConfigs.qcow = {config, lib, ...}: {
services.qemuGuest.enable = true;
};
};
nixosConfigurations = builtins.listToAttrs (nixpkgs.lib.lists.forEach (nixpkgs.lib.attrsets.cartesianProductOfSets { architecture = architectures; configuration = configurations; }) (systemInfo: nixpkgs.lib.attrsets.nameValuePair "nixos-${systemInfo.configuration}-${systemInfo.architecture}" (nixpkgs.lib.nixosSystem {
system = "${systemInfo.architecture}-linux";
modules = [
nixos-generators.nixosModules.all-formats
self.nixosModules.customFormats
(nixpkgs.lib.path.append ./configurations "${systemInfo.configuration}.nix")
];
})));
};
}