-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
221 lines (207 loc) · 8.68 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
{
description = "All your flake's are belongs to us";
# nixConfig = {
# # override the default substituters
# substituters = [
# "https://cache.nixos.org"
# "https://nix-community.cachix.org"
# ];
# trusted-public-keys = [
# "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# ];
# };
# This is the standard format for flake.nix.
# `inputs` are the dependencies of the flake,
# and `outputs` function will return all the build results of the flake.
# Each item in `inputs` will be passed as a parameter to
# the `outputs` function after being pulled and built.
inputs = {
# There are many ways to reference flake inputs.
# The most widely used is `github:owner/name/reference`,
# which represents the GitHub repository URL + branch/commit-id/tag.
# Official NixOS package source, using nixos-23.11 branch here
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin";
# home-manager, used for managing user configuration
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
# The `follows` keyword in inputs is used for inheritance.
# Here, `inputs.nixpkgs` of home-manager is kept consistent with
# the `inputs.nixpkgs` of the current flake,
# to avoid problems caused by different versions of nixpkgs.
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware/master";
};
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs-darwin";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
nix-homebrew.inputs.nixpkgs.follows = "nixpkgs-darwin";
nix-homebrew.inputs.nix-darwin.follows = "nix-darwin";
homebrew-bundle = {
url = "github:homebrew/homebrew-bundle";
flake = false;
};
homebrew-core = {
url = "github:homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
homebrew-services = {
url = "github:homebrew/homebrew-services";
flake = false;
};
emacs-plus = {
url = "github:d12frosted/homebrew-emacs-plus";
flake = false;
};
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0-3.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# `outputs` are all the build result of the flake.
#
# A flake can have many use cases and different types of outputs.
#
# parameters in function `outputs` are defined in `inputs` and
# can be referenced by their names. However, `self` is an exception,
# this special parameter points to the `outputs` itself(self-reference)
#
# The `@` syntax here is used to alias the attribute set of the
# inputs's parameter, making it convenient to use inside the function.
outputs = { self, nixpkgs, disko, nixpkgs-darwin, nix-darwin, nix-homebrew, nixos-hardware, home-manager, homebrew-bundle, homebrew-core, homebrew-cask, homebrew-services, emacs-plus, lix-module,... } @inputs: {
darwinConfigurations = {
"machine-spirit" = nix-darwin.lib.darwinSystem {
modules = [
./macos/darwin-configuration.nix
home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.jadex = import ./macos/home.nix;
};
users.users.jadex.home = "/Users/jadex";
}
nix-homebrew.darwinModules.nix-homebrew {
nix-homebrew = {
# Install Homebrew under the default prefix
enable = true;
autoMigrate = true;
# User owning the Homebrew prefix
user = "jadex";
# Automatically migrate existing Homebrew installations
mutableTaps = false;
taps = {
"d12frosted/emacs-plus" = emacs-plus;
"homebrew/homebrew-core" = homebrew-core;
"homebrew/homebrew-cask" = homebrew-cask;
"homebrew/homebrew-bundle" = homebrew-bundle;
"homebrew/homebrew-services" = homebrew-services;
};
};
}
];
specialArgs = { inherit inputs; };
};
};
darwinPackages = self.darwinConfigurations."machine-spirit".pkgs;
nixosConfigurations = {
# By default, NixOS will try to refer the nixosConfiguration with
# its hostname, so the system named `nixos-test` will use this one.
# However, the configuration name can also be specified using:
# sudo nixos-rebuild switch --flake /path/to/flakes/directory#<name>
#
# The `nixpkgs.lib.nixosSystem` function is used to build this
# configuration, the following attribute set is its parameter.
#
# Run the following command in the flake's directory to
# deploy this configuration on any NixOS system:
# sudo nixos-rebuild switch --flake .#nixos-test
"machine-spirit" = nixpkgs.lib.nixosSystem{
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
lix-module.nixosModules.default
disko.nixosModules.disko
./machine-spirit/disk-config.nix
./machine-spirit/configuration.nix
{
nix = {
settings.experimental-features = [ "nix-command" "flakes" ];
};
}
./common/services.nix
home-manager.nixosModules.home-manager {
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jadex = import ./common/home.nix;
}
];
};
"tammy" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
# The Nix module system can modularize configuration,
# improving the maintainability of configuration.
#
# Each parameter in the `modules` is a Nixpkgs Module, and
# there is a partial introduction to it in the nixpkgs manual:
# <https://nixos.org/manual/nixpkgs/unstable/#module-system-introduction>
# It is said to be partial because the documentation is not
# complete, only some simple introductions.
# such is the current state of Nix documentation...
#
# A Nixpkgs Module can be an attribute set, or a function that
# returns an attribute set. By default, if a Nixpkgs Module is a
# function, this function has the following default parameters:
#
# lib: the nixpkgs function library, which provides many
# useful functions for operating Nix expressions:
# https://nixos.org/manual/nixpkgs/stable/#id-1.4
# config: all config options of the current flake, very useful
# options: all options defined in all NixOS Modules
# in the current flake
# pkgs: a collection of all packages defined in nixpkgs,
# plus a set of functions related to packaging.
# you can assume its default value is
# `nixpkgs.legacyPackages."${system}"` for now.
# can be customed by `nixpkgs.pkgs` option
# modulesPath: the default path of nixpkgs's modules folder,
# used to import some extra modules from nixpkgs.
# this parameter is rarely used,
# you can ignore it for now.
#
# The default parameters mentioned above are automatically
# generated by Nixpkgs.
# However, if you need to pass other non-default parameters
# to the submodules,
# you'll have to manually configure these parameters using
# `specialArgs`.
# you must use `specialArgs` by uncommenting the following line:
#
# specialArgs = {...}; # pass custom arguments into all submodules.
modules = [
# Import the configuration.nix here, so that the
# old configuration file can still take effect.
# Note: configuration.nix itself is also a Nixpkgs Module,
./laptop/configuration.nix
./common/services.nix
nixos-hardware.nixosModules.lenovo-thinkpad-t495
home-manager.nixosModules.home-manager {
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.jadex = import ./linux/home.nix;
}
];
};
};
};
}