Compare commits

..

No commits in common. "575e6ae979f4ad10735e6fcaba9e42790960726d" and "e79a5d7cde768a3690e448758e7bae5966eba52b" have entirely different histories.

33 changed files with 587 additions and 397 deletions

View file

@ -1,5 +1,15 @@
{pkgs, ...}: { {
# TODO: Only apply this to workstations osConfig,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
devType = osConfig.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem devType acceptedTypes) {
home.packages = with pkgs; [ home.packages = with pkgs; [
libnotify # send desktop notifications libnotify # send desktop notifications
imagemagick # create/edit images imagemagick # create/edit images
@ -12,4 +22,5 @@
glow # render markdown glow # render markdown
ffmpeg # record, convert and stream audio and video ffmpeg # record, convert and stream audio and video
]; ];
};
} }

View file

@ -1,3 +0,0 @@
{pkgs, ...}: {
home.packages = with pkgs; [ninja];
}

View file

@ -1,6 +1,5 @@
{ {
imports = [ imports = [
./python ./python
./cpp.nix
]; ];
} }

View file

@ -33,7 +33,6 @@
nixd nixd
emmet-language-server emmet-language-server
vscode-langservers-extracted vscode-langservers-extracted
kotlin-language-server
# Linters / formatters # Linters / formatters
stylua stylua
@ -50,7 +49,6 @@
alejandra alejandra
deadnix deadnix
statix statix
ktlint
# Other tools / utilities # Other tools / utilities
ripgrep ripgrep

View file

@ -4,14 +4,10 @@
# A list of shared modules that ALL systems need # A list of shared modules that ALL systems need
shared = [ shared = [
../system/shared ../system
../home ../home
../options ../options
]; ];
workstationRole = ../system/roles/workstation;
laptopRole = ../system/roles/laptop;
uniRole = ../system/roles/uni;
in { in {
herugrim = lib.nixosSystem { herugrim = lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
@ -22,8 +18,6 @@ in {
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
inputs.impermanence.nixosModules.impermanence inputs.impermanence.nixosModules.impermanence
inputs.lanzaboote.nixosModules.lanzaboote inputs.lanzaboote.nixosModules.lanzaboote
workstationRole
laptopRole
] ]
++ shared; ++ shared;
}; };
@ -37,9 +31,6 @@ in {
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
inputs.impermanence.nixosModules.impermanence inputs.impermanence.nixosModules.impermanence
inputs.lanzaboote.nixosModules.lanzaboote inputs.lanzaboote.nixosModules.lanzaboote
workstationRole
laptopRole
uniRole
] ]
++ shared; ++ shared;
}; };

View file

@ -98,11 +98,6 @@
".local/share/cargo" ".local/share/cargo"
".local/share/go" ".local/share/go"
".config/rye" ".config/rye"
# University crap
"Android/Sdk"
"AndroidStudioProjects"
".android"
]; ];
extraFiles = [ extraFiles = [
".config/gtk-3.0/bookmarks" ".config/gtk-3.0/bookmarks"
@ -143,7 +138,10 @@
}; };
device = { device = {
roles.virtual-machine = false; roles = {
type = "laptop";
virtual-machine = false;
};
cpu.type = "amd"; cpu.type = "amd";
gpu.type = "amd"; gpu.type = "amd";
hasTPM = true; hasTPM = true;
@ -184,10 +182,10 @@
"eDP-1, 1920x1200@60, 0x1080, 1" "eDP-1, 1920x1200@60, 0x1080, 1"
# HDMI-A-1 above primary # HDMI-A-1 above primary
#"HDMI-A-1, 1920x1080@60, 0x0, 1" "HDMI-A-1, 1920x1080@60, 0x0, 1"
# HDMI-A-1 left to primary # HDMI-A-1 left to primary
"HDMI-A-1, 1920x1080@60, 1920x1080, 1" #"HDMI-A-1, 1920x1080@60, 1920x1080, 1"
# Mirror the primary (laptop) monitor on externals # Mirror the primary (laptop) monitor on externals
", preferred, auto, 1, mirror, eDP-1" ", preferred, auto, 1, mirror, eDP-1"

View file

@ -1,11 +1,39 @@
{lib, ...}: let {
inherit (lib) mkOption; lib,
config,
...
}: let
inherit (lib) mkOption types;
cfg = config.myOptions.device.roles;
in { in {
options.myOptions.device.roles = { options.myOptions.device.roles = {
type = mkOption {
type = types.enum ["laptop" "desktop" "server"];
default = "";
description = ''
The type/purpoes of the device that will be used within the rest of the configuration.
- laptop: portable devices with battery optimizations
- desktop: stationary devices configured for maximum performance
- server: server and infrastructure
'';
};
virtual-machine = mkOption { virtual-machine = mkOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Is this system a virtual machine?"; description = "Is this system a virtual machine?";
}; };
isWorkstation = mkOption {
type = lib.types.bool;
default = builtins.elem cfg.type ["laptop" "desktop"];
readOnly = true;
description = ''
Is this machine a workstation?
Workstation machines are meant for regular day-to-day use.
'';
};
}; };
} }

11
system/roles/default.nix Normal file
View file

@ -0,0 +1,11 @@
{
# We import all of the roles here, with the type checks being handled
# in the individual files each time. This is a bit ugly, but necessary
# as NixOS doesn't support optional imports, due to circual imports
# (there might be a change of the config value inside one of the
# imported files).
imports = [
./workstation
./laptop
];
}

View file

@ -1,8 +1,14 @@
{ {
pkgs, pkgs,
lib,
config, config,
... ...
}: { }: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
hardware.acpilight.enable = true; hardware.acpilight.enable = true;
environment.systemPackages = with pkgs; [acpi]; environment.systemPackages = with pkgs; [acpi];
@ -17,4 +23,5 @@
cpupower cpupower
]; ];
}; };
};
} }

