From a5b5ea7f597708539bbf80845ba933031433233f Mon Sep 17 00:00:00 2001 From: twoneis Date: Fri, 2 Aug 2024 23:49:06 +0200 Subject: [PATCH] why? --- devices/ellaca/options.nix | 17 +++-- devices/inkvine/options.nix | 19 +++--- devices/pleniscenta/options.nix | 6 +- disks.nix | 16 +++++ keys.nix | 2 +- modules/{user => apps}/alacritty.conf.nix | 0 modules/{user => apps}/default.nix | 9 ++- modules/{user => apps}/firefox.nix | 7 ++- modules/apps/media.nix | 17 +++++ modules/{user => apps}/notes.nix | 7 ++- modules/{user => apps}/programs.nix | 9 ++- modules/{user => apps}/themes.nix | 7 ++- modules/{user => apps}/vencord.conf.json | 0 modules/{user => apps}/vesktop.conf.json | 0 modules/containers/default.nix | 5 +- modules/default.nix | 12 ++-- modules/games/default.nix | 9 +-- modules/home/default.nix | 10 +-- modules/impermanence/default.nix | 7 ++- modules/networking/default.nix | 6 +- modules/niri/default.nix | 8 +-- modules/niri/xwl-satellite.service.nix | 4 +- modules/secureboot/default.nix | 3 +- modules/user/media.nix | 14 ----- modules/utils/default.nix | 6 +- modules/vm/default.nix | 7 ++- options.nix | 77 ++++++++++------------- outputs.nix | 3 +- 28 files changed, 164 insertions(+), 123 deletions(-) create mode 100644 disks.nix rename modules/{user => apps}/alacritty.conf.nix (100%) rename modules/{user => apps}/default.nix (74%) rename modules/{user => apps}/firefox.nix (96%) create mode 100644 modules/apps/media.nix rename modules/{user => apps}/notes.nix (65%) rename modules/{user => apps}/programs.nix (85%) rename modules/{user => apps}/themes.nix (89%) rename modules/{user => apps}/vencord.conf.json (100%) rename modules/{user => apps}/vesktop.conf.json (100%) delete mode 100644 modules/user/media.nix diff --git a/devices/ellaca/options.nix b/devices/ellaca/options.nix index b145c37..10e3200 100644 --- a/devices/ellaca/options.nix +++ b/devices/ellaca/options.nix @@ -1,12 +1,11 @@ { ... }: { - full = true; + conf = { + apps.enable = true; + niri.enable = true; + containers.enable = true; - withNiri = true; - - withContainers = true; - - hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; - - stateVersion = "24.05"; - hmStateVersion = "24.11"; + hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; + stateVersion = "24.05"; + hmStateVersion = "24.11"; + }; } diff --git a/devices/inkvine/options.nix b/devices/inkvine/options.nix index 670f7e4..ce2e223 100644 --- a/devices/inkvine/options.nix +++ b/devices/inkvine/options.nix @@ -1,13 +1,12 @@ { ... }: { - full = true; + conf = { + apps.enable = true; + niri.enable = true; + games.enable = true; + secureboot.enable = true; - withNiri = true; - - withGames = true; - withSecureBoot = true; - - hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; - - stateVersion = "24.05"; - hmStateVersion = "24.11"; + hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input"; + stateVersion = "24.05"; + hmStateVersion = "24.11"; + }; } diff --git a/devices/pleniscenta/options.nix b/devices/pleniscenta/options.nix index 5c22220..21ec34d 100644 --- a/devices/pleniscenta/options.nix +++ b/devices/pleniscenta/options.nix @@ -1,4 +1,6 @@ { ... }: { - stateVersion = "24.05"; - hmStateVersion = "24.11"; + conf = { + stateVersion = "24.05"; + hmStateVersion = "24.11"; + }; } diff --git a/disks.nix b/disks.nix new file mode 100644 index 0000000..104acda --- /dev/null +++ b/disks.nix @@ -0,0 +1,16 @@ +{ lib, ... }: let + inherit (lib) mkOption; + inherit (lib.types) attrsOf str; +in { + options = { + disks = mkOption { + type = attrsOf str; + default = { }; + example = { + boot = "4672-C1A9"; + crypt = "747ae319-f189-44f5-9737-a42672e2c02d"; + root = "04255623-c061-4cf0-89fa-b3d8eb239d59"; + }; + }; + }; +} diff --git a/keys.nix b/keys.nix index 96146ef..11c6231 100644 --- a/keys.nix +++ b/keys.nix @@ -1,7 +1,7 @@ { lib, ... }: let inherit (lib) mkOption; inherit (lib.types) attrsOf str; -in { +in{ options = { keys = mkOption { type = attrsOf str; diff --git a/modules/user/alacritty.conf.nix b/modules/apps/alacritty.conf.nix similarity index 100% rename from modules/user/alacritty.conf.nix rename to modules/apps/alacritty.conf.nix diff --git a/modules/user/default.nix b/modules/apps/default.nix similarity index 74% rename from modules/user/default.nix rename to modules/apps/default.nix index b81fa54..9b6afba 100644 --- a/modules/user/default.nix +++ b/modules/apps/default.nix @@ -1,4 +1,7 @@ -{ lib, config, pkgs, ... }: { +{ lib, config, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in { imports = [ ./media.nix ./notes.nix @@ -6,7 +9,7 @@ ./themes.nix ]; - config = lib.mkIf config.full { + config = mkIf conf.apps.enable { # Audio security.rtkit.enable = true; @@ -30,7 +33,7 @@ }; }; - home-manager.users.${config.username}.home.packages = [ pkgs.overskride ]; + home-manager.users.${conf.username}.home.packages = [ pkgs.overskride ]; services.blueman.enable = true; }; diff --git a/modules/user/firefox.nix b/modules/apps/firefox.nix similarity index 96% rename from modules/user/firefox.nix rename to modules/apps/firefox.nix index 6fdb8f5..ae94d87 100644 --- a/modules/user/firefox.nix +++ b/modules/apps/firefox.nix @@ -1,6 +1,9 @@ -{ inputs, lib, config, pkgs, ... }: lib.mkIf config.full { +{ inputs, lib, config, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.apps.enable { nixpkgs.overlays = [ inputs.nur.overlay ]; - home-manager.users.${config.username} = { + home-manager.users.${conf.username} = { programs.firefox = { enable = true; profiles = { diff --git a/modules/apps/media.nix b/modules/apps/media.nix new file mode 100644 index 0000000..7cf9edd --- /dev/null +++ b/modules/apps/media.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.apps.enable { + + home-manager.users.${conf.username} = { + home.packages = with pkgs; [ + loupe + spotify + amberol + ]; + + programs.mpv = { + enable = true; + }; + }; +} diff --git a/modules/user/notes.nix b/modules/apps/notes.nix similarity index 65% rename from modules/user/notes.nix rename to modules/apps/notes.nix index 7e9c127..122e4a1 100644 --- a/modules/user/notes.nix +++ b/modules/apps/notes.nix @@ -1,5 +1,8 @@ -{ lib, config, ... }: lib.mkIf config.full { - home-manager.users.${config.username} = { +{ lib, config, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.apps.enable { + home-manager.users.${conf.username} = { home.packages = [ ]; diff --git a/modules/user/programs.nix b/modules/apps/programs.nix similarity index 85% rename from modules/user/programs.nix rename to modules/apps/programs.nix index 3357d99..c7cc542 100644 --- a/modules/user/programs.nix +++ b/modules/apps/programs.nix @@ -1,15 +1,18 @@ -{ lib, config, pkgs, ... }: { +{ lib, config, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in { imports = [ ./firefox.nix ]; - config = lib.mkIf config.full { + config = mkIf conf.apps.enable { services = { # Needed for some features in nautilus such as auto-mounting and trash gvfs.enable = true; }; - home-manager.users.${config.username} = { + home-manager.users.${conf.username} = { home.packages = with pkgs; [ signal-desktop vesktop diff --git a/modules/user/themes.nix b/modules/apps/themes.nix similarity index 89% rename from modules/user/themes.nix rename to modules/apps/themes.nix index 37bb4c1..c775e7f 100644 --- a/modules/user/themes.nix +++ b/modules/apps/themes.nix @@ -1,5 +1,8 @@ -{ lib, config, pkgs, ... }: lib.mkIf config.full { - home-manager.users.${config.username} = { +{ lib, config, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.apps.enable { + home-manager.users.${conf.username} = { home.packages = with pkgs; [ adwaita-icon-theme adwaita-qt diff --git a/modules/user/vencord.conf.json b/modules/apps/vencord.conf.json similarity index 100% rename from modules/user/vencord.conf.json rename to modules/apps/vencord.conf.json diff --git a/modules/user/vesktop.conf.json b/modules/apps/vesktop.conf.json similarity index 100% rename from modules/user/vesktop.conf.json rename to modules/apps/vesktop.conf.json diff --git a/modules/containers/default.nix b/modules/containers/default.nix index c13a4bf..9dff044 100644 --- a/modules/containers/default.nix +++ b/modules/containers/default.nix @@ -1,4 +1,7 @@ -{ lib, config, pkgs, ... }: lib.mkIf config.withContainers { +{ lib, config, pkgs, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.containers.enable { virtualisation.podman = { enable = true; dockerCompat = true; diff --git a/modules/default.nix b/modules/default.nix index 2040ee7..f71e526 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,8 @@ -{ lib, config, ... }: { +{ config, ... }: let + inherit (config) conf; +in { imports = [ + ./apps ./containers ./fonts ./games @@ -10,7 +13,6 @@ ./niri ./nix ./secureboot - ./user ./utils ./vm ]; @@ -29,11 +31,11 @@ }; }; - users.users.${config.username}= { + users.users.${conf.username}= { isNormalUser = true; - description = config.username; + description = conf.username; extraGroups = [ "networkmanager" "wheel" ]; }; - system.stateVersion = config.stateVersion; + system.stateVersion = conf.stateVersion; } diff --git a/modules/games/default.nix b/modules/games/default.nix index 70d288b..7fa1786 100644 --- a/modules/games/default.nix +++ b/modules/games/default.nix @@ -1,5 +1,6 @@ { lib, config, pkgs, ... }: let inherit (lib) mkIf mkMerge; + inherit (config) conf; holo-script = pkgs.writeShellApplication { name = "holo-script"; runtimeInputs = [ pkgs.steam pkgs.gamescope ]; @@ -12,9 +13,9 @@ desktopName = "Holo"; exec = "${holo-script}/bin/holo-script"; }; -in mkIf config.withGames (mkMerge [ - (mkIf config.withImpermanence { - environment.persistence."/persist".users.${config.username}= { +in mkIf conf.games.enable (mkMerge [ + (mkIf conf.impermanence.enable { + environment.persistence."/persist".users.${conf.username}= { directories = [ "Games" ".steam" @@ -26,7 +27,7 @@ in mkIf config.withGames (mkMerge [ programs.gamescope.enable = true; programs.gamemode.enable = true; - home-manager.users.${config.username} = { + home-manager.users.${conf.username} = { home.packages = [ pkgs.prismlauncher holo diff --git a/modules/home/default.nix b/modules/home/default.nix index 9f82aed..33c0949 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,14 +1,16 @@ -{ config, ... }: { +{ config, ... }: let + inherit (config) conf; +in{ home-manager = { useGlobalPkgs = true; useUserPackages = true; - users.${config.username} = { + users.${conf.username} = { home = { username = "twoneis"; - homeDirectory = "/home/${config.username}"; + homeDirectory = "/home/${conf.username}"; - stateVersion = config.hmStateVersion; + stateVersion = conf.hmStateVersion; }; programs.home-manager.enable = true; diff --git a/modules/impermanence/default.nix b/modules/impermanence/default.nix index 2721774..c9bb669 100644 --- a/modules/impermanence/default.nix +++ b/modules/impermanence/default.nix @@ -1,4 +1,7 @@ -{ lib, config, ... }: lib.mkIf config.withImpermanence { +{ lib, config, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.impermanence.enable { environment.persistence."/persist" = { enable = true; directories = [ @@ -14,7 +17,7 @@ "/etc/shadow" ]; - users.${config.username}= { + users.${conf.username}= { directories = [ "Documents" "Pictures" diff --git a/modules/networking/default.nix b/modules/networking/default.nix index 1140f56..853cfc7 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -1,5 +1,7 @@ -{ config, pkgs, ... }: { - home-manager.users.${config.username}.home.packages = [ pkgs.networkmanagerapplet ]; +{ config, pkgs, ... }: let + inherit (config) conf; +in{ + home-manager.users.${conf.username}.home.packages = [ pkgs.networkmanagerapplet ]; networking = { networkmanager = { enable = true; diff --git a/modules/niri/default.nix b/modules/niri/default.nix index 430c77f..287c669 100644 --- a/modules/niri/default.nix +++ b/modules/niri/default.nix @@ -1,13 +1,13 @@ { inputs, lib, config, pkgs, ... }: let inherit (lib) mkIf; - inherit (config) withNiri username; + inherit (config) conf; in { imports = [ ./xwl-satellite.service.nix ]; - config = mkIf withNiri { - nixpkgs.overlays = mkIf config.withNiri [ + config = mkIf conf.niri.enable { + nixpkgs.overlays = [ inputs.niri.overlays.niri ]; @@ -26,7 +26,7 @@ in { lidSwitch = "suspend"; }; - home-manager.users.${username} = { + home-manager.users.${conf.username} = { home.packages = with pkgs; [ brightnessctl swaybg diff --git a/modules/niri/xwl-satellite.service.nix b/modules/niri/xwl-satellite.service.nix index 7f8ad56..0b49fee 100644 --- a/modules/niri/xwl-satellite.service.nix +++ b/modules/niri/xwl-satellite.service.nix @@ -1,7 +1,7 @@ { lib, config, pkgs, ... }: let inherit (lib) mkIf; - inherit (config) withNiri; -in mkIf withNiri { + inherit (config) conf; +in mkIf conf.niri.enable { environment.systemPackages = with pkgs; [ xwayland-satellite xwayland ]; systemd.user.services.xwayland-satellite = { description = "Xwayland outside your Wayland"; diff --git a/modules/secureboot/default.nix b/modules/secureboot/default.nix index 75fd92f..6193bc9 100644 --- a/modules/secureboot/default.nix +++ b/modules/secureboot/default.nix @@ -1,6 +1,7 @@ { lib, config, pkgs, ... }: let inherit (lib) mkIf mkForce; -in mkIf config.withSecureBoot { + inherit (config) conf; +in mkIf conf.secureboot.enable { environment.systemPackages = [ pkgs.sbctl ]; boot.loader.systemd-boot.enable = mkForce false; diff --git a/modules/user/media.nix b/modules/user/media.nix deleted file mode 100644 index fc52890..0000000 --- a/modules/user/media.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: lib.mkIf config.full { - - home-manager.users.${config.username} = { - home.packages = with pkgs; [ - loupe - spotify - amberol - ]; - - programs.mpv = { - enable = true; - }; - }; -} diff --git a/modules/utils/default.nix b/modules/utils/default.nix index ed781fc..268e478 100644 --- a/modules/utils/default.nix +++ b/modules/utils/default.nix @@ -1,8 +1,10 @@ -{ config, pkgs, ... }: { +{ config, pkgs, ... }: let + inherit (config) conf; +in { programs.fish.enable = true; users.defaultUserShell = pkgs.fish; - home-manager.users.${config.username} = { + home-manager.users.${conf.username} = { home.packages = with pkgs; [ man-pages man-pages-posix diff --git a/modules/vm/default.nix b/modules/vm/default.nix index fdc7323..03ccccb 100644 --- a/modules/vm/default.nix +++ b/modules/vm/default.nix @@ -1,5 +1,8 @@ -{ lib, config, ... }: lib.mkIf config.withVM { +{ lib, config, ... }: let + inherit (lib) mkIf; + inherit (config) conf; +in mkIf conf.vm.enable { virtualisation.libvirtd.enable = true; programs.virt-manager.enable = true; - users.users.${config.username}.extraGroups = [ "libvirtd" ]; + users.users.${conf.username}.extraGroups = [ "libvirtd" ]; } diff --git a/options.nix b/options.nix index 1f15b1c..3f73d90 100644 --- a/options.nix +++ b/options.nix @@ -1,53 +1,40 @@ -{ lib, ... }: { - options = let - inherit (lib) mkOption mkEnableOption; - inherit (lib.types) nullOr attrsOf str; - in { - full = mkEnableOption "Enable complete configuration for end-user machine"; +{ lib, ... }: let + inherit (lib) mkOption mkEnableOption; + inherit (lib.types) nullOr str; +in { + options = { + conf = { + apps.enable = mkEnableOption "Enable complete configuration for end-user machine"; + niri.enable = mkEnableOption "Enable niri compositor"; + vm.enable = lib.mkEnableOption "Enable VM related configuration"; + containers.enable = mkEnableOption "Enable container support"; + games.enable = mkEnableOption "Enable games"; + impermanence.enable = mkEnableOption "Use impermanence module"; + secureboot.enable = mkEnableOption "Enable secure boot utilities (manual key-enrolling required)"; - withNiri = mkEnableOption "Enable niri compositor"; - - withVM = lib.mkEnableOption "Enable VM related configuration"; - withContainers = mkEnableOption "Enable container support"; - - withGames = mkEnableOption "Enable games"; - - withImpermanence = mkEnableOption "Use impermanence module"; - - withSecureBoot = mkEnableOption "Enable secure boot utilities (manual key-enrolling required)"; - - disks = mkOption { - type = attrsOf str; - default = { }; - example = { - boot = "4672-C1A9"; - crypt = "747ae319-f189-44f5-9737-a42672e2c02d"; - root = "04255623-c061-4cf0-89fa-b3d8eb239d59"; + username = mkOption { + type = str; + default = "twoneis"; + example = "anna"; }; - }; - username = mkOption { - type = str; - default = "twoneis"; - example = "anna"; - }; + hwmonPath = mkOption { + type = nullOr str; + default = null; + example = "/sys/class/hwmon/hwmon1/temp1_input"; + }; - hwmonPath = mkOption { - type = nullOr str; - default = null; - example = "/sys/class/hwmon/hwmon1/temp1_input"; - }; + stateVersion = mkOption { + type = nullOr str; + default = null; + example = "24.05"; + }; - stateVersion = mkOption { - type = nullOr str; - default = null; - example = "24.05"; - }; - - hmStateVersion = mkOption { - type = nullOr str; - default = null; - example = "24.11"; + hmStateVersion = mkOption { + type = nullOr str; + default = null; + example = "24.11"; + }; }; }; } diff --git a/outputs.nix b/outputs.nix index 7aa6800..a4587f9 100644 --- a/outputs.nix +++ b/outputs.nix @@ -1,9 +1,10 @@ { nixpkgs, lix, home-manager, nixos-hardware, niri, impermanence, lanzaboote, ... }@inputs: let modules = [ ./modules - ./options.nix ./colors.nix + ./disks.nix ./keys.nix + ./options.nix niri.nixosModules.niri home-manager.nixosModules.home-manager lix.nixosModules.default