-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.AGA.nix
560 lines (503 loc) · 21.8 KB
/
flake.AGA.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
{
description = "Flake of Aga on T580";
outputs = inputs@{ self, ... }:
# NOTE that install.sh will replace the username and email by the active one by string replacement
let
# ---- SYSTEM SETTINGS ---- #
systemSettings = {
system = "x86_64-linux"; # system arch
hostname = "nixosaga"; # hostname
profile = "personal"; # select a profile defined from my profiles directory
timezone = "Europe/Warsaw"; # select timezone
locale = "en_US.UTF-8"; # select locale
bootMode = "uefi"; # uefi or bios
bootMountPath = "/boot"; # mount path for efi boot partition; only used for uefi boot mode
grubDevice = ""; # device identifier for grub; only used for legacy (bios) boot mode
gpuType = "intel"; # amd, intel or nvidia; only makes some slight mods for amd at the moment
# Security
doasEnable = false; # for enabling doas
sudoEnable = true; # for enabling sudo
DOASnoPass = false; # for enabling doas without password
wrappSudoToDoas = false; # for wrapping sudo with doas
sudoNOPASSWD = true; # for allowing sudo without password (NOT Recommended, check sudo.md for more info)
sudoCommands = [
{
command = "/run/current-system/sw/bin/systemctl suspend"; # this requires polkit rules to be set
options = [ "NOPASSWD" ];
}
{
command = "/run/current-system/sw/bin/restic";
options = [ "NOPASSWD" "SETENV" ];
}
{
command = "/run/current-system/sw/bin/rsync";
options = [ "NOPASSWD" "SETENV" ];
}
];
pkiCertificates = [ /home/aga/.certificates/ca.cert.pem ];
# Polkit
polkitEnable = true;
polkitRules = ''
polkit.addRule(function(action, subject) {
if (
subject.isInGroup("users") && (
// Allow reboot and power-off actions
action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
action.id == "org.freedesktop.login1.suspend" ||
action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
// Allow managing specific systemd units
(action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("verb") == "start" &&
action.lookup("unit") == "mnt-NFS_Backups.mount") ||
// Allow running rsync and restic
(action.id == "org.freedesktop.policykit.exec" &&
(action.lookup("command") == "/run/current-system/sw/bin/rsync" ||
action.lookup("command") == "/run/current-system/sw/bin/restic"))
)
) {
return polkit.Result.YES;
}
});
'';
# Backups
resticWrapper = true; # for enabling restic wrapper
rsyncWrapper = false; # for enabling rsync wrapper
homeBackupEnable = true; # restic.nix
homeBackupDescription = "Backup Home Directory with Restic";
homeBackupExecStart = "/run/current-system/sw/bin/sh /home/aga/myScripts/agalaptop_backup.sh";
homeBackupUser = "aga";
homeBackupTimerDescription = "Timer for home_backup service";
homeBackupOnCalendar = "0/12:00:00"; # Every 12 hour
homeBackupCallNextEnabled = true; # for calling next service after backup
homeBackupCallNext = [ "remote_backup.service" ]; # service to call after backup
remoteBackupEnable = true; # restic.nix
remoteBackupDescription = "Copy Restic Backup to Remote Server";
remoteBackupExecStart = "/run/current-system/sw/bin/sh /home/aga/myScripts/agalaptop_backup_remote.sh";
remoteBackupUser = "aga";
remoteBackupTimerDescription = "Timer for remote_backup service";
# Network
networkManager = true;
ipAddress = "192.168.0.77"; # ip to be reserved on router by mac (manually)
wifiIpAddress = "192.168.0.78"; # ip to be reserved on router by mac (manually)
defaultGateway = null; # default gateway
nameServers = [ "192.168.8.1" "192.168.8.1" ]; # nameservers / DNS
wifiPowerSave = true; # for enabling wifi power save for laptops
# Firewall
firewall = true;
allowedTCPPorts = [ ];
allowedUDPPorts = [ ];
# LUKS drives
bootSSH = false; # for enabling ssh on boot (to unlock encrypted drives by SSH)
# check drives.nix & drives.org if you need to set your LUKS devices to be opened on boot and automate mounting.
openLUKS = false; # drives.nix
disk1_name = "SAMPLE1";
disk1_path = "/dev/disk/by-uuid/231c229c-SAMPLE1";
disk2_name = "SAMPLE2";
disk2_path = "/dev/disk/by-uuid/04aaf88f-SAMPLE2";
disk3_name = "SAMPLE3";
disk3_path = "/dev/disk/by-uuid/452c53a6-SAMPLE3";
# NFS server settings
nfsServerEnable = false;
nfsExports = ''
/mnt/example 192.168.8.90(rw,sync,insecure,all_squash,anonuid=1000,anongid=1000) 192.168.8.91(rw,sync,insecure,all_squash,anonuid=1000,anongid=1000)
/mnt/example2 192.168.8.90(rw,sync,insecure,all_squash,anonuid=1000,anongid=1000) 192.168.8.91(rw,sync,insecure,all_squash,anonuid=1000,anongid=1000)
'';
# NFS client settings
nfsClientEnable = true;
nfsMounts = [
{
what = "192.168.8.80:/mnt/DATA_4TB/Warehouse/Books";
where = "/mnt/NFS_Books";
type = "nfs";
options = "noatime";
}
{
what = "192.168.8.80:/mnt/DATA_4TB/Warehouse/downloads";
where = "/mnt/NFS_downloads";
type = "nfs";
options = "noatime";
}
{
what = "192.168.8.80:/mnt/DATA_4TB/Warehouse/Media";
where = "/mnt/NFS_Media";
type = "nfs";
options = "noatime";
}
{
what = "192.168.8.80:/mnt/DATA_4TB/backups/AgaLaptop";
where = "/mnt/NFS_Backups";
type = "nfs";
options = "noatime";
}
];
nfsAutoMounts = [
{
where = "/mnt/NFS_Books";
automountConfig = {
TimeoutIdleSec = "600";
};
}
{
where = "/mnt/NFS_Movies";
automountConfig = {
TimeoutIdleSec = "600";
};
}
{
where = "/mnt/NFS_Media";
automountConfig = {
TimeoutIdleSec = "600";
};
}
{
where = "/mnt/NFS_Backups";
automountConfig = {
TimeoutIdleSec = "600";
};
}
];
# SSH System settings for BOOT
authorizedKeys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCfNRaYr4LSuhcXgI97o2cRfW0laPLXg7OzwiSIuV9N7cin0WC1rN1hYi6aSGAhK+Yu/bXQazTegVhQC+COpHE6oVI4fmEsWKfhC53DLNeniut1Zp02xLJppHT0TgI/I2mmBGVkEaExbOadzEayZVL5ryIaVw7Op92aTmCtZ6YJhRV0hU5MhNcW5kbUoayOxqWItDX6ARYQov6qHbfKtxlXAr623GpnqHeH8p9LDX7PJKycDzzlS5e44+S79JMciFPXqCtVgf2Qq9cG72cpuPqAjOSWH/fCgnmrrg6nSPk8rLWOkv4lSRIlZstxc9/Zv/R6JP/jGqER9A3B7/vDmE8e3nFANxc9WTX5TrBTxB4Od75kFsqqiyx9/zhFUGVrP1hJ7MeXwZJBXJIZxtS5phkuQ2qUId9zsCXDA7r0mpUNmSOfhsrTqvnr5O3LLms748rYkXOw8+M/bPBbmw76T40b3+ji2aVZ4p4PY4Zy55YJaROzOyH4GwUom+VzHsAIAJF/Tg1DpgKRklzNsYg9aWANTudE/J545ymv7l2tIRlJYYwYP7On/PC+q1r/Tfja7zAykb3tdUND1CVvSr6CkbFwZdQDyqSGLkybWYw6efVNgmF4yX9nGfOpfVk0hGbkd39lUQCIe3MzVw7U65guXw/ZwXpcS0k1KQ+0NvIo5Z1ahQ== [email protected]" ];
hostKeys = [ "/etc/secrets/initrd/ssh_host_rsa_key" ];
# Printer
servicePrinting = true;
networkPrinters = true;
sharePrinter = false; # for enabling printer sharing
# Intel Network Adapter Power Management
iwlwifiDisablePowerSave = false; # modify iwlwifi power save for Intel Adapter | true = disable power save | false = do nothing
# TLP Power management
TLP_ENABLE = false; # Disable for laptops if you want granular power management with profiles
# TLP Power management
PROFILE_ON_BAT = "performance";
PROFILE_ON_AC = "low-power";
WIFI_PWR_ON_AC = "off"; # Sets Wi-Fi power saving mode. off – disabled saving mode | on – enabled
WIFI_PWR_ON_BAT = "on";
INTEL_GPU_MIN_FREQ_ON_AC = 300; # sudo tlp-stat -g
INTEL_GPU_MIN_FREQ_ON_BAT = 300;
# logind settings
LOGIND_ENABLE = false; # Disable for laptops if you want granular power management with profiles
lidSwitch = "suspend"; # when the lid is closed, do one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", "lock"
lidSwitchExternalPower = "ignore"; # when the lid is closed but connected to power
lidSwitchDocked = "ignore"; # when the lid is closed, and connected to another display
powerKey = "suspend"; # when pressing power key, do one of above
# More Power settings
powerManagement_ENABLE = true; # Enable power management profiles for desktop systems <<<
power-profiles-daemon_ENABLE = true; # Enable power management profiles for desktop systems <<<
# System packages
systemPackages = [
pkgs.vim
pkgs.wget
pkgs.nmap # net tool for port scanning
pkgs.zsh
pkgs.git
pkgs.cryptsetup
pkgs.home-manager
pkgs.wpa_supplicant # for wifi
pkgs.btop
pkgs.fzf
pkgs.tldr
pkgs.rsync
pkgs.nfs-utils
pkgs.restic
# pkgs.atuin
# pkgs.syncthing
# pkgs.pciutils # install if you need some commands like lspci
pkgs.vivaldi # requires patch to be imported + qt5.qtbase
pkgs.qt5.qtbase
#pkgs.pcloud # requires patch to be imported
];
systemStateVersion = "24.05";
# Auto update Settings
autoUpdate = true; # for enabling automatic updates
autoUpdate_dates = "22:30";
autoUpdate_randomizedDelaySec = "45min";
HomeAutoUpdate = false; # enable home manager auto update
HomeAutoUpdate_frecuency = "weekly"; # enable home manager auto update
};
# ----- USER SETTINGS ----- #
userSettings = rec {
username = "aga"; # username
name = "aga"; # name/identifier
email = ""; # email (used for certain configurations)
dotfilesDir = "/home/aga/.dotfiles"; # absolute path of the local repo
extraGroups = [ "networkmanager" "wheel" "input" "dialout" ];
theme = "io"; # selcted theme from my themes directory (./themes/)
wm = "plasma6"; # Selected window manager or desktop environment; must select one in both ./user/wm/ and ./system/wm/
# window manager type (hyprland or x11) translator
wmType = if (wm == "hyprland") then "wayland" else "x11";
dockerEnable = false; # for enabling docker
virtualizationEnable = true; # for enabling virtualization
gitUser = "akunito"; # git username
gitEmail = "[email protected]"; # git email
browser = "vivaldi"; # Default browser; must select one from ./user/app/browser/
defaultRoamDir = "Personal.p"; # Default org roam directory relative to ~/Org
term = "kitty"; # Default terminal command;
font = "Intel One Mono"; # Selected font
fontPkg = pkgs.intel-one-mono; # Font package
# Home-Manager packages
homePackages = [
pkgs.zsh
pkgs.kitty
pkgs.git
pkgs.syncthing
# vivaldi # temporary moved to configuration.nix for issue with plasma 6
# qt5.qtbase
pkgs-unstable.ungoogled-chromium
# pkgs-unstable.vscode
pkgs-unstable.obsidian
pkgs-unstable.spotify
# pkgs-unstable.xournalpp
pkgs-unstable.vlc
pkgs-unstable.candy-icons
pkgs.calibre
pkgs-unstable.libreoffice
pkgs-unstable.telegram-desktop
pkgs-unstable.qbittorrent
pkgs-unstable.nextcloud-client
];
homeStateVersion = "24.05";
editor = "nano"; # Default editor;
# editor spawning translator
# generates a command that can be used to spawn editor inside a gui
# EDITOR and TERM session variables must be set in home.nix or other module
# I set the session variable SPAWNEDITOR to this in my home.nix for convenience
spawnEditor = if (editor == "emacsclient") then
"emacsclient -c -a 'emacs'"
else
(if ((editor == "vim") ||
(editor == "nvim") ||
(editor == "nano")) then
"exec " + term + " -e " + editor
else
editor);
};
# create patched nixpkgs
nixpkgs-patched =
(import inputs.nixpkgs { system = systemSettings.system; rocmSupport = (if systemSettings.gpu == "amd" then true else false); }).applyPatches {
name = "nixpkgs-patched";
src = inputs.nixpkgs;
# patches = [ ./patches/emacs-no-version-check.patch ]; # DISABLING emacs patches??
};
# configure pkgs
# use nixpkgs if running a server (homelab or worklab profile)
# otherwise use patched nixos-unstable nixpkgs
pkgs = (if ((systemSettings.profile == "homelab") || (systemSettings.profile == "worklab") || (systemSettings.profile == "personal"))
then
pkgs-stable
else
(import nixpkgs-patched {
system = systemSettings.system;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
# overlays = [ inputs.rust-overlay.overlays.default ]; # not needed
}));
pkgs-stable = import inputs.nixpkgs-stable {
system = systemSettings.system;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
pkgs-unstable = import inputs.nixpkgs {
system = systemSettings.system;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
# pkgs-emacs = import inputs.emacs-pin-nixpkgs {
# system = systemSettings.system;
# };
# pkgs-kdenlive = import inputs.kdenlive-pin-nixpkgs {
# system = systemSettings.system;
# };
# pkgs-nwg-dock-hyprland = import inputs.nwg-dock-hyprland-pin-nixpkgs {
# system = systemSettings.system;
# };
# configure lib
# use nixpkgs if running a server (homelab or worklab profile)
# otherwise use patched nixos-unstable nixpkgs
lib = (if ((systemSettings.profile == "homelab") || (systemSettings.profile == "worklab") || (systemSettings.profile == "personal")) # PERSONAL AS WELL
then
inputs.nixpkgs-stable.lib
else
inputs.nixpkgs.lib);
# use home-manager-stable if running a server (homelab or worklab profile)
# otherwise use home-manager-unstable
# home-manager = (if ((systemSettings.profile == "homelab") || (systemSettings.profile == "worklab"))
# then
# inputs.home-manager-stable
# else
# inputs.home-manager-unstable);
home-manager = inputs.home-manager-stable; # Overriding home-manager logic to force stable
# Systems that can run tests:
supportedSystems = [ "aarch64-linux" "i686-linux" "x86_64-linux" ];
# Function to generate a set based on supported systems:
forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
# Attribute set of nixpkgs for each system:
nixpkgsFor =
forAllSystems (system: import inputs.nixpkgs { inherit system; });
in {
homeConfigurations = {
# Home Manager configuration for the main
user = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
(./. + "/profiles" + ("/" + systemSettings.profile) + "/home.nix") # load home.nix from selected PROFILE
];
extraSpecialArgs = {
# pass config variables from above
inherit pkgs-stable;
# inherit pkgs-emacs;
# inherit pkgs-kdenlive;
# inherit pkgs-nwg-dock-hyprland;
inherit systemSettings;
inherit userSettings;
inherit inputs;
};
};
};
nixosConfigurations = {
system = lib.nixosSystem {
system = systemSettings.system;
modules = [
(./. + "/profiles" + ("/" + systemSettings.profile) + "/configuration.nix")
./system/bin/phoenix.nix
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t590
]; # load configuration.nix from selected PROFILE
specialArgs = {
# pass config variables from above
inherit pkgs-stable;
inherit systemSettings;
inherit userSettings;
inherit inputs;
};
};
};
# nixOnDroidConfigurations = {
# inherit pkgs;
# default = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
# modules = [ ./profiles/nix-on-droid/configuration.nix ];
# };
# extraSpecialArgs = {
# # pass config variables from above
# inherit pkgs-stable;
# # inherit pkgs-emacs;
# inherit systemSettings;
# inherit userSettings;
# inherit inputs;
# };
# };
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
default = self.packages.${system}.install;
install = pkgs.writeShellApplication {
name = "install";
runtimeInputs = with pkgs; [ git ]; # I could make this fancier by adding other deps
text = ''${./install.sh} "$@"'';
};
});
apps = forAllSystems (system: {
default = self.apps.${system}.install;
install = {
type = "app";
program = "${self.packages.${system}.install}/bin/install";
};
});
};
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-stable.url = "nixpkgs/nixos-24.11";
# emacs-pin-nixpkgs.url = "nixpkgs/f72123158996b8d4449de481897d855bc47c7bf6";
# kdenlive-pin-nixpkgs.url = "nixpkgs/cfec6d9203a461d9d698d8a60ef003cac6d0da94";
# nwg-dock-hyprland-pin-nixpkgs.url = "nixpkgs/2098d845d76f8a21ae4fe12ed7c7df49098d3f15";
home-manager-unstable.url = "github:nix-community/home-manager/master";
home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
home-manager-stable.url = "github:nix-community/home-manager/release-24.11";
home-manager-stable.inputs.nixpkgs.follows = "nixpkgs-stable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; # additional settings for specific hardware
# nix-on-droid = {
# url = "github:nix-community/nix-on-droid/master";
# inputs.nixpkgs.follows = "nixpkgs";
# inputs.home-manager.follows = "home-manager-unstable";
# };
# hyprland = {
# type = "git";
# url = "https://github.com/hyprwm/Hyprland";
# submodules = true;
# rev = "918d8340afd652b011b937d29d5eea0be08467f5";
# };
# hyprland.inputs.nixpkgs.follows = "nixpkgs";
# hyprland-plugins.url = "github:hyprwm/hyprland-plugins/3ae670253a5a3ae1e3a3104fb732a8c990a31487";
# hyprland-plugins.inputs.hyprland.follows = "hyprland";
# hycov.url = "github:DreamMaoMao/hycov/de15cdd6bf2e46cbc69735307f340b57e2ce3dd0";
# hycov.inputs.hyprland.follows = "hyprland";
# hyprgrass.url = "github:horriblename/hyprgrass/736119f828eecaed2deaae1d6ff1f50d6dabaaba";
# hyprgrass.inputs.hyprland.follows = "hyprland";
# nix-doom-emacs.url = "github:nix-community/nix-doom-emacs";
# nix-doom-emacs.inputs.nixpkgs.follows = "emacs-pin-nixpkgs";
# nix-straight.url = "github:librephoenix/nix-straight.el/pgtk-patch";
# nix-straight.flake = false;
# nix-doom-emacs.inputs.nix-straight.follows = "nix-straight";
# eaf = {
# url = "github:emacs-eaf/emacs-application-framework";
# flake = false;
# };
# eaf-browser = {
# url = "github:emacs-eaf/eaf-browser";
# flake = false;
# };
# org-nursery = {
# url = "github:chrisbarrett/nursery";
# flake = false;
# };
# org-yaap = {
# url = "gitlab:tygrdev/org-yaap";
# flake = false;
# };
# org-side-tree = {
# url = "github:localauthor/org-side-tree";
# flake = false;
# };
# org-timeblock = {
# url = "github:ichernyshovvv/org-timeblock";
# flake = false;
# };
# org-krita = {
# url = "github:librephoenix/org-krita";
# flake = false;
# };
# org-xournalpp = {
# url = "gitlab:vherrmann/org-xournalpp";
# flake = false;
# };
# org-sliced-images = {
# url = "github:jcfk/org-sliced-images";
# flake = false;
# };
# magit-file-icons = {
# url = "github:librephoenix/magit-file-icons/abstract-icon-getters-compat";
# flake = false;
# };
# phscroll = {
# url = "github:misohena/phscroll";
# flake = false;
# };
# mini-frame = {
# url = "github:muffinmad/emacs-mini-frame";
# flake = false;
# };
# stylix.url = "github:danth/stylix";
# rust-overlay.url = "github:oxalica/rust-overlay";
blocklist-hosts = {
url = "github:StevenBlack/hosts";
flake = false;
};
};
}