summaryrefslogtreecommitdiff
path: root/os/core
diff options
context:
space:
mode:
authoradikro <adikro@disroot.org>2025-12-24 16:21:00 +0100
committeradikro <adikro@disroot.org>2025-12-24 16:21:00 +0100
commit6aaa5993e4c1cfb205ed555d958702f9bba1770d (patch)
tree3af8cf20967cf10542edd2e51232b1da70002fde /os/core
parent2ceabfd1d1dc03ca895e960048b73a82e29e45e8 (diff)
a bunch of changes, renames sys to os and refactored some of the logic
Diffstat (limited to 'os/core')
-rw-r--r--os/core/audio.nix30
-rw-r--r--os/core/bootloader.nix42
-rw-r--r--os/core/core.nix46
-rw-r--r--os/core/drivers.nix47
-rw-r--r--os/core/fonts.nix22
-rw-r--r--os/core/greet.nix29
-rw-r--r--os/core/home-manager.nix36
-rw-r--r--os/core/localization.nix41
-rw-r--r--os/core/memory.nix41
-rw-r--r--os/core/networking.nix20
-rw-r--r--os/core/power.nix18
-rw-r--r--os/core/security.nix38
-rw-r--r--os/core/storage.nix36
-rw-r--r--os/core/users.nix24
14 files changed, 470 insertions, 0 deletions
diff --git a/os/core/audio.nix b/os/core/audio.nix
new file mode 100644
index 0000000..4868c7d
--- /dev/null
+++ b/os/core/audio.nix
@@ -0,0 +1,30 @@
+{ config, lib, pkgs, username, ... }:
+let
+ cfg = config.sys.core.audio;
+in
+{
+ options.sys.core.audio.enable = lib.mkEnableOption "audio support";
+ config = lib.mkIf cfg.enable {
+ services = {
+ pipewire = {
+ enable = true;
+ audio.enable = true;
+ pulse.enable = true;
+ alsa.enable = true;
+ alsa.support32Bit = true;
+ jack.enable = true;
+ wireplumber.enable = true;
+ };
+ playerctld.enable = true;
+ spotifyd.enable = true;
+ };
+
+ security.rtkit.enable = true;
+ hardware.enableAllFirmware = true;
+
+ environment.systemPackages = with pkgs; [
+ helvum
+ alsa-utils
+ ];
+ };
+}
diff --git a/os/core/bootloader.nix b/os/core/bootloader.nix
new file mode 100644
index 0000000..ff0aad5
--- /dev/null
+++ b/os/core/bootloader.nix
@@ -0,0 +1,42 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.bootloader;
+in
+{
+ options.sys.core.bootloader = lib.mkOption {
+ type = lib.types.enum [ "systemd-boot" "grub" "none" ];
+ default = "systemd-boot";
+ description = "which bootloader to use";
+ };
+ config = lib.mkMerge [
+ {
+ boot.loader.efi.canTouchEfiVariables = true;
+ boot.supportedFilesystems = [ "ntfs" ];
+ boot.kernelParams = [ "quiet" "splash" ];
+ }
+
+ (lib.mkIf (cfg == "systemd-boot") {
+ boot.consoleLogLevel = 0;
+ boot.loader = {
+ systemd-boot.enable = true;
+ systemd-boot.editor = false;
+ timeout = 0;
+ };
+ })
+
+ (lib.mkIf (cfg == "grub") {
+ boot.loader = {
+ timeout = 3;
+ efi.efiSysMountPoint = "/boot";
+ grub = {
+ enable = true;
+ device = "nodev";
+ efiSupport = true;
+ useOSProber = true;
+
+ default = 2;
+ };
+ };
+ })
+ ];
+}
diff --git a/os/core/core.nix b/os/core/core.nix
new file mode 100644
index 0000000..428d7ea
--- /dev/null
+++ b/os/core/core.nix
@@ -0,0 +1,46 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.sys.core;
+in
+{
+ imports = [
+ ./audio.nix
+ ./bootloader.nix
+ ./drivers.nix
+ ./fonts.nix
+ ./greet.nix
+ ./home-manager.nix
+ ./localization.nix
+ ./memory.nix
+ ./networking.nix
+ ./power.nix
+ ./security.nix
+ ./storage.nix
+ ./users.nix
+ ];
+
+ options.sys.core = {
+ allowUnfree.enable = lib.mkEnableOption "unfree software";
+
+ flatpak.enable = lib.mkEnableOption "Flatpak support";
+
+ hardwareTools = {
+ enable = lib.mkEnableOption "peripheral and thermal tools";
+ };
+ };
+
+ config = lib.mkMerge [
+ (lib.mkIf cfg.allowUnfree.enable {
+ nixpkgs.config.allowUnfree = true;
+ })
+
+ (lib.mkIf cfg.flatpak.enable {
+ services.flatpak.enable = true;
+ })
+
+ (lib.mkIf cfg.hardwareTools.enable {
+ programs.coolercontrol.enable = true;
+ environment.systemPackages = [ pkgs.rivalcfg ];
+ })
+ ];
+}
diff --git a/os/core/drivers.nix b/os/core/drivers.nix
new file mode 100644
index 0000000..c769786
--- /dev/null
+++ b/os/core/drivers.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.sys.core.drivers;
+in
+{
+ options.sys.core.drivers = {
+ enable = lib.mkEnableOption "enables hardware drivers";
+ amd.enable = lib.mkEnableOption "AMD specific drivers and microcode";
+ stability = lib.mkOption {
+ type = lib.types.enum [ "stable" "unstable" ];
+ default = "stable";
+ };
+ };
+ config = lib.mkIf cfg.enable (lib.mkMerge [
+ {
+ services.smartd.enable = true;
+ hardware.sensor.iio.enable = true;
+ hardware.enableAllFirmware = true;
+ hardware.cpu.amd.updateMicrocode = true;
+ hardware.graphics = {
+ enable = true;
+ enable32Bit = true;
+ };
+ }
+
+ (lib.mkIf cfg.amd.enable {
+ services.xserver.videoDrivers = [ "amdgpu" ];
+ hardware.amdgpu = {
+ initrd.enable = true;
+ overdrive.enable = true;
+ };
+ })
+
+ (lib.mkIf (cfg.amd.enable && cfg.stability == "unstable") {
+ services.lact.enable = true;
+ boot.kernelPackages = pkgs.linuxPackages_cachyos-lto-znver4;
+ chaotic.mesa-git = {
+ enable = true;
+ extraPackages = [ pkgs.mesa_git.opencl ];
+ };
+ })
+
+ (lib.mkIf (cfg.amd.enable && cfg.stability == "stable") {
+ boot.kernelPackages = pkgs.linuxPackages_latest;
+ })
+ ]);
+}
diff --git a/os/core/fonts.nix b/os/core/fonts.nix
new file mode 100644
index 0000000..1173439
--- /dev/null
+++ b/os/core/fonts.nix
@@ -0,0 +1,22 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.sys.core.fonts;
+in
+{
+ options.sys.core.fonts.enable = lib.mkEnableOption "system-wide font and console configuration";
+
+ config = lib.mkIf cfg.enable {
+ console = {
+ keyMap = "pl";
+ earlySetup = true;
+ font = "ter-v32n";
+ packages = with pkgs; [ terminus_font ];
+ };
+
+ fonts.packages = with pkgs; [
+ nerd-fonts.jetbrains-mono
+ nerd-fonts.fira-mono
+ nerd-fonts.fira-code
+ ];
+ };
+}
diff --git a/os/core/greet.nix b/os/core/greet.nix
new file mode 100644
index 0000000..95603e8
--- /dev/null
+++ b/os/core/greet.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.sys.core.greet;
+in
+{
+ options.sys.core.greet.enable = lib.mkEnableOption "enables greetd daemon with tuigreet";
+ config = lib.mkIf cfg.enable {
+ services.greetd = {
+ enable = true;
+ settings = {
+ default_session = {
+ user = "greeter";
+ command = ''
+ ${pkgs.tuigreet}/bin/tuigreet \
+ --sessions ${config.services.displayManager.sessionData.desktops}/share/xsessions:${config.services.displayManager.sessionData.desktops}/share/wayland-sessions \
+ --remember \
+ --remember-user-session \
+ --asterisks \
+ --greeting 'Welcome to NixOS!' \
+ --time
+ '';
+ };
+ };
+ };
+ security.pam.services.greetd.enableGnomeKeyring = true;
+
+ environment.systemPackages = with pkgs; [ tuigreet ];
+ };
+}
diff --git a/os/core/home-manager.nix b/os/core/home-manager.nix
new file mode 100644
index 0000000..7bc4b18
--- /dev/null
+++ b/os/core/home-manager.nix
@@ -0,0 +1,36 @@
+{ inputs, config, lib, username, ... }:
+let
+ cfg = config.sys.core.home-manager;
+in
+{
+ imports = [ inputs.home-manager.nixosModules.home-manager ];
+
+ options.sys.core.home-manager = {
+ enable = lib.mkEnableOption "home Manager configuration";
+
+ users = lib.mkOption {
+ default = {};
+ description = "Attribute set of users and their home-manager configurations";
+ type = lib.types.attrsOf (lib.types.submodule {
+ options = {
+ path = lib.mkOption {
+ type = lib.types.path;
+ description = "Path to the user's home.nix file";
+ };
+ };
+ });
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ home-manager = {
+ extraSpecialArgs = { inherit inputs username; };
+ useGlobalPkgs = true;
+ useUserPackages = true;
+ backupFileExtension = "bak";
+
+ users = lib.mapAttrs (name: userCfg: {
+ imports = [ userCfg.path ];
+ }) cfg.users;
+ };
+ };
+}
diff --git a/os/core/localization.nix b/os/core/localization.nix
new file mode 100644
index 0000000..4d45b75
--- /dev/null
+++ b/os/core/localization.nix
@@ -0,0 +1,41 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.locale;
+in
+{
+ options.sys.core.locale = {
+ enable = lib.mkEnableOption "system localization (timezone and language)";
+
+ timeZone = lib.mkOption {
+ type = lib.types.str;
+ default = "Europe/Warsaw";
+ description = "the system timezone.";
+ };
+
+ format = lib.mkOption {
+ type = lib.types.str;
+ default = "pl_PL.UTF-8";
+ description = "the locale used for numbers, time, and measurements.";
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ time.timeZone = cfg.timeZone;
+
+ i18n = {
+ defaultLocale = "en_US.UTF-8";
+
+ extraLocaleSettings = {
+ LC_TIME = cfg.format;
+ LC_NUMERIC = cfg.format;
+ LC_MONETARY = cfg.format;
+ LC_PAPER = cfg.format;
+ LC_MEASUREMENT = cfg.format;
+ LC_COLLATE = cfg.format;
+ LC_NAME = cfg.format;
+ LC_ADDRESS = cfg.format;
+ LC_TELEPHONE = cfg.format;
+ LC_IDENTIFICATION = cfg.format;
+ };
+ };
+ };
+}
diff --git a/os/core/memory.nix b/os/core/memory.nix
new file mode 100644
index 0000000..956cc73
--- /dev/null
+++ b/os/core/memory.nix
@@ -0,0 +1,41 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.memory;
+in
+{
+ options.sys.core.memory = {
+ zram = {
+ enable = lib.mkEnableOption "enables zram compression";
+ percent = lib.mkOption {
+ type = lib.types.int;
+ default = 25;
+ };
+ };
+
+ swapfile = {
+ enable = lib.mkEnableOption "enables a swapfile";
+ size = lib.mkOption {
+ type = lib.types.int;
+ default = 8;
+ };
+ };
+ };
+ config = lib.mkMerge [
+ (lib.mkIf cfg.zram.enable {
+ zramSwap = {
+ enable = true;
+ algorithm = "zstd";
+ memoryPercent = cfg.zram.percent;
+ priority = 100;
+ };
+ })
+
+ (lib.mkIf cfg.swapfile.enable {
+ swapDevices = [ {
+ device = "/.swapvol/swapfile";
+ size = cfg.swapfile.size * 1024;
+ priority = 0;
+ } ];
+ })
+ ];
+}
diff --git a/os/core/networking.nix b/os/core/networking.nix
new file mode 100644
index 0000000..314feb7
--- /dev/null
+++ b/os/core/networking.nix
@@ -0,0 +1,20 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.network;
+in
+{
+ options.sys.core.network.enable = lib.mkEnableOption "system-wide networking setup";
+ config = lib.mkIf cfg.enable {
+ networking = {
+ networkmanager = {
+ enable = true;
+ wifi.macAddress = "stable-ssid";
+ ethernet.macAddress = "stable-ssid";
+ };
+ firewall = {
+ enable = true;
+ };
+ };
+ systemd.services."NetworkManager-wait-online".enable = false;
+ };
+}
diff --git a/os/core/power.nix b/os/core/power.nix
new file mode 100644
index 0000000..f67665e
--- /dev/null
+++ b/os/core/power.nix
@@ -0,0 +1,18 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.power;
+in
+{
+ options.sys.core.power.enable = lib.mkEnableOption "enables AMD-optimized power management";
+ config = lib.mkIf cfg.enable {
+ services.power-profiles-daemon.enable = true;
+
+ boot.kernelParams = [
+ "amd_pstate=active"
+ "nvme_core.default_ps_max_latency_us=0"
+ ];
+
+ powerManagement.powertop.enable = true;
+ services.thermald.enable = true;
+ };
+}
diff --git a/os/core/security.nix b/os/core/security.nix
new file mode 100644
index 0000000..cfc8bf6
--- /dev/null
+++ b/os/core/security.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.sys.core.security;
+in
+{
+ options.sys.core.security.enable = lib.mkEnableOption "core security services";
+ config = lib.mkIf cfg.enable {
+ services.gnome.gnome-keyring.enable = true;
+
+ security = {
+ polkit.enable = true;
+ rtkit.enable = true;
+ };
+
+ programs.gnupg.agent = {
+ enable = true;
+ enableSSHSupport = true;
+ pinentryPackage = pkgs.pinentry-curses;
+ };
+
+ systemd.user.services.polkit-gnome-authentication-agent-1 = {
+ description = "gnome-polkit-authentication-agent-1";
+ wantedBy = [ "graphical-session.target" ];
+ serviceConfig = {
+ Type = "simple";
+ ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
+ Restart = "on-failure";
+ RestartSec = 1;
+ TimeoutStopSec = 10;
+ };
+ };
+
+ environment.systemPackages = with pkgs; [
+ veracrypt
+ bitwarden-desktop
+ ];
+ };
+}
diff --git a/os/core/storage.nix b/os/core/storage.nix
new file mode 100644
index 0000000..693e5e7
--- /dev/null
+++ b/os/core/storage.nix
@@ -0,0 +1,36 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.storage;
+in
+{
+ options.sys.core.storage = {
+ enable = lib.mkEnableOption "enables storage management";
+
+ keepDays = lib.mkOption {
+ type = lib.types.int;
+ default = 14;
+ description = "Number of days to keep old Nix generations before GC";
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ nix.settings.auto-optimise-store = true;
+
+ programs.nh = {
+ enable = true;
+ clean.enable = true;
+ clean.extraArgs = "--keep-days ${toString cfg.keepDays} --keep 5";
+ };
+
+ services.fstrim.enable = true;
+
+ services.btrfs.autoScrub = {
+ enable = true;
+ fileSystems = [ "/" ];
+ };
+
+ boot.tmp = {
+ useTmpfs = true;
+ tmpfsSize = "50%";
+ };
+ };
+}
diff --git a/os/core/users.nix b/os/core/users.nix
new file mode 100644
index 0000000..d0af69f
--- /dev/null
+++ b/os/core/users.nix
@@ -0,0 +1,24 @@
+{ config, lib, pkgs, username, ... }:
+let
+ cfg = config.sys.core.users;
+in
+{
+ options.sys.core.users.enable = lib.mkEnableOption "enables user accounts";
+ config = lib.mkIf cfg.enable {
+ programs.fish.enable = true;
+ users.users.${username} = {
+ isNormalUser = true;
+ shell = pkgs.fish;
+
+ extraGroups = lib.mkMerge [
+ [ "wheel" ]
+
+ (lib.mkIf (config.sys.core.drivers.amd.enable or false) [ "video" "render" ])
+ (lib.mkIf (config.sys.core.network.enable or false) [ "networkmanager" ])
+ (lib.mkIf (config.sys.srv.kvm.enable or false) [ "libvirtd" ])
+ (lib.mkIf (config.sys.srv.docker.enable or false) [ "docker" ])
+ (lib.mkIf (config.sys.srv.autoclicker.enable or false) [ "input" ])
+ ];
+ };
+ };
+}