-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
174 lines (167 loc) · 4.96 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
flake-utils.url = "github:numtide/flake-utils";
nixos-apple-silicon = {
url = "github:tpwrules/nixos-apple-silicon";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat = {
url = "github:inclyc/flake-compat";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
flake-parts,
sops-nix,
...
}@inputs:
let
devShellsDir = ./devShells;
nixosConfigDir = ./nixos/configurations;
inherit (self) outputs;
rootPath = ./.;
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = flake-utils.lib.defaultSystems;
perSystem =
{
pkgs,
...
}:
{
devShells =
nixpkgs.lib.mapAttrs' (
f: _:
nixpkgs.lib.nameValuePair (nixpkgs.lib.removeSuffix ".nix" f) (
import (devShellsDir + "/${f}") { inherit pkgs; }
)
) (builtins.readDir devShellsDir)
// {
default = import ./shell.nix { inherit pkgs; };
};
packages = import ./pkgs { inherit pkgs; };
};
flake =
{
nix.settings = {
# nix substituters shared between home-manager and nixos
substituters =
let
channelStore = x: "https://${x}/nix-channels/store";
mirrors = map (x: channelStore "mirrors.${x}.edu.cn") [
"bfsu"
"tuna.tsinghua"
"ustc"
];
cachix = x: "https://${x}.cachix.org";
in
nixpkgs.lib.flatten [
mirrors
(cachix "nix-community")
"https://cache.nixos.org"
(cachix "inclyc")
];
};
nixosModules.lyc = import ./nixos/modules;
nixosConfigurations =
nixpkgs.lib.genAttrs
(map (f: nixpkgs.lib.removeSuffix ".nix" f) [
"adrastea"
"metis"
])
(
hostName:
nixpkgs.lib.nixosSystem {
modules =
[ (nixosConfigDir + "/${hostName}") ]
++ [
outputs.nixosModules.lyc
sops-nix.nixosModules.sops
];
specialArgs = {
inherit inputs outputs rootPath;
};
}
);
overlays = {
additions = final: _prev: import ./pkgs { pkgs = final; };
modifications = import ./overlays/modifications.nix;
};
}
// (
# Home-manager configurations
let
mkHomeConfig =
{
hostName,
unixName ? "lyc",
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
home-manager ? inputs.home-manager,
}:
{
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [
(./home/lyc/configurations + "/${hostName}")
sops-nix.homeManagerModules.sops
] ++ (builtins.attrValues outputs.homeManagerModules);
extraSpecialArgs = {
inherit
inputs
outputs
rootPath
unixName
hostName
system
;
};
};
};
in
{
homeConfigurations =
nixpkgs.lib.foldr (a: b: a // b) { } (
map (hostName: mkHomeConfig { inherit hostName; }) [
# Simple home configuration, only specified "hostName"
"adrastea"
"metis"
"ict-malcon"
]
)
// mkHomeConfig {
hostName = "amalthea";
system = "aarch64-darwin";
}
// mkHomeConfig {
hostName = "aplax";
system = "aarch64-darwin";
}
// mkHomeConfig {
hostName = "aplaz";
system = "aarch64-linux";
};
homeManagerModules = {
lyc = import ./home/lyc/modules;
common = import ./home/modules;
};
}
);
};
}