From c1d9af57156f3c95590d9a12c394ee064df9696e Mon Sep 17 00:00:00 2001 From: adikro Date: Sat, 20 Dec 2025 15:25:38 +0100 Subject: added disko config for laptop, added storage and memory modules --- sys/core/audio.nix | 9 ++++--- sys/core/bootloader.nix | 7 +++-- sys/core/core.nix | 33 +++++++++++++++++++++++- sys/core/drivers.nix | 65 +++++++++++++++++++++++------------------------ sys/core/fonts.nix | 6 ++--- sys/core/greet.nix | 5 ++-- sys/core/home-manager.nix | 18 +++++++------ sys/core/localization.nix | 5 ++-- sys/core/memory.nix | 46 +++++++++++++++++++++++++++++++++ sys/core/networking.nix | 5 ++-- sys/core/security.nix | 11 +++++--- sys/core/storage.nix | 10 ++++++++ sys/core/users.nix | 23 +++++++++++++++++ sys/default.nix | 1 - sys/pkgs/pkgs.nix | 4 --- sys/srv/compat.nix | 6 ++--- sys/srv/docker.nix | 9 +++---- sys/srv/files.nix | 16 +++++++----- sys/srv/gaming.nix | 12 ++++----- sys/srv/kvm.nix | 9 +++---- sys/srv/nix-helper.nix | 5 ++-- sys/srv/ollama.nix | 15 +++-------- sys/wm/niri.nix | 17 +++---------- sys/wm/wm.nix | 19 +++++++++++++- 24 files changed, 229 insertions(+), 127 deletions(-) create mode 100644 sys/core/memory.nix create mode 100644 sys/core/storage.nix create mode 100644 sys/core/users.nix delete mode 100644 sys/pkgs/pkgs.nix (limited to 'sys') diff --git a/sys/core/audio.nix b/sys/core/audio.nix index f855ad0..234b6bd 100644 --- a/sys/core/audio.nix +++ b/sys/core/audio.nix @@ -1,10 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, username, ... }: let - cfg = config.szpont.sys.core.audio; + cfg = config.sys.core.audio; in { - options.szpont.sys.core.audio.enable = lib.mkEnableOption "audio support"; - + options.sys.core.audio.enable = lib.mkEnableOption "audio support"; config = lib.mkIf cfg.enable { services = { pipewire = { @@ -27,5 +26,7 @@ in helvum alsa-utils ]; + + home-manager.users.${username}.hm.soft.easyeffects.enable = true; }; } diff --git a/sys/core/bootloader.nix b/sys/core/bootloader.nix index 292679e..7293ffc 100644 --- a/sys/core/bootloader.nix +++ b/sys/core/bootloader.nix @@ -1,14 +1,13 @@ { config, lib, ... }: let - cfg = config.szpont.sys.core.bootloader; + cfg = config.sys.core.bootloader; in { - options.szpont.sys.core.bootloader = lib.mkOption { + options.sys.core.bootloader = lib.mkOption { type = lib.types.enum [ "systemd-boot" "grub" "none" ]; default = "systemd-boot"; - description = "Which bootloader to use"; + description = "which bootloader to use"; }; - config = lib.mkMerge [ { boot.loader.efi.canTouchEfiVariables = true; diff --git a/sys/core/core.nix b/sys/core/core.nix index da8f277..ba38eb9 100644 --- a/sys/core/core.nix +++ b/sys/core/core.nix @@ -1,4 +1,7 @@ -{ ... }: +{ config, lib, pkgs, ... }: +let + cfg = config.sys.core; +in { imports = [ ./audio.nix @@ -8,7 +11,35 @@ ./greet.nix ./home-manager.nix ./localization.nix + ./memory.nix ./networking.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/sys/core/drivers.nix b/sys/core/drivers.nix index de7dcb5..a01bb54 100644 --- a/sys/core/drivers.nix +++ b/sys/core/drivers.nix @@ -1,9 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.core.drivers; + cfg = config.sys.core.drivers; in { - options.szpont.sys.core.drivers = { + options.sys.core.drivers = { enable = lib.mkEnableOption "enables hardware drivers"; amd.enable = lib.mkEnableOption "AMD specific drivers and microcode"; stability = lib.mkOption { @@ -11,38 +11,37 @@ in default = "stable"; }; }; + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + services.smartd.enable = true; + hardware.sensor.iio.enable = true; + hardware.enableAllFirmware = true; + hardware.graphics = { + enable = true; + enable32Bit = true; + }; + } - config = lib.mkIf cfg.enable { - services.smartd.enable = true; - hardware.sensor.iio.enable = true; - hardware.enableRedistributableFirmware = true; - hardware.graphics = { - enable = true; - enable32Bit = true; - }; + (lib.mkIf cfg.amd.enable { + services.xserver.videoDrivers = [ "amdgpu" ]; + hardware.cpu.amd.updateMicrocode = true; + hardware.amdgpu = { + initrd.enable = true; + overdrive.enable = true; + }; + }) - programs.coolercontrol.enable = true; - environment.systemPackages = with pkgs; [ linux-firmware ]; + (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 (lib.mkMerge [ - { - services.xserver.videoDrivers = [ "amdgpu" ]; - hardware.cpu.amd.updateMicrocode = true; - hardware.amdgpu = { - initrd.enable = true; - overdrive.enable = true; - }; - } - (lib.mkIf (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.stability == "stable") { - boot.kernelPackages = pkgs.linuxPackages_latest; - }) - ])); + (lib.mkIf (cfg.amd.enable && cfg.stability == "stable") { + boot.kernelPackages = pkgs.linuxPackages_latest; + }) + ]); } diff --git a/sys/core/fonts.nix b/sys/core/fonts.nix index 5bdf751..1173439 100644 --- a/sys/core/fonts.nix +++ b/sys/core/fonts.nix @@ -1,11 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.core.fonts; + cfg = config.sys.core.fonts; in { - options.szpont.sys.core.fonts = { - enable = lib.mkEnableOption "system-wide fonts and console configuration"; - }; + options.sys.core.fonts.enable = lib.mkEnableOption "system-wide font and console configuration"; config = lib.mkIf cfg.enable { console = { diff --git a/sys/core/greet.nix b/sys/core/greet.nix index c5e3c5c..95603e8 100644 --- a/sys/core/greet.nix +++ b/sys/core/greet.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.core.greet; + cfg = config.sys.core.greet; in { - options.szpont.sys.core.greet.enable = lib.mkEnableOption "enables greetd daemon with tuigreet"; - + options.sys.core.greet.enable = lib.mkEnableOption "enables greetd daemon with tuigreet"; config = lib.mkIf cfg.enable { services.greetd = { enable = true; diff --git a/sys/core/home-manager.nix b/sys/core/home-manager.nix index df9a518..7bc4b18 100644 --- a/sys/core/home-manager.nix +++ b/sys/core/home-manager.nix @@ -1,34 +1,36 @@ -{ inputs, config, lib,... }: +{ inputs, config, lib, username, ... }: let - cfg = config.szpont.sys.core.home-manager; + cfg = config.sys.core.home-manager; in { imports = [ inputs.home-manager.nixosModules.home-manager ]; - options.szpont.sys.core.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"; + 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"; + description = "Path to the user's home.nix file"; }; }; }); }; }; - config = lib.mkIf cfg.enable { home-manager = { - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { inherit inputs username; }; useGlobalPkgs = true; useUserPackages = true; backupFileExtension = "bak"; - users = lib.mapAttrs (name: user: import user.path) cfg.users; + users = lib.mapAttrs (name: userCfg: { + imports = [ userCfg.path ]; + }) cfg.users; }; }; } diff --git a/sys/core/localization.nix b/sys/core/localization.nix index 0b046d4..4d45b75 100644 --- a/sys/core/localization.nix +++ b/sys/core/localization.nix @@ -1,9 +1,9 @@ { config, lib, ... }: let - cfg = config.szpont.sys.core.locale; + cfg = config.sys.core.locale; in { - options.szpont.sys.core.locale = { + options.sys.core.locale = { enable = lib.mkEnableOption "system localization (timezone and language)"; timeZone = lib.mkOption { @@ -18,7 +18,6 @@ in description = "the locale used for numbers, time, and measurements."; }; }; - config = lib.mkIf cfg.enable { time.timeZone = cfg.timeZone; diff --git a/sys/core/memory.nix b/sys/core/memory.nix new file mode 100644 index 0000000..cdf71e8 --- /dev/null +++ b/sys/core/memory.nix @@ -0,0 +1,46 @@ +{ config, lib, ... }: +let + cfg = config.sys.core.memory; +in +{ + options.sys.core.memory = { + enable = lib.mkEnableOption "memory management"; + + zram = { + enable = lib.mkEnableOption "enables zram compression"; + percent = lib.mkOption { + type = lib.types.int; + default = 25; + description = "Percentage of total RAM to use for zram"; + }; + }; + + swapfile = { + enable = lib.mkEnableOption "enables a swapfile"; + size = lib.mkOption { + type = lib.types.int; + default = 8192; + description = "Size of the swapfile in gigabytes"; + }; + }; + }; + + config = lib.mkIf cfg.enable (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/sys/core/networking.nix b/sys/core/networking.nix index aa8e606..314feb7 100644 --- a/sys/core/networking.nix +++ b/sys/core/networking.nix @@ -1,10 +1,9 @@ { config, lib, ... }: let - cfg = config.szpont.sys.core.network; + cfg = config.sys.core.network; in { - options.szpont.sys.core.network.enable = lib.mkEnableOption "system-wide networking setup"; - + options.sys.core.network.enable = lib.mkEnableOption "system-wide networking setup"; config = lib.mkIf cfg.enable { networking = { networkmanager = { diff --git a/sys/core/security.nix b/sys/core/security.nix index 2c34662..bf43577 100644 --- a/sys/core/security.nix +++ b/sys/core/security.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.core.security; + cfg = config.sys.core.security; in { - options.szpont.sys.core.security.enable = lib.mkEnableOption "core security services"; - + options.sys.core.security.enable = lib.mkEnableOption "core security services"; config = lib.mkIf cfg.enable { services.gnome.gnome-keyring.enable = true; @@ -30,5 +29,11 @@ in TimeoutStopSec = 10; }; }; + + environment.systemPackages = with pkgs; [ + veracrypt + bitwarden-desktop + hello + ]; }; } diff --git a/sys/core/storage.nix b/sys/core/storage.nix new file mode 100644 index 0000000..6e2dab8 --- /dev/null +++ b/sys/core/storage.nix @@ -0,0 +1,10 @@ +{ config, lib, ... }: +let + cfg = config.sys.core.storage; +in +{ + options.sys.core.storage.enable = lib.mkEnableOption "enables storage management"; + config = lib.mkIf cfg.enable { + nix.settings.auto-optimise-store = true; + }; +} diff --git a/sys/core/users.nix b/sys/core/users.nix new file mode 100644 index 0000000..fb4e7f0 --- /dev/null +++ b/sys/core/users.nix @@ -0,0 +1,23 @@ +{ 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" ]) + ]; + }; + }; +} diff --git a/sys/default.nix b/sys/default.nix index ede6c62..225c08f 100644 --- a/sys/default.nix +++ b/sys/default.nix @@ -2,7 +2,6 @@ { imports = [ ./core/core.nix - ./pkgs/pkgs.nix ./srv/srv.nix ./wm/wm.nix ]; diff --git a/sys/pkgs/pkgs.nix b/sys/pkgs/pkgs.nix deleted file mode 100644 index facb35d..0000000 --- a/sys/pkgs/pkgs.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ ... }: -{ - -} diff --git a/sys/srv/compat.nix b/sys/srv/compat.nix index 5c08a9b..ab9560f 100644 --- a/sys/srv/compat.nix +++ b/sys/srv/compat.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.srv.compat; + cfg = config.sys.srv.compat; in { - options.szpont.sys.srv.compat.enable = lib.mkEnableOption "enables compatibility with windows & x11"; - + options.sys.srv.compat.enable = lib.mkEnableOption "enables compatibility with windows & x11"; config = lib.mkIf cfg.enable { programs.xwayland = { enable = true; @@ -14,6 +13,7 @@ in environment.sessionVariables = { NIXOS_OZONE_WL = "1"; ELECTRON_ENABLE_WAYLAND = "1"; + WINE_RT_PRIO = "1"; }; environment.systemPackages = with pkgs; [ diff --git a/sys/srv/docker.nix b/sys/srv/docker.nix index 3baa689..0ed1541 100644 --- a/sys/srv/docker.nix +++ b/sys/srv/docker.nix @@ -1,15 +1,14 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, username, ... }: let - cfg = config.szpont.sys.srv.docker; + cfg = config.sys.srv.docker; in { - options.szpont.sys.srv.docker.enable = lib.mkEnableOption "docker container engine"; - + options.sys.srv.docker.enable = lib.mkEnableOption "enables the docker container engine"; config = lib.mkIf cfg.enable { virtualisation.docker.enable = true; environment.systemPackages = [ pkgs.docker-compose ]; - users.users.adam.extraGroups = [ "docker" ]; + users.users.${username}.extraGroups = [ "docker" ]; }; } diff --git a/sys/srv/files.nix b/sys/srv/files.nix index bbd6ca8..9b5759e 100644 --- a/sys/srv/files.nix +++ b/sys/srv/files.nix @@ -1,16 +1,15 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.srv.files; + cfg = config.sys.srv.files; in { - options.szpont.sys.srv.files = { - thunar.enable = lib.mkEnableOption "thunar file manager"; - utils.enable = lib.mkEnableOption "compression and trash utilities"; + options.sys.srv.files = { + thunar.enable = lib.mkEnableOption "enables the thunar file manager"; + utils.enable = lib.mkEnableOption "enables compression and trash utilities"; }; - config = lib.mkMerge [ { - szpont.sys.srv.files.utils.enable = lib.mkDefault cfg.thunar.enable; + sys.srv.files.utils.enable = lib.mkDefault cfg.thunar.enable; } (lib.mkIf cfg.thunar.enable { @@ -22,7 +21,10 @@ in thunar-vcs-plugin ]; }; - services.gnome.gnome-keyring.enable = true; + services = { + tumbler.enable = true; + gnome.gnome-keyring.enable = true; + }; environment.systemPackages = with pkgs; [ file-roller ]; }) diff --git a/sys/srv/gaming.nix b/sys/srv/gaming.nix index 1eb5472..ee7f608 100644 --- a/sys/srv/gaming.nix +++ b/sys/srv/gaming.nix @@ -1,17 +1,15 @@ { config, lib, pkgs, username, ... }: let - cfg = config.szpont.sys.srv.gaming; + cfg = config.sys.srv.gaming; in { - options.szpont.sys.srv.gaming = { - enable = lib.mkEnableOption "enables gaming stuff"; - steam.enable = lib.mkEnableOption "enables steam stuff"; + options.sys.srv.gaming = { + enable = lib.mkEnableOption "enables gaming utilities"; + steam.enable = lib.mkEnableOption "enables steam utilities"; vr.enable = lib.mkEnableOption "enables vr support"; }; - config = lib.mkMerge [ (lib.mkIf cfg.enable { - home-manager.users.${username}.szpont.hm.soft.gaming.enable = true; programs.gamescope.enable = true; programs.gamemode = { @@ -23,6 +21,8 @@ in heroic prismlauncher ]; + + home-manager.users.${username}.hm.soft.mangohud.enable = true; }) (lib.mkIf cfg.steam.enable { diff --git a/sys/srv/kvm.nix b/sys/srv/kvm.nix index 08c8578..2cf8c26 100644 --- a/sys/srv/kvm.nix +++ b/sys/srv/kvm.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.srv.kvm; + cfg = config.sys.srv.kvm; in { - options.szpont.sys.srv.kvm.enable = lib.mkEnableOption "KVM/QEMU virtualization with Virt-Manager"; - + options.sys.srv.kvm.enable = lib.mkEnableOption "KVM/QEMU virtualization with Virt-Manager"; config = lib.mkIf cfg.enable { virtualisation.libvirtd = { enable = true; @@ -14,8 +13,6 @@ in programs.virt-manager.enable = true; - users.users.adam.extraGroups = [ "libvirtd" ]; - - boot.initrd.kernelModules = [ "kvm-amd" ]; + boot.initrd.kernelModules = lib.optional (config.sys.core.drivers.amd.enable or false) "kvm-amd"; }; } diff --git a/sys/srv/nix-helper.nix b/sys/srv/nix-helper.nix index fc81ddb..5eb3353 100644 --- a/sys/srv/nix-helper.nix +++ b/sys/srv/nix-helper.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.srv.nix-helper; + cfg = config.sys.srv.nix-helper; in { - options.szpont.sys.srv.nix-helper.enable = lib.mkEnableOption "enables nix-helper"; - + options.sys.srv.nix-helper.enable = lib.mkEnableOption "enables nix-helper"; config = lib.mkIf cfg.enable { nix.settings = { trusted-users = [ "root" "adam" ]; diff --git a/sys/srv/ollama.nix b/sys/srv/ollama.nix index 7cb90bf..11babd6 100644 --- a/sys/srv/ollama.nix +++ b/sys/srv/ollama.nix @@ -1,18 +1,9 @@ { config, lib, pkgs, ... }: let - cfg = config.szpont.sys.srv.ollama; + cfg = config.sys.srv.ollama; in { - options.szpont.sys.srv.ollama = { - enable = lib.mkEnableOption "Ollama AI service"; - - useRocm = lib.mkOption { - type = lib.types.bool; - default = true; - description = "whether to use ollama with ROCm support."; - }; - }; - + options.sys.srv.ollama.enable = lib.mkEnableOption "Ollama AI service"; config = lib.mkIf cfg.enable { fileSystems."/models" = { device = "/home/ollama"; @@ -22,7 +13,7 @@ in services.ollama = { enable = true; - package = if cfg.useRocm then pkgs.ollama-rocm else pkgs.ollama; + package = pkgs.ollama-rocm; user = "ollama"; models = "/models"; diff --git a/sys/wm/niri.nix b/sys/wm/niri.nix index 96a08ca..c92b068 100644 --- a/sys/wm/niri.nix +++ b/sys/wm/niri.nix @@ -1,11 +1,11 @@ { inputs, config, lib, pkgs, username, ... }: let - cfg = config.szpont.sys.wm.niri; + cfg = config.sys.wm.niri; in { imports = [ inputs.niri.nixosModules.niri ]; - options.szpont.sys.wm.niri.enable = lib.mkEnableOption "Niri"; + options.sys.wm.niri.enable = lib.mkEnableOption "Niri"; config = lib.mkIf cfg.enable { nixpkgs.overlays = [ inputs.niri.overlays.niri ]; @@ -15,16 +15,7 @@ in package = pkgs.niri-unstable; }; - xdg.portal = { - enable = true; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - ]; - }; - - services.dbus.enable = true; - - szpont.sys.srv.compat.enable = true; - home-manager.users.${username}.szpont.hm.env.niri.enable = true; + sys.srv.compat.enable = true; + home-manager.users.${username}.hm.env.niri.enable = true; }; } diff --git a/sys/wm/wm.nix b/sys/wm/wm.nix index 48df857..10780e0 100644 --- a/sys/wm/wm.nix +++ b/sys/wm/wm.nix @@ -1,6 +1,23 @@ -{ ... }: +{ config, lib, pkgs, ... }: +let + cfg = config.sys.wm; +in { imports = [ ./niri.nix ]; + + options.sys.wm.enable = lib.mkEnableOption "enables shared wm features"; + + config = lib.mkIf (cfg.enable || cfg.niri.enable or false) { + services.dbus.enable = true; + + xdg.portal = { + enable = true; + wlr.enable = true; + xdgOpenUsePortal = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + config.common.default = [ "gtk" ]; + }; + }; } -- cgit v1.3