-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
162 lines (155 loc) · 4.4 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
{
description = "Configurations of Mr.Unhappy";
inputs = {
flake-utils.url = github:numtide/flake-utils;
unstable-nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
unstable-home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "unstable-nixpkgs";
};
unstable-nixos-hardware.url = github:NixOS/nixos-hardware;
ags = {
url = github:Aylur/ags;
inputs.nixpkgs.follows = "unstable-nixpkgs";
};
zen-browser = {
url = "github:MarceColl/zen-browser-flake";
inputs.nixpkgs.follows = "unstable-nixpkgs";
};
darwin-nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-24.05-darwin;
darwin-nix-darwin = {
url = github:LnL7/nix-darwin/master;
inputs.nixpkgs.follows = "darwin-nixpkgs";
};
darwin-home-manager = {
url = github:nix-community/home-manager/release-24.05;
inputs.nixpkgs.follows = "darwin-nixpkgs";
};
};
outputs = inputs @ {
self,
flake-utils,
unstable-nixpkgs,
unstable-home-manager,
unstable-nixos-hardware,
ags,
zen-browser,
darwin-nixpkgs,
darwin-nix-darwin,
darwin-home-manager,
...
}: let
mkHost = user: hostName: system: specifiedModules: let
isDarwin = builtins.elem system unstable-nixpkgs.lib.platforms.darwin;
specifics =
{
nixos = {
nixpkgs = unstable-nixpkgs;
nixSystem = unstable-nixpkgs.lib.nixosSystem;
modules = [
unstable-home-manager.nixosModules.home-manager
./modules/nixos-common.nix
./modules/nixos
];
hm-modules = [
ags.homeManagerModules.default
];
};
darwin = {
nixpkgs = darwin-nixpkgs;
nixSystem = darwin-nix-darwin.lib.darwinSystem;
modules = [
darwin-home-manager.darwinModules.home-manager
./modules/darwin-common.nix
];
hm-modules = [
ags.homeManagerModules.default
];
};
}
.${
if isDarwin
then "darwin"
else "nixos"
};
in let
hostConfig = import ./hosts/${hostName}.nix {
inherit (specifics) nixpkgs;
inherit system hostName user;
};
lib = specifics.nixpkgs.lib.extend (final: prev: {
# …
});
freezeRegistry = {
nix.registry = lib.mapAttrs (_: flake: {inherit flake;}) inputs;
};
hostRootModule =
{
system.configurationRevision =
if (self ? rev)
then self.rev
else throw "refuse to build: git tree is dirty";
}
// hostConfig.root;
homeManagerModules = [
({config, ...}: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./home.nix;
sharedModules = specifics.hm-modules;
extraSpecialArgs = {
inherit isDarwin;
};
};
})
];
in
specifics.nixSystem {
inherit system;
specialArgs = {
inherit (specifics) nixpkgs;
inherit isDarwin hostName lib user;
};
modules =
[
./common.nix
freezeRegistry
]
++ specifics.modules
++ [
hostRootModule
hostConfig.module
]
++ homeManagerModules
++ specifiedModules;
};
in
flake-utils.lib.eachDefaultSystem (system: {
formatter = unstable-nixpkgs.legacyPackages.${system}.alejandra;
})
// {
nixosConfigurations = {
north = mkHost "mrunhap" "north" "x86_64-linux" [
{
environment.systemPackages = [zen-browser.packages."x86_64-linux".default];
}
];
homelab = mkHost "root" "homelab" "x86_64-linux" [];
};
darwinConfigurations = {
m3air = mkHost "liubo" "m3air" "aarch64-darwin" [];
macmini = mkHost "liubo" "macmini" "aarch64-darwin" [];
};
};
nixConfig = {
accept-flake-config = true;
experimental-features = ["nix-command" "flakes" "repl-flake"];
extra-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
}