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 +++++++++++++++++ 13 files changed, 177 insertions(+), 66 deletions(-) create mode 100644 sys/core/memory.nix create mode 100644 sys/core/storage.nix create mode 100644 sys/core/users.nix (limited to 'sys/core') 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" ]) + ]; + }; + }; +} -- cgit v1.3