-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
131 lines (120 loc) · 3.08 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
{
description = "gang.liu macOS system config";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.11-darwin";
nix-darwin = {
url = "github:LnL7/nix-darwin/nix-darwin-24.11";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
# secrets = {
# url = "git+ssh://git@github.com/stringang/nix-secrets.git";
# flake = false;
# };
};
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs: let
inherit (nixpkgs) lib;
mylib = import ./lib {inherit lib;};
genSpecialArgs = myvars: {
inherit inputs mylib myvars;
pkgs-stable = import inputs.nixpkgs {
inherit (myvars) system;
# pass-through Allow unfree packages
config.allowUnfree = true;
};
};
# common arguments pass to darwin & nixos hosts
commonArgs = {inherit inputs lib mylib genSpecialArgs;};
darwinHosts = {
mini = rec {
myvars = {
system = "aarch64-darwin";
username = "liugang";
homeDirectory = "/Users/liugang";
hostname = "liugang-mini";
};
# darwin 模块
darwinModules = [
./modules/darwin
(./. + "/hosts/darwin-mini")
];
homeModules = [
./home/darwin
(./. + "/hosts/darwin-mini/home.nix")
];
};
mbp = {
myvars = {
system = "x86_64-darwin";
username = "liugang";
homeDirectory = "/Users/liugang";
hostname = "liugang-mbp";
};
darwinModules = [
./modules/darwin
./hosts/darwin-mbp
];
homeModules = [
./home/darwin
./hosts/darwin-mbp/home.nix
];
};
work = {
myvars = {
system = "aarch64-darwin";
username = "yuzhang";
homeDirectory = "/Users/yuzhang";
hostname = "yuzhang-mbp";
};
darwinModules = [
./modules/darwin
./hosts/darwin-work
];
homeModules = [
./home/darwin
./hosts/darwin-work/home.nix
];
};
};
in
{
darwinConfigurations =
builtins.mapAttrs (
_: value:
mylib.macosSystem (commonArgs // value)
)
darwinHosts;
}
// flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
alejandra
nil
taplo
typos
];
};
# Format the nix code in this flake
formatter =
# alejandra is a nix formatter with a beautiful output
pkgs.alejandra;
}
);
}