View file

@ -1,4 +1,13 @@
{pkgs, ...}: { {
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop"];
in {
imports = [ imports = [
./power-profiles-daemon ./power-profiles-daemon
./upower.nix ./upower.nix
@ -6,7 +15,7 @@
./systemd.nix ./systemd.nix
]; ];
config = { config = mkIf (builtins.elem deviceType acceptedTypes) {
environment.systemPackages = with pkgs; [powertop]; environment.systemPackages = with pkgs; [powertop];
}; };
} }

View file

@ -1,11 +1,16 @@
{ {
pkgs, pkgs,
lib, lib,
config,
... ...
}: let }: let
inherit (lib) mkIf;
inherit (lib.modules) mkForce; inherit (lib.modules) mkForce;
inherit (lib.strings) makeBinPath; inherit (lib.strings) makeBinPath;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop"];
in { in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# allows changing system behavior based upon user-selected power profiles # allows changing system behavior based upon user-selected power profiles
# (with `powerprofilesctl` command) # (with `powerprofilesctl` command)
services.power-profiles-daemon.enable = true; services.power-profiles-daemon.enable = true;
@ -34,4 +39,5 @@ in {
wants = ["power-profiles-daemon.service"]; wants = ["power-profiles-daemon.service"];
wantedBy = ["default.target"]; wantedBy = ["default.target"];
}; };
};
} }

View file

@ -1,4 +1,14 @@
{ {
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services = { services = {
# DBus service that provides power management support to applications # DBus service that provides power management support to applications
upower = { upower = {
@ -9,4 +19,5 @@
criticalPowerAction = "Hibernate"; criticalPowerAction = "Hibernate";
}; };
}; };
};
} }

View file

@ -1,4 +1,13 @@
{ {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services.libinput = { services.libinput = {
# enable libinput # enable libinput
enable = true; enable = true;
@ -19,4 +28,5 @@
disableWhileTyping = true; disableWhileTyping = true;
}; };
}; };
};
} }

View file

@ -1,3 +0,0 @@
{pkgs, ...}: {
environment.systemPackages = [pkgs.android-studio];
}

View file

@ -1,5 +0,0 @@
{
imports = [
./android.nix
];
}

View file

