-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
214 lines (197 loc) · 5.66 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
{
description = "Home Manager configuration of symph";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-wsl.url = "github:nix-community/nixos-wsl";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-update = {
url = "github:nix-community/nixpkgs-update";
};
catppuccin.url = "github:catppuccin/nix";
# Neovim
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, home-manager, ... }@inputs:
let
lib = nixpkgs.lib;
mkGetDefault =
attr: key: default:
let
path = lib.strings.splitString "." key;
in
if lib.attrsets.hasAttrByPath path attr then lib.attrsets.getAttrFromPath path attr else default;
mkMy =
{
settings ? { },
profile ? { },
}:
let
passedProfile = profile;
in
rec {
name = "symph";
fullName = "SymphonySimper";
dir = {
home = "/home/${name}";
dev = "${dir.home}/lifeisfun";
data = "${dir.home}/importantnt";
};
profile = mkGetDefault passedProfile "name" "default";
system = mkGetDefault passedProfile "system" "x86_64-linux";
gui = {
enable = mkGetDefault settings "gui.enable" false;
desktop = {
enable = mkGetDefault settings "gui.desktop.enable" false;
type = mkGetDefault settings "gui.desktop.type" "wm"; # wm or de
wm = gui.desktop.type == "wm";
};
display = {
name = mkGetDefault settings "gui.display.name" "eDP-1";
scale = mkGetDefault settings "gui.display.scale" 1;
width = mkGetDefault settings "gui.display.width" 1920;
height = mkGetDefault settings "gui.display.height" 1080;
refreshRate = mkGetDefault settings "gui.display.refreshRate" 60;
};
};
theme = {
dark = mkGetDefault settings "theme.dark" false;
flavor = if theme.dark then "mocha" else "latte";
color = (import ./assets/colors.nix { flavor = theme.flavor; });
gtk = if theme.dark then "Adwaita-dark" else "Adwaita";
wallpaper = "${dir.home}/.dotfiles/assets/images/bg.png";
font = {
sans = "Poppins";
mono = "JetBrainsMono Nerd Font";
glyph = "Font Awesome 6 Free";
};
};
programs = {
terminal = "alacritty";
editor = "nvim";
multiplexer = "tmux";
browser = "chromium";
launcher = "wofi";
notification = "dunst";
music = "yt";
video = "mpv";
pdf = "zathura";
image = "loupe";
};
};
mkProfile =
{
name,
settings ? { },
profile ? { },
for, # system or home
}:
let
my = mkMy {
inherit settings;
profile = profile // {
inherit name;
};
};
pkgs = import nixpkgs {
system = my.system;
config.allowUnfree = true;
overlays =
[
(import ./overlays/lib.nix { inherit my; })
]
++ (lib.optionals (for == "home") [
# (import ./overlays/nvim-plugins.nix { inherit inputs; })
]);
};
modules =
[
./profiles/${my.profile}/${for}.nix
]
++ (lib.optionals (for == "home") [
inputs.nixvim.homeManagerModules.nixvim
]);
specialArgs = {
inherit my;
inherit inputs;
};
in
if for == "home" then
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
inherit modules;
lib = pkgs.lib;
extraSpecialArgs = specialArgs;
}
else
lib.nixosSystem {
inherit pkgs;
inherit modules;
inherit specialArgs;
lib = pkgs.lib;
system = my.system;
};
mkProfiles =
profiles: for:
builtins.listToAttrs (
map (
profile:
if builtins.elem for profile.for then
rec {
name = profile.name;
value = mkProfile {
inherit for;
inherit name;
settings = profile.settings;
profile = mkGetDefault profile "profile" { };
};
}
else
null
) profiles
);
profiles = [
{
name = "wsl";
for = [
"system"
"home"
];
}
{
name = "gui";
for = [
"system"
"home"
];
settings = {
gui = {
enable = true;
desktop.enable = true;
display = {
name = "eDP-1";
scale = 1.8;
width = 2880;
height = 1800;
refreshRate = 60;
};
};
};
}
];
in
{
homeConfigurations = mkProfiles profiles "home";
nixosConfigurations = mkProfiles profiles "system";
};
}