-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
164 lines (155 loc) · 5.13 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Top level flake for Daniel's NixOS host configuration
{
description = "Daniel's host configurations";
inputs = {
# Basic inputs we need
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:nixos/nixos-hardware/master";
# Stuff for home directory handling
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# We use sops for secrets handling
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Utility flake used for internal management
flake-utils.url = "github:numtide/flake-utils";
# My dotfiles
dotfiles = {
url = "github:kinnison/dotfiles";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
inputs.nixpkgs-unstable.follows = "nixpkgs-unstable";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = inputs:
let
make-nixos-system = { sysconfig, nixpkgs, system, modules ? [] }:
let
overlays = [
(
final: prev: {
unstable = import inputs.nixpkgs-unstable {
inherit system;
};
}
)
];
in
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
(import ./configurations sysconfig)
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.home-manager
(
{ config, ... }: {
# Use the flakes' nixpkgs for commands
nix = {
nixPath = [ "nixpkgs=${nixpkgs}" ];
registry.nixpkgs = {
from = {
id = "nixpkgs";
type = "indirect";
};
flake = nixpkgs;
};
};
nixpkgs.overlays = overlays;
home-manager.useGlobalPkgs = false;
home-manager.useUserPackages = true;
home-manager.users."${sysconfig.user.name}" =
(inputs.dotfiles.homeConfigurations.${config.networking.hostName} config);
}
)
] ++ modules;
# extraModules = [ (import ./modules) ];
};
loadConfig = hostname: let
config = import (./configurations + "/${hostname}" + /config.nix);
in
config // {
hostname = hostname;
};
in
{
nixosConfigurations = {
installer = let
nixpkgs = inputs.nixpkgs;
in
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(
{ ... }: {
nixpkgs.overlays = [
(
final: prev: {
installer = (import ./installer/pkgs { pkgs = prev; });
}
)
];
}
)
"${nixpkgs.outPath}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${nixpkgs.outPath}/nixos/modules/installer/cd-dvd/channel.nix"
inputs.sops-nix.nixosModules.sops
./installer/iso.nix
];
};
test = make-nixos-system {
sysconfig = loadConfig "test";
nixpkgs = inputs.nixpkgs;
system = "x86_64-linux";
modules = [
(import ./configurations/test)
];
};
parasomnix = make-nixos-system {
sysconfig = loadConfig "parasomnix";
nixpkgs = inputs.nixpkgs;
system = "x86_64-linux";
modules = [
(import ./configurations/parasomnix)
];
};
indolence = make-nixos-system {
sysconfig = loadConfig "indolence";
nixpkgs = inputs.nixpkgs;
system = "x86_64-linux";
modules = [
(import ./configurations/indolence)
];
};
cataplexy = make-nixos-system {
sysconfig = loadConfig "cataplexy";
nixpkgs = inputs.nixpkgs;
system = "x86_64-linux";
modules = [
(import ./configurations/cataplexy)
];
};
};
}
// (
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
sops-pkgs = inputs.sops-nix.packages.${system};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; with sops-pkgs; [ pwgen nixfmt-classic sops-init-gpg-key ];
nativeBuildInputs = with sops-pkgs; [ sops-import-keys-hook ];
sopsPGPKeyDirs = [ "./keys/hosts/" "./keys/users/" ];
};
}
)
);
}