-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
235 lines (200 loc) · 7.14 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
{
description = "Shinzui's dotfiles";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
darwin = {
url = "github:LnL7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
flake-utils.url = "github:numtide/flake-utils";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
nix-neovimplugins = { url = "github:jooooscha/nixpkgs-vim-extra-plugins"; };
moses-lua = { url = "github:Yonaba/Moses"; flake = false; };
vim-rescript = { url = "github:rescript-lang/vim-rescript"; flake = false; };
vim-reasonml = { url = "github:jordwalke/vim-reasonml"; flake = false; };
};
outputs =
{ self
, nixpkgs
, nixpkgs-unstable
, darwin
, home-manager
, flake-utils
, agenix
, nix-neovimplugins
, ...
}@inputs:
let
# Building blocks
inherit (darwin.lib) darwinSystem;
inherit (inputs.nixpkgs-unstable.lib) attrValues makeOverridable optionalAttrs singleton;
# d = (import ./darwin) { pkgs=nixpkgs-unstable; inherit nixpkgs-unstable; };
# Configuration for `nixpkgs` mostly used in personal configs.
nixpkgsConfig = {
config = { allowUnfree = true; };
overlays = attrValues self.overlays;
};
# Personal configuration shared between `nix-darwin` and plain `home-manager` configs.
# This value determines the Home Manager release that your configuration is compatible with. This
# helps avoid breakage when a new Home Manager release introduces backwards incompatible changes.
#
# You can update Home Manager without changing this value. See the Home Manager release notes for
# a list of state version changes in each release.
homeManagerStateVersion = "23.05";
homeManagerCommonConfig = with self.homeManagerModules; {
imports = attrValues self.homeManagerModules ++ [
./home
{ home.stateVersion = homeManagerStateVersion; }
];
};
nixDarwinCommonModules = [
{
config._module.args = {
inherit nixpkgs-unstable;
};
}
# Include extra `nix-darwin`
self.darwinModules.pam
self.darwinModules.users
agenix.darwinModules.default
# Main `nix-darwin` config
./darwin
# `home-manager` module
home-manager.darwinModules.home-manager
(
{ config, lib, pkgs, ... }:
let
inherit (config.users) primaryUser;
in
{
nixpkgs = nixpkgsConfig;
# Hack to support legacy worklows that use `<nixpkgs>` etc.
nix.nixPath = { nixpkgs = "$HOME/.config/dotfiles.nix/nixpkgs.nix"; };
# `home-manager` config
users.users.${primaryUser}.home = "/Users/${primaryUser}";
home-manager.useGlobalPkgs = true;
home-manager.users.${primaryUser} = homeManagerCommonConfig;
home-manager.extraSpecialArgs = {
inherit (config) age;
};
# Add a registry entry for this flake
nix.registry.my.flake = self;
nix.registry.nixpkgs.flake = nixpkgs-unstable;
}
)
];
in
{
#Various configs (only Sungkyung for now)
#nix-darwin configs
darwinConfigurations = rec {
# Mininal configurations to bootstrap systems
bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin";
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
};
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
#MacBook Pro M1X
SungkyungM1X = darwinSystem {
system = "aarch64-darwin";
modules = nixDarwinCommonModules ++ [
{
users.primaryUser = "shinzui";
networking.computerName = "sungkyung";
networking.hostName = "sungkyung";
#networksetup -listallnetworkservices
networking.knownNetworkServices = [
"Wi-Fi"
"Thunderbolt Bridge"
];
}
];
};
};
#
# Outputs ---
overlays = {
nix-neovimplugins = nix-neovimplugins.overlays.default;
pkgs-master = final: prev: {
pkgs-master = import inputs.nixpkgs {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-stable = final: prev: {
pkgs-stable = import inputs.nixpkgs-stable {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-unstable = final: prev: {
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
overlays = [ ];
};
};
# Overlay that adds various additional utility functions to `vimUtils`
vimUtils = import ./overlays/vimUtils.nix;
# Overlay that adds some additional Neovim plugins
vimPlugins = final: prev:
let
inherit (self.overlays.vimUtils final prev) vimUtils;
in
{
vimPlugins = prev.vimPlugins.extend (super: self:
(vimUtils.buildVimPluginsFromFlakeInputs inputs [
"vim-rescript"
"vim-reasonml"
]) // {
moses-nvim = vimUtils.buildNeovimLuaPackagePluginFromFlakeInput inputs "moses-lua";
}
);
};
# Overlay useful on Macs with Apple Silicon
apple-silicon = final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs-unstable {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
};
};
};
darwinModules = {
users = import ./modules/darwin/users.nix;
pam = import ./modules/darwin/pam.nix;
};
homeManagerModules = {
configs-git-aliases = import ./home/config/git-aliases.nix;
configs-gh-aliases = import ./home/config/gh-aliases.nix;
configs-wezterm = import ./home/wezterm.nix;
configs-starship-symbols = import ./home/config/starship-symbols.nix;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
legacyPackages = import inputs.nixpkgs-unstable {
inherit system;
inherit (nixpkgsConfig) config;
overlays = with self.overlays; [
pkgs-master
pkgs-stable
apple-silicon
];
};
pkgs = legacyPackages;
agenix = inputs.agenix;
in
{
devShell = import ./shell.nix { inherit pkgs system agenix; };
});
}
# vim: foldmethod=marker