-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
157 lines (136 loc) · 3.77 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
{
inputs = {
nixpkgs = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
ref = "nixpkgs-unstable";
};
nixos-hardware = {
type = "github";
owner = "nixos";
repo = "nixos-hardware";
ref = "master";
};
darwin = {
type = "github";
owner = "lnl7";
repo = "nix-darwin";
ref = "master";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database = {
type = "github";
owner = "Mic92";
repo = "nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
type = "github";
owner = "nix-community";
repo = "home-manager";
ref = "master";
inputs.nixpkgs.follows = "nixpkgs";
};
emacs-overlay = {
type = "github";
owner = "nix-community";
repo = "emacs-overlay";
ref = "master";
inputs.nixpkgs.follows = "nixpkgs";
};
systems-private.url = path:///home/alex/systems-private;
};
outputs =
{ self
, nixpkgs
, nixos-hardware
, darwin
, nix-index-database
, home-manager
, emacs-overlay
, systems-private
} @ inputs:
let
emacsOverlay = { nixpkgs.overlays = [ emacs-overlay.overlay ]; };
mkCommonModules = name: [
./config/hosts/${name}
./config/modules/common
./config/users
./config/roles
{
networking.hostName = name;
system.stateVersion = "24.05";
programs.command-not-found.enable = false; # use nix-index-database
}
];
nixosModules = [
home-manager.nixosModules.home-manager
nix-index-database.nixosModules.nix-index
systems-private.nixosModules.private
./config/modules/nixos
];
darwinModules = [
home-manager.darwinModules.home-manager
nix-index-database.darwinModules.nix-index
systems-private.nixosModules.private
./config/modules/darwin
];
# check if attrset should become a nixosConfiguration
isNixosSystem = system: system == "x86_64-linux";
# generate the list of modules to inject into the configuration
mkModules = name: cfg:
(mkCommonModules name)
++ (if isNixosSystem cfg.system
then nixosModules
else darwinModules)
++ (cfg.modules or [ ]);
mkSystem = name: cfg: {
system = cfg.system;
modules = mkModules name cfg;
specialArgs = {
inherit inputs;
};
};
# turn a named attrset into nixosSystems or darwinSystems
mkConfiguration = name: cfg:
if isNixosSystem cfg.system
then nixpkgs.lib.nixosSystem (mkSystem name cfg)
else darwin.lib.darwinSystem (mkSystem name cfg);
mkConfigurations = systems: nixpkgs.lib.mapAttrs mkConfiguration systems;
darwinSystems = {
imac = {
system = "aarch64-darwin";
modules = [ emacsOverlay ];
};
};
nixosSystems = {
base = {
system = "x86_64-linux";
modules = [ ];
};
carbon = {
system = "x86_64-linux";
modules = [
nixos-hardware.nixosModules.lenovo-thinkpad-x1-6th-gen
emacsOverlay
];
};
mini = {
system = "x86_64-linux";
modules = [{ custom.user.shell = nixpkgs.legacyPackages.x86_64-linux.bash; }];
};
pi = {
system = "aarch64-linux";
modules = [
nixos-hardware.nixosModules.raspberry-pi-4
{ custom.user.shell = nixpkgs.legacyPackages.aarch64-linux.bash; }
];
};
};
in
{
darwinConfigurations = mkConfigurations darwinSystems;
nixosConfigurations = mkConfigurations nixosSystems;
};
}