-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
206 lines (185 loc) · 6.94 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
{
description = "Multi-platform Nix flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.11-darwin";
nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-darwin = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
# Provide firefox overlay to workaround broken Darwin package
nixpkgs-firefox-darwin.url = "github:bandithedoge/nixpkgs-firefox-darwin";
firefox-addons = {
url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland = {
url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland-plugins = {
url = "github:hyprwm/hyprland-plugins";
inputs.hyprland.follows = "hyprland";
};
hyprcursor.url = "github:hyprwm/hyprcursor";
nixvim.url = "github:pete3n/nixvim-flake";
deploy-rs.url = "github:serokell/deploy-rs";
};
outputs =
{
home-manager,
home-manager-darwin,
nixpkgs,
nixpkgs-darwin,
nix-darwin,
self,
...
}@inputs:
# @inputs because we need to pass both inputs and outputs to our
# configurations
let
outputs = self.outputs; # Could be writting as 'inherit (self) outputs' but
# this is more clear. We need to include outputs because we reference our
# own outputs in our outputs
# This is a workaround to allow passing a specified user, host, and
# target system to the flake, which will pass this to the output
# configurations to build them appropriately
build_target = import ./build-target.nix { };
# Supported systems for flake packages, shells, etc.
supportedSystems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
# This is a function to generate an attribute set for each of the
# systems in the supportedSystems list
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
# Custom locally defined packages from the ./packages directory
# Accessible through 'nix build', 'nix shell', etc
# The forAllSystems function will create a packages output for each
# system in supportedSystems, so you can run:
# 'nix build .#packages.aarch64-darwin.yubioath-darwin' etc.
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
localPackages = import ./packages/cross-platform {
inherit system pkgs;
config = {
allowUnfree = true;
};
};
# These packages only support Linux so they are excluded
# for non-Linux build targets, this prevents errors when evaluating
# the flake
localLinuxPackages =
if build_target.isLinux then
import ./packages/linux {
inherit system pkgs;
config = {
allowUnfree = true;
};
}
else
{ };
# These packages only support Darwin so they are excluded
# for non-Darwin build targets
localDarwinPackages =
if !build_target.isLinux then
import ./packages/darwin {
inherit system pkgs;
config = {
allowUnfree = true;
};
}
else
{ };
in
# Combine our local cross-platform packages with the appropriate
# Linux-only or Darwin-only local packages depending on the build target
pkgs.lib.recursiveUpdate localPackages (
if build_target.isLinux then localLinuxPackages else localDarwinPackages
)
);
# Formatter for nix files, available through 'nix fmt'
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
# Flake wide overlays accessible though ouputs.overlays
overlays = import ./overlays { inherit inputs build_target; };
# Provide an easy import for all home-manager modules to each configuration
homeManagerModules = import ./modules/home-manager;
# Provide an import for all nixos system modules to each configuration
nixosModules = import ./modules;
# User defintions for the system (careful these create/overwrite users)
systemUsers = import ./users;
# System configuration for Linux based systems
nixosConfigurations =
if build_target.isLinux then
{
"${build_target.host}" = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs build_target;
};
modules = [
./hosts/${build_target.host}/configuration.nix
./users/linux/linux-${build_target.user}.nix
];
};
}
else
{ };
# System configuration for Darwin based systems
darwinConfigurations =
if !build_target.isLinux then
{
"${build_target.host}" = nix-darwin.lib.darwinSystem {
specialArgs = {
inherit inputs outputs build_target;
};
modules = [
./hosts/${build_target.host}/nix-core.nix
./hosts/${build_target.host}/system.nix
./hosts/${build_target.host}/apps.nix
./users/darwin/darwin-${build_target.user}.nix
];
};
}
else
{ };
homeConfigurations =
if build_target.isLinux then
{
# Home-manager configuration for Linux based systems
"${build_target.user}@${build_target.host}" = home-manager.lib.homeManagerConfiguration {
# Home-manager requires 'pkgs' instance to be manually specified
pkgs = nixpkgs.legacyPackages.${build_target.system};
extraSpecialArgs = {
inherit inputs outputs build_target;
};
modules = [ ./home-manager/${build_target.user}/linux-home.nix ];
};
}
else
{
# Home-manager configuration for Darwin based systems
"${build_target.user}@${build_target.host}" = home-manager-darwin.lib.homeManagerConfiguration {
pkgs = nixpkgs-darwin.legacyPackages.${build_target.system};
extraSpecialArgs = {
inherit inputs outputs build_target;
};
modules = [ ./home-manager/${build_target.user}/darwin-home.nix ];
};
};
};
}