@ -4,9 +4,12 @@
lib, lib,
... ...
}: let }: let
inherit (lib) getExe; inherit (lib) mkIf getExe;
inherit (lib.strings) concatStringsSep; inherit (lib.strings) concatStringsSep;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
greetingMsg = "'Access is restricted to authorized personnel only.'"; greetingMsg = "'Access is restricted to authorized personnel only.'";
tuiGreetTheme = "'border=magenta;text=cyan;prompt=green;time=red;action=white;button=yellow;container=black;input=gray'"; tuiGreetTheme = "'border=magenta;text=cyan;prompt=green;time=red;action=white;button=yellow;container=black;input=gray'";
@ -43,6 +46,7 @@
]; ];
}; };
in { in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services.greetd = { services.greetd = {
enable = true; enable = true;
vt = 1; vt = 1;
@ -70,4 +74,5 @@ in {
# Persist info about previous session & user # Persist info about previous session & user
myOptions.system.impermanence.root.extraDirectories = ["/var/cache/tuigreet"]; myOptions.system.impermanence.root.extraDirectories = ["/var/cache/tuigreet"];
};
} }

View file

@ -1,4 +1,13 @@
{ {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# unlock GPG keyring on login # unlock GPG keyring on login
security.pam.services = let security.pam.services = let
gnupg = { gnupg = {
@ -22,4 +31,5 @@
inherit gnupg; inherit gnupg;
}; };
}; };
};
} }

View file

@ -1,4 +1,14 @@
{pkgs, ...}: { {
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
fonts = { fonts = {
enableDefaultPackages = false; enableDefaultPackages = false;
@ -106,4 +116,5 @@
# Tool for searching and previewing installed fonts # Tool for searching and previewing installed fonts
font-manager font-manager
]; ];
};
} }

View file

@ -1,4 +1,13 @@
{ {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
programs = { programs = {
# allow non-root users to mount fuse filesystems with allow_other # allow non-root users to mount fuse filesystems with allow_other
fuse.userAllowOther = true; fuse.userAllowOther = true;
@ -15,4 +24,5 @@
# registry for linux (thanks to Gnome) # registry for linux (thanks to Gnome)
dconf.enable = true; dconf.enable = true;
}; };
};
} }

View file

@ -1,4 +1,13 @@
{ {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# Screen locker which works across all virtual terminals # Screen locker which works across all virtual terminals
# Use `systemctl start physlock` to securely lock the screen # Use `systemctl start physlock` to securely lock the screen
services.physlock = { services.physlock = {
@ -14,4 +23,5 @@
hibernate = true; hibernate = true;
}; };
}; };
};
} }

View file

