-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
133 lines (125 loc) · 3.6 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
description = "My NixOS Config";
nixConfig = {
extra-substituters = [ "https://raspberry-pi-nix.cachix.org" ];
extra-trusted-public-keys = [
"raspberry-pi-nix.cachix.org-1:WmV2rdSangxW0rZjY/tBvBDSaNFQ3DyEQsVw8EvHn9o="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
raspberry-pi-nix.url = "github:tstat/raspberry-pi-nix";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nnn = {
url = "github:jarun/nnn";
flake = false;
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware";
};
};
outputs =
{
nixpkgs,
nixpkgs-stable,
home-manager,
sops-nix,
nnn,
self,
...
}@inputs:
with builtins;
with nixpkgs.lib;
let
getNixFilesInDir = d: map (p: d + "/${p}") (filter (n: hasSuffix ".nix" n) (attrNames (readDir d)));
mkHost =
hostname:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
{
_module.args = inputs // {
inherit hostname;
pkgs-stable = import nixpkgs-stable {
system = "x86_64-linux";
config.allowUnfree = true;
};
};
}
]
++ (getNixFilesInDir ./common)
++ (getNixFilesInDir ./common-opt)
++ (getNixFilesInDir ./hosts/${hostname});
};
in
{
# This builds all derivations here on `nix flake check`.
# https://github.com/NixOS/nix/issues/7165
checks =
let
# Shape:
# [
# {x86_64-linux: {name = desktop; value = desktopConfig;}}
# {x86_64-linux: {name = laptop; value = laptopConfig;}}
# ...
# ]
systems = mapAttrsToList (
hostname: type:
let
config = self.nixosConfigurations.${hostname}.config.system.build.toplevel;
system = config.system;
in
{
${system} = {
name = hostname;
value = config;
};
}
) (readDir ./hosts);
in
# Shape:
# {x86_64-linux = {desktop = desktopConfig; laptop: laptopConfig;}}
zipAttrsWith (system: listToAttrs) systems;
nixosConfigurations =
(mapAttrs (hostname: _: mkHost hostname)
# Get hostnames by reading folder name in hosts/
(readDir ./hosts)
)
// {
# ISO installer image with USB wifi driver support
# Build with:
# nix build .#nixosConfigurations.iso-wifi.config.system.build.isoImage
iso-wifi = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
# Add rtl8821cu wifi driver
(nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix")
(
{
pkgs,
lib,
config,
...
}:
{
boot.extraModulePackages = with config.boot.kernelPackages; [
rtl8821cu
];
}
)
];
};
};
};
}