-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
196 lines (171 loc) · 5.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
{
description = "Home Manager configuration";
nixConfig = {
# override the default substituters
substituters = [
# cache mirror located in China
# status: https://mirror.sjtu.edu.cn/
# "https://mirror.sjtu.edu.cn/nix-channels/store"
# status: https://mirrors.ustc.edu.cn/status/
# "https://mirrors.ustc.edu.cn/nix-channels/store"
"https://cache.nixos.org"
# nix community's cache server
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
# nix community's cache server public key
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nix-index-database = {
url = "github:nix-community/nix-index-database/e76ff2df6bfd2abe06abd8e7b9f217df941c1b07";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:lnl7/nix-darwin/550340062c16d7ef8c2cc20a3d2b97bcd3c6b6f6";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL/main";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils/b1d9ab70662946ef0850d488da1c9019f3a9752a";
};
nix-on-droid = {
url = "github:nix-community/nix-on-droid/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
# neovim-nightly-overlay = {
# url = "github:nix-community/neovim-nightly-overlay";
# inputs.nixpkgs.follows = "nixpkgs";
# };
};
outputs =
inputs@{ nixpkgs
, nixpkgs-unstable
, nix-index-database
, nix-darwin
, home-manager
, flake-utils
, nix-on-droid
, ...
}: with flake-utils.lib; eachDefaultSystem (system:
let
log = v: builtins.trace v v;
systemMaps = {
"x86_64-darwin" = "common-darwin";
"aarch64-darwin" = "common-darwin";
};
overlays = [
# inputs.neovim-nightly-overlay.overlay
];
mkHome =
{ modules
, useSecret ? true
, useProxy ? false
, useMirrorDrive ? false # useMirrorDrive is a boolean to config if copy remote config from google drive by rclone instead of Google drive stream
, isMobile ? false
, extraSpecialArgs ? { }
}: home-manager.lib.homeManagerConfiguration {
pkgs = builtins.trace system (import nixpkgs {
inherit system;
config.allowUnfree = true;
# overlays = overlays;
});
modules = log (builtins.filter (el: el != "") modules);
# Nix has dynamic scope, extraSpecialArgs will be passed to evalModules as the scope of funcitons,
# which means those functions can access `useSecret` directly instead of `specialArgs.useSecret`
# TL;DR: https://github.com/nix-community/home-manager/blob/36f873dfc8e2b6b89936ff3e2b74803d50447e0a/modules/default.nix#L26
extraSpecialArgs = {
inherit system useSecret useProxy useMirrorDrive isMobile;
unstablePkgs = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
} // extraSpecialArgs;
};
in
{
packages = {
home-manager = home-manager.defaultPackage.${system};
nix-darwin = nix-darwin.packages.${system}.default;
nix-on-droid = nix-on-droid.packages.${system};
homeConfigurations = {
vpn-server = mkHome {
modules = [
./home/vpn-server.nix
];
};
# m3 || wsl || ec2
ide = mkHome {
modules = [
./home/ide.nix
];
};
# c02fk4mjmd6m
ide-mirror = mkHome {
useMirrorDrive = true;
modules = [
./home/ide.nix
];
};
# cn ec2
ide-cn = mkHome {
useProxy = true;
modules = [
./home/ide.nix
];
};
# mobile
ide-mobile = mkHome {
isMobile = true;
useMirrorDrive = true;
modules = [
./home/ide.nix
];
};
# clean all packages & generated files
eject = mkHome {
modules = [
./home/eject.nix
];
};
};
darwinConfigurations = {
"darwin" = nix-darwin.lib.darwinSystem {
inherit system;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
modules = log [
./systems/darwin.nix
];
specialArgs = { inherit inputs; };
};
};
nixOnDroidConfigurations = {
"default" = nix-on-droid.lib.nixOnDroidConfiguration {
inherit system;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
modules = [
./systems/aarch64-linux.nix
];
};
};
};
});
}