-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
216 lines (202 loc) · 7.47 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
{
inputs = {
# I rely on unstable as I prefer the interface and many of the packages I use also rely on it.
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# This gives me access to the cosmic desktop environment from System76. Eventually this will be replaced by a nixpkgs pkg
# or a System76 official one.
nixos-cosmic = {
url = "github:lilyinstarlight/nixos-cosmic";
inputs.nixpkgs.follows = "nixpkgs";
};
# How I manage the home directories for the users on every one of my machines.
# TODO: Allow for aliases for users to allow it to work on machines that I have less control over
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
# The tools I leverage to use the most recent versions of wlroots that haven't made it to nixpkgs yet.
# TODO: Do I really need this anymore? I might go back to Hyprland or Sway eventually but right now they just
# don't play nicely with my NVIDIA GPU
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
# A set of packages for rust and rust associated tooling.
# TODO: Should I be using an overlay on this? Is that dangerous?
fenix = {
url = "github:andresilva/fenix/fix-platforms";
inputs.nixpkgs.follows = "nixpkgs";
};
# This makes my mac play nicely with Nix so I can manage all my mac dependencies with nix as well.
# TODO: Check and see whether or not there are workarounds to get things that don't work on mac onto mac anyway.
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
# Eventually the plan is to use this to have a declarative definition of my talon set-up that can be used on any machine
# I use. In particular, I'd like for this to play nicely with crafting my own talon files but also pull down community talon
# files.
talon-nix = {
url = "github:ProfDoof/talon-nix/no_desktop_file";
inputs.nixpkgs.follows = "nixpkgs";
};
# An absolute necessity for my mac apps. This generates trampoline files in the Apps directories for my Nix mac apps
# that are then indexed by spotlight. Without this, spotlight can't see the nix apps and I can't launch them from spotlight
mac-app-util = {
url = "github:hraban/mac-app-util";
};
# A tool to allow me to generate appropriate dev-shells for working on my dotfiles for most systems.
flake-utils = {
url = "github:numtide/flake-utils";
};
# Formatter library
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Extended VSCode Extensions input.
nix-vscode-extensions = {
url = "github:nix-community/nix-vscode-extensions";
inputs.nixpkgs.follows = "nixpkgs";
};
firefox-darwin = {
url = "github:bandithedoge/nixpkgs-firefox-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-alien.url = "github:thiagokokada/nix-alien";
};
outputs =
{
self,
nixpkgs,
nixos-cosmic,
home-manager,
nixpkgs-wayland,
fenix,
nix-darwin,
mac-app-util,
flake-utils,
treefmt-nix,
nix-vscode-extensions,
talon-nix,
firefox-darwin,
...
}@inputs:
let
dotlib = import ./lib/default.nix inputs;
# Eventually the common modules, darwin modules, and nixos modules, I think I would like broken out into their own files
# and then I want to somehow just add requirements to the modules to specify that they are only for NixOS or only for
# Darwin, or only for Home-Manager. However, I need to understand the module system better for that. I'm currently
# thinking that the way to go might be something like a module option that allows a host to specify the OS they expect
# to be running. Then, the modules can opt-in or out to being included. After that, the system can create the correct
# type of configuration. Whether that be a Darwin Config, a Nixos Config, or a Home Manager Config.
commonModules = dotlib.common.modules;
darwinModules = commonModules ++ [
./os/darwin.nix
talon-nix.darwinModules.default
mac-app-util.darwinModules.default
# I'd really like this to be a bit dryer in conjuction with the nixosModules version of this code down below.
# It just feels weird that I have basically the same code except for a couple of specific details.
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.sharedModules = [ mac-app-util.homeManagerModules.default ];
home-manager.users.john.imports = [
./users/john/darwin.nix
./private/users/john/darwin.nix
];
users.users.john.home = "/Users/john";
}
(
{ pkgs, config, ... }:
{
config.nixpkgs.overlays = [
firefox-darwin.overlay
];
}
)
];
nixOsModules = commonModules ++ [
./os/nixos.nix
talon-nix.nixosModules.default
nixos-cosmic.nixosModules.default
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.john.imports = [
./users/john/nixos.nix
./private/users/john/nixos.nix
];
}
(
{
self,
system,
pkgs,
config,
...
}:
{
environment.systemPackages = with self.inputs.nix-alien.packages.${system}; [
nix-alien
];
# Optional, needed for `nix-alien-ld`
programs.nix-ld.enable = true;
nixpkgs.overlays = [
nixpkgs-wayland.overlay
];
}
)
];
# Ideally this will turn into a helper function for a more feature complete function.
getHosts = dotlib.common.getHosts [
./hosts
./private/hosts
];
in
{
nixosConfigurations =
nixpkgs.lib.mapAttrs
# One thing to consider in the future is whether I want to also pass in the inputs so that my
# modules can leverage the info those bring in.
(
_: hostModules:
nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = { inherit self system; };
modules = hostModules ++ nixOsModules;
}
)
(getHosts "nixos");
darwinConfigurations = nixpkgs.lib.mapAttrs (
_: hostModules:
nix-darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = hostModules ++ darwinModules;
}
) (getHosts "darwin");
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
treefmtWrapper = treefmt-nix.lib.mkWrapper pkgs ./treefmt.nix;
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
nil
bashInteractive
python3
pipx
ruff
];
};
formatter = treefmtWrapper;
}
);
}