@ -5,8 +5,10 @@
}: let }: let
inherit (lib) mkIf; inherit (lib) mkIf;
cfg = config.myOptions.home-manager.programs.games.steam; cfg = config.myOptions.home-manager.programs.games.steam;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in { in {
config = mkIf cfg.enable { config = mkIf ((builtins.elem deviceType acceptedTypes) && cfg.enable) {
programs.steam = { programs.steam = {
enable = true; enable = true;
remotePlay.openFirewall = false; remotePlay.openFirewall = false;

View file

@ -1,4 +1,14 @@
{pkgs, ...}: { {
lib,
pkgs,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# Unconditionally enable thunar file manager here as a relatively # Unconditionally enable thunar file manager here as a relatively
# lightweight fallback option for my default file manager. # lightweight fallback option for my default file manager.
programs.thunar = { programs.thunar = {
@ -22,4 +32,5 @@
# thumbnail support on thunar # thumbnail support on thunar
services.tumbler.enable = true; services.tumbler.enable = true;
};
} }

View file

@ -6,8 +6,10 @@
inherit (lib) mkIf; inherit (lib) mkIf;
cfgUser = config.myOptions.system.username; cfgUser = config.myOptions.system.username;
cfg = config.myOptions.home-manager.programs.applications.virtualbox; cfg = config.myOptions.home-manager.programs.applications.virtualbox;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in { in {
config = mkIf cfg.enable { config = mkIf ((builtins.elem deviceType acceptedTypes) && cfg.enable) {
virtualisation.virtualbox.host = { virtualisation.virtualbox.host = {
enable = true; enable = true;

View file

@ -7,8 +7,10 @@
inherit (lib) mkIf; inherit (lib) mkIf;
cfgUser = config.myOptions.system.username; cfgUser = config.myOptions.system.username;
cfg = config.myOptions.home-manager.programs.applications.wireshark; cfg = config.myOptions.home-manager.programs.applications.wireshark;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in { in {
config = mkIf cfg.enable { config = mkIf ((builtins.elem deviceType acceptedTypes) && cfg.enable) {
programs.wireshark = { programs.wireshark = {
enable = true; enable = true;
package = pkgs.wireshark; package = pkgs.wireshark;

View file

@ -1,8 +1,15 @@
{ {
config,
pkgs, pkgs,
lib, lib,
... ...
}: { }: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
environment.systemPackages = [pkgs.appimage-run]; environment.systemPackages = [pkgs.appimage-run];
# run appimages with appimage-run # run appimages with appimage-run
@ -46,4 +53,5 @@
# symlink there for compatibility. # symlink there for compatibility.
# - For example the rye installed python binaries look there # - For example the rye installed python binaries look there
environment.etc."ssl/cert.pem".source = "/etc/ssl/certs/ca-certificates.crt"; environment.etc."ssl/cert.pem".source = "/etc/ssl/certs/ca-certificates.crt";
};
} }

View file

@ -6,6 +6,5 @@
./misc.nix ./misc.nix
./logind.nix ./logind.nix
./gnome-keyring.nix ./gnome-keyring.nix
./flatpak.nix
]; ];
} }

View file

@ -1,4 +1,14 @@
{pkgs, ...}: { {
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# https://dataswamp.org/~solene/2022-09-28-earlyoom.html # https://dataswamp.org/~solene/2022-09-28-earlyoom.html
# avoid the linux kernel locking itself when we're putting too much strain on the memory # avoid the linux kernel locking itself when we're putting too much strain on the memory
# this helps avoid having to shut down forcefully when we OOM # this helps avoid having to shut down forcefully when we OOM
@ -19,4 +29,5 @@
echo "Process $EARLYOOM_NAME ($EARLYOOM_PID) was killed" echo "Process $EARLYOOM_NAME ($EARLYOOM_PID) was killed"
''; '';
}; };
};
} }

View file

@ -1,3 +0,0 @@
{
services.flatpak.enable = true;
}

View file

@ -1,4 +1,14 @@
{pkgs, ...}: { {
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services = { services = {
udev.packages = with pkgs; [gnome.gnome-settings-daemon]; udev.packages = with pkgs; [gnome.gnome-settings-daemon];
gnome.gnome-keyring.enable = true; gnome.gnome-keyring.enable = true;
@ -11,4 +21,5 @@
xdg.portal.config.common = { xdg.portal.config.common = {
"org.freedesktop.impl.portal.Secret" = ["gnome-keyring"]; "org.freedesktop.impl.portal.Secret" = ["gnome-keyring"];
}; };
};
} }

View file

@ -1,4 +1,13 @@
{ {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# despite being under logind, this has nothing to do with login # despite being under logind, this has nothing to do with login
# it's about power management # it's about power management
services.logind = { services.logind = {
@ -9,4 +18,5 @@
HibernateDelaySec=3600 HibernateDelaySec=3600
''; '';
}; };
};
} }

View file

@ -1,4 +1,14 @@
{ {
config,
lib,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services = { services = {
# enable GVfs - a userspace virtual filesystem # enable GVfs - a userspace virtual filesystem
gvfs.enable = true; gvfs.enable = true;
@ -6,4 +16,5 @@
# storage daemon required for udiskie auto-mount # storage daemon required for udiskie auto-mount
udisks2.enable = true; udisks2.enable = true;
}; };
};
} }

View file

@ -1,4 +1,13 @@
{config, ...}: { {
lib,
config,
...
}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
services = { services = {
# enable GVfs, a userspace virtual filesystem # enable GVfs, a userspace virtual filesystem
# (allows viewing ftp,sftp,... directly from the file manager) # (allows viewing ftp,sftp,... directly from the file manager)
@ -7,4 +16,5 @@
# Storage daemon required for udiskie auto-mount # Storage daemon required for udiskie auto-mount
udisks2.enable = !config.boot.isContainer; udisks2.enable = !config.boot.isContainer;
}; };
};
} }

View file

@ -5,11 +5,13 @@
... ...
}: let }: let
inherit (lib) mkIf optional; inherit (lib) mkIf optional;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
cfg = config.myOptions.workstation.printing; cfg = config.myOptions.workstation.printing;
cfgUser = config.myOptions.system.username; cfgUser = config.myOptions.system.username;
in { in {
config = mkIf cfg.enable { config = mkIf (builtins.elem deviceType acceptedTypes && cfg.enable) {
# enable cups and add some drivers for common printers # enable cups and add some drivers for common printers
services = { services = {
printing = { printing = {