From 51d2c2aa7cf7539e04e729ef170ac19bc7f47037 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 3 Aug 2024 18:08:22 +0200 Subject: [PATCH] Modularize nixos and home-manager packages --- README.md | 24 +++++ base/base_packages.nix | 82 --------------- base/big_g.nix | 12 --- base/common_hardware.nix | 34 ++----- base/default.nix | 4 +- base/env.nix | 7 +- base/extra.nix | 1 - base/login_manager.nix | 60 ----------- base/theme.nix | 8 ++ base/xkb_layout.nix | 2 - hardware/marmo/configuration.nix | 3 + hardware/overheating/configuration.nix | 3 + hardware/spaceship/configuration.nix | 9 +- modules/conf.nix | 62 ++++++------ modules/programs/base_packages.nix | 104 +++++++++++++++++++ modules/programs/coding.nix | 134 +++++++++++++++++++++++++ modules/programs/default.nix | 9 ++ modules/programs/flatpak.nix | 31 ++++++ modules/programs/gnome_services.nix | 28 ++++++ modules/programs/greetd.nix | 99 ++++++++++++++++++ modules/programs/home_packages.nix | 93 +++++++++++++++++ modules/programs/layout.nix | 23 +++++ modules/programs/media.nix | 56 +++++++++++ modules/programs/piper.nix | 19 ++++ modules/programs/printing.nix | 24 +++++ programs/coding.nix | 116 --------------------- programs/common.nix | 79 +-------------- programs/default.nix | 4 - programs/flatpak.nix | 14 --- programs/hyprland/config.nix | 6 +- programs/media.nix | 34 ------- programs/utils.nix | 11 -- 32 files changed, 713 insertions(+), 482 deletions(-) delete mode 100644 base/base_packages.nix delete mode 100644 base/big_g.nix delete mode 100644 base/extra.nix delete mode 100644 base/login_manager.nix create mode 100644 base/theme.nix create mode 100644 modules/programs/base_packages.nix create mode 100644 modules/programs/coding.nix create mode 100644 modules/programs/flatpak.nix create mode 100644 modules/programs/gnome_services.nix create mode 100644 modules/programs/greetd.nix create mode 100644 modules/programs/home_packages.nix create mode 100644 modules/programs/layout.nix create mode 100644 modules/programs/media.nix create mode 100644 modules/programs/piper.nix create mode 100644 modules/programs/printing.nix delete mode 100644 programs/coding.nix delete mode 100644 programs/flatpak.nix delete mode 100644 programs/media.nix delete mode 100644 programs/utils.nix diff --git a/README.md b/README.md index e9a047a..2fdca1b 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,27 @@ My personal configuration for NixOS/home-manager. While not intended to be used by someone else, feel free to do so anyway or use it as a template for your configuration if you wish to. + +# Modules + +This configuration features several modules that can be used as preconfigured "recipies". +These modules attempt to combine the home-manager and nixos packages/options to one single configuration file for each new system. +For package lists, please check the individual modules, as the lists can be long. + +- base packages : A list of system packages to be installed by default +- home packages : A list of home packages to be installed by default +- media packages : A list of media packages to be installed by default +- coding packages : A list of coding packages to be installed by default +- acpid : Enables the acpid daemon +- bluetooth : Configures/enables bluetooth and installs tools for bluetooth +- drives : A drive configuration module +- flatpak : Installs and enables declarative flatpak +- gnome_services : Gnome services for minimal enviroments -> Window managers etc +- gpu : GPU settings (AMD) +- greetd : Enables and configures the greetd/regreet login manager with Hyprland +- kde_connect : Enables KDE connect and opens its ports +- layout : Modules to configure keyboard layout system wide +- piper : Installs and enables piper alongside its daemon +- printing : Enables and configures printing services +- virtualbox : Enables and configures virtualbox +- xone : Installs the xone driver diff --git a/base/base_packages.nix b/base/base_packages.nix deleted file mode 100644 index 4175297..0000000 --- a/base/base_packages.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ pkgs, config, ... }: -{ - imports = [ - # is wrapped in if statement to enable when needed - ../programs/gaming/default.nix - ../programs/themes/stylix.nix - ]; - - environment.systemPackages = with pkgs; [ - openssl - dbus - glib - gtk4 - gtk3 - libadwaita - gtk-layer-shell - gtk4-layer-shell - direnv - dconf - gsettings-desktop-schemas - gnome.nixos-gsettings-overrides - bibata-cursors - xorg.xkbutils - libxkbcommon - icon-library - adwaita-icon-theme - hicolor-icon-theme - morewaita-icon-theme - kdePackages.breeze-icons - seahorse - upower - (lib.mkIf config.conf.streamdeck.enable (callPackage - ../override/streamdeck.nix - { })) - ]; - - gtk.iconCache.enable = false; - - fonts.packages = with pkgs; [ - cantarell-fonts - ]; - - nix.settings.experimental-features = "nix-command flakes"; - - virtualisation.docker.enable = true; - - services.upower.enable = true; - services.printing.enable = true; - services.dbus.enable = true; - services.dbus.packages = with pkgs; [ - gnome2.GConf - ]; - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - - programs.fish.enable = true; - programs.fish.promptInit = '' - ${pkgs.any-nix-shell}/bin/any-nix-shell fish --info-right | source - ''; - programs.nix-ld.enable = true; - programs.nix-ld.libraries = with pkgs; [ - jdk - zlib - ]; - programs.dconf.enable = true; - programs.direnv = { - package = pkgs.direnv; - silent = false; - loadInNixShell = true; - direnvrcExtra = ""; - nix-direnv = { - enable = true; - package = pkgs.nix-direnv; - }; - }; - programs.ssh.startAgent = true; - programs.gnupg.agent.enable = true; - -} diff --git a/base/big_g.nix b/base/big_g.nix deleted file mode 100644 index 0b1fe1d..0000000 --- a/base/big_g.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs, ... }: { - services = { - # needed for GNOME services outside of GNOME Desktop - dbus.packages = with pkgs; [ - gcr - gnome.gnome-settings-daemon - ]; - - gnome.gnome-keyring.enable = true; - gvfs.enable = true; - }; -} diff --git a/base/common_hardware.nix b/base/common_hardware.nix index 2cd48a9..e8b4f88 100644 --- a/base/common_hardware.nix +++ b/base/common_hardware.nix @@ -11,7 +11,10 @@ in boot.loader.efi.canTouchEfiVariables = true; # Enable networking + networking.useDHCP = lib.mkDefault true; networking.networkmanager.enable = true; + networking.hostName = config.conf.hostname; + services.flatpak.enable = true; # Set your time zone. @@ -23,25 +26,14 @@ in # Enable the X11 windowing system. services.xserver.enable = true; - # Configure keymap in X11 - services.xserver = { - xkb.layout = "us"; - xkb.variant = ""; - }; - - # Enable CUPS to print documents. - services.printing.enable = true; - services.printing.browsing = true; - services.printing.drivers = [ pkgs.hplip ]; - services.printing.startWhenNeeded = true; # optional - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; + nixpkgs.hostPlatform = lib.mkDefault config.conf.system; + nix.settings.auto-optimise-store = true; # Enable sound with pipewire. hardware.pulseaudio.enable = false; + hardware.cpu.${config.conf.cpu}.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + services.fstrim.enable = lib.mkDefault true; security.rtkit.enable = true; services.pipewire = { enable = true; @@ -65,8 +57,6 @@ in "resume=\"PARTLABEL=SWAP\"" ] ++ config.conf.boot_params; - networking.hostName = config.conf.hostname; - # allows user change later on users.mutableUsers = true; users.users.${username} = { @@ -82,8 +72,6 @@ in password = "firstlogin"; }; - system.stateVersion = "unstable"; - fileSystems."/" = { device = "/dev/disk/by-label/ROOT"; @@ -115,10 +103,4 @@ in swapDevices = [{ device = "/dev/disk/by-label/SWAP"; }]; - - nixpkgs.hostPlatform = lib.mkDefault config.conf.system; - hardware.cpu.${config.conf.cpu}.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - services.fstrim.enable = lib.mkDefault true; - nix.settings.auto-optimise-store = true; - networking.useDHCP = lib.mkDefault true; } diff --git a/base/default.nix b/base/default.nix index 6a582dd..8fd4f86 100644 --- a/base/default.nix +++ b/base/default.nix @@ -1,10 +1,8 @@ { imports = [ - ./big_g.nix - ./login_manager.nix ./env.nix ./xkb_layout.nix - ./base_packages.nix ./common_hardware.nix + ./theme.nix ]; } diff --git a/base/env.nix b/base/env.nix index 0591a20..d8cf336 100644 --- a/base/env.nix +++ b/base/env.nix @@ -1,7 +1,4 @@ -{ pkgs -, config -, ... -}: { +{ pkgs, config, ... }: { environment.variables = { GSETTINGS_SCHEMA_DIR = "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; NEOVIDE_MAXIMIZED = "0"; @@ -13,7 +10,7 @@ environment.sessionVariables = { NIXOS_OZONE_WL = "1"; GOPATH = "$HOME/.go"; - FLAKE = "home/${config.conf.username}/gits/dotFiles/nix"; + FLAKE = config.conf.nix_path; # don't ask... marksman somehow requires this DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1; }; diff --git a/base/extra.nix b/base/extra.nix deleted file mode 100644 index 96fb09e..0000000 --- a/base/extra.nix +++ /dev/null @@ -1 +0,0 @@ -{ options, ... }: options.extra.extraHardwareConfig diff --git a/base/login_manager.nix b/base/login_manager.nix deleted file mode 100644 index 37a3d7e..0000000 --- a/base/login_manager.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ lib -, config -, pkgs -, inputs -, ... -}: -let - username = config.conf.username; - session = { - command = "${lib.getExe inputs.hyprland.packages.${config.conf.system}.hyprland} --config /etc/greetd/hyprgreet.conf"; - user = username; - }; -in -{ - services.xserver.displayManager.session = [ - { - manage = "desktop"; - name = "Hyprland"; - start = '' - ${lib.getExe pkgs.hyprland} & waitPID=$! - ''; - } - ]; - - # greetd display manager - programs.hyprland.enable = true; - services.greetd = { - enable = true; - settings = { - terminal.vt = 1; - default_session = session; - }; - }; - - environment.etc."greetd/environments".text = '' - Hyprland - ''; - - # should technically be the same, but this is configured instead in order to provide a decent out of the box login experience. - environment.etc."greetd/hyprgreet.conf".text = '' - exec-once=gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' - - monitor=${config.conf.login_manager.monitor},${config.conf.login_manager.resolution},0x0,${config.conf.login_manager.scale} - monitor=_,disable - - input { - force_no_accel = true - } - - misc { - disable_splash_rendering = false - disable_hyprland_logo = false - } - - exec-once=regreet --style /home/${username}/.config/gtk-3.0/gtk.css; hyprctl dispatch exit - ''; - - # unlock GPG keyring on login - security.pam.services.greetd.enableGnomeKeyring = true; -} diff --git a/base/theme.nix b/base/theme.nix new file mode 100644 index 0000000..15d10c2 --- /dev/null +++ b/base/theme.nix @@ -0,0 +1,8 @@ +{ lib, config, ... }: { + # imports = lib.mkIf config.conf.default_base_packages.enable [ + imports = [ + # is wrapped in if statement to enable when needed + ../programs/gaming/default.nix + ../programs/themes/stylix.nix + ]; +} diff --git a/base/xkb_layout.nix b/base/xkb_layout.nix index 8238484..ecbc97c 100644 --- a/base/xkb_layout.nix +++ b/base/xkb_layout.nix @@ -19,5 +19,3 @@ in symbolsFile = "${layout}"; }; } - - diff --git a/hardware/marmo/configuration.nix b/hardware/marmo/configuration.nix index fbecd6f..3764ad0 100644 --- a/hardware/marmo/configuration.nix +++ b/hardware/marmo/configuration.nix @@ -22,5 +22,8 @@ amdgpu.enable = true; kde_connect.enable = true; xone.enable = true; + greetd = { + resolution = "3440x1440@180"; + }; }; } diff --git a/hardware/overheating/configuration.nix b/hardware/overheating/configuration.nix index 027bff1..6f79231 100644 --- a/hardware/overheating/configuration.nix +++ b/hardware/overheating/configuration.nix @@ -27,5 +27,8 @@ kde_connect.enable = true; bluetooth.enable = true; acpid.enable = true; + greetd = { + resolution = "3440x1440@180"; + }; }; } diff --git a/hardware/spaceship/configuration.nix b/hardware/spaceship/configuration.nix index f7e1ce7..cd2f8b7 100644 --- a/hardware/spaceship/configuration.nix +++ b/hardware/spaceship/configuration.nix @@ -10,9 +10,6 @@ in # config variables conf = { monitor = "DP-1"; - login_manager = { - resolution = "3440x1440@180"; - }; gaming = { enable = true; }; @@ -22,7 +19,7 @@ in monitor = [ # default "DP-2,2560x1440@165,0x0,1" - "DP-1,3440x1440@180,2560x0,1,vrr,1" + "DP-1,3440x1440@180,2560x0,1,vrr,0" "HDMI-A-1,1920x1200@60,6000x0,1" "HDMI-A-1,transform,1" @@ -84,9 +81,13 @@ in kde_connect.enable = true; xone.enable = true; amdgpu.enable = true; + piper.enable = true; vapi = { enable = true; rocm.enable = true; }; + greetd = { + resolution = "3440x1440@180"; + }; }; } diff --git a/modules/conf.nix b/modules/conf.nix index 7253eac..5e47826 100644 --- a/modules/conf.nix +++ b/modules/conf.nix @@ -141,7 +141,7 @@ monitor = lib.mkOption { default = [ ]; example = [ - "DP-1,3440x1440@180,2560x0,1,vrr,1" + "DP-1,3440x1440@180,2560x0,1,vrr,0" ]; type = with lib.types; listOf str; description = '' @@ -187,33 +187,31 @@ ''; }; - login_manager = { - monitor = lib.mkOption { - default = "${config.conf.monitor}"; - example = "eDP-1"; - type = lib.types.str; - description = '' - main monitor for the login screen. - By default the main monitor is used. - ''; - }; - scale = lib.mkOption { - default = "${config.conf.scale}"; - example = "1.5"; - type = lib.types.str; - description = '' - Scale used by the monitor in the login screen. - By default the scale of the main monitor is used. - ''; - }; - resolution = lib.mkOption { - default = "auto"; - example = "3440x1440@180"; - type = lib.types.str; - description = '' - Resolution/refreshrate used by the monitor in the login screen. - ''; - }; + nix_path = lib.mkOption { + default = "/home${config.conf.username}/gits/dotFiles"; + example = "yourpath"; + type = lib.types.str; + description = '' + The default path for your configuration. + ''; + }; + + kb_layout = lib.mkOption { + default = "dashie"; + example = "us"; + type = lib.types.str; + description = '' + The layout used in services. + ''; + }; + + system_state_version = lib.mkOption { + default = "unstable"; + example = "24.05"; + type = lib.types.str; + description = '' + System state version + ''; }; colorscheme = lib.mkOption { @@ -251,9 +249,15 @@ or a path to a custom yaml file. ''; }; + + }; config = { conf.kernel = lib.mkIf (config.conf.gaming.enable && config.conf.gaming.kernel) pkgs.linuxPackages_xanmod_latest; - }; + } // (lib.optionalAttrs (options?system.stateVersion) + { + system.stateVersion = "unstable"; + } + ); } diff --git a/modules/programs/base_packages.nix b/modules/programs/base_packages.nix new file mode 100644 index 0000000..8186448 --- /dev/null +++ b/modules/programs/base_packages.nix @@ -0,0 +1,104 @@ +{ config, lib, options, pkgs, ... }: { + options.mods = { + default_base_packages = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enables default system packages. + ''; + }; + additional_packages = lib.mkOption { + default = [ ]; + example = [ pkgs.openssl ]; + type = with lib.types; listOf packages; + description = '' + Additional packages to install. + Note that these are installed even if base packages is disabled, e.g. you can also use this as the only packages to install. + ''; + }; + }; + }; + + + config = + (lib.optionalAttrs (options?environment.systemPackages) + { + environment.systemPackages = config.mods.default_base_packages.additional_packages; + } // (lib.mkIf config.mods.default_base_packages.enable ( + lib.optionalAttrs + (options?environment.systemPackages) + { + environment.systemPackages = with pkgs; [ + openssl + dbus + glib + gtk4 + gtk3 + libadwaita + gtk-layer-shell + gtk4-layer-shell + direnv + dconf + gsettings-desktop-schemas + gnome.nixos-gsettings-overrides + bibata-cursors + xorg.xkbutils + libxkbcommon + icon-library + adwaita-icon-theme + hicolor-icon-theme + morewaita-icon-theme + kdePackages.breeze-icons + seahorse + upower + (lib.mkIf config.conf.streamdeck.enable (callPackage + ../../override/streamdeck.nix + { })) + ]; + + gtk.iconCache.enable = false; + + fonts.packages = with pkgs; [ + cantarell-fonts + ]; + + nix.settings.experimental-features = "nix-command flakes"; + + virtualisation.docker.enable = true; + + services.upower.enable = true; + services.dbus.enable = true; + services.dbus.packages = with pkgs; [ + gnome2.GConf + ]; + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + programs.fish.enable = true; + programs.fish.promptInit = '' + ${pkgs.any-nix-shell}/bin/any-nix-shell fish --info-right | source + ''; + programs.nix-ld.enable = true; + programs.nix-ld.libraries = with pkgs; [ + jdk + zlib + ]; + programs.direnv = { + package = pkgs.direnv; + silent = false; + loadInNixShell = true; + direnvrcExtra = ""; + nix-direnv = { + enable = true; + package = pkgs.nix-direnv; + }; + }; + programs.ssh.startAgent = true; + programs.gnupg.agent.enable = true; + }))); +} diff --git a/modules/programs/coding.nix b/modules/programs/coding.nix new file mode 100644 index 0000000..aa222ff --- /dev/null +++ b/modules/programs/coding.nix @@ -0,0 +1,134 @@ +{ lib, config, pkgs, options, ... }: { + options.mods = { + coding = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enables coding packages. + ''; + }; + dashvim = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enables dashvim package. + ''; + }; + }; + }; + + config = lib.mkIf config.mods.coding.enable (lib.optionalAttrs (options?home.packages) { + programs.dashvim = lib.mkIf config.mods.coding.dashvim { + enable = true; + colorscheme = config.conf.colorscheme; + }; + home.packages = with pkgs; [ + #basics + gitui + gcc + meson + ninja + tree-sitter + unzip + pkg-config + sqlite + plantuml + d-spy + + # cpp + bear + clang-tools + + #sql + nodePackages.sql-formatter + sqls + + #assembly + asm-lsp + + #yaml + yamlfmt + yamllint + yaml-language-server + + #markdown + marksman + mdformat + + #bash + bash-language-server + shfmt + + #fsharp + fsharp + fsautocomplete + + #haskell + haskellPackages.cabal-install + ghc + haskellPackages.haskell-language-server + + #html + html-tidy + + #json + jq + nodePackages.vscode-json-languageserver + + #css + tailwindcss + tailwindcss-language-server + vscode-langservers-extracted + + #editors + neovide + ##fallback + vscodium + + #rust + rustup + + #python + python3 + python312Packages.python-lsp-server + python312Packages.python-lsp-ruff + python312Packages.python-lsp-black + + #ts/js + nodejs_20 + deno + typescript + nodePackages.typescript-language-server + nodePackages.prettier + + #go + go + gopls + + #typst + typst + tinymist + ltex-ls + + #java + gradle + maven + jdt-language-server + temurin-jre-bin + + #.! + dotnet-sdk_8 + omnisharp-roslyn + csharpier + netcoredbg + + #zig + zig + zls + ]; + + }); +} diff --git a/modules/programs/default.nix b/modules/programs/default.nix index 5d1864d..92cc349 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -7,5 +7,14 @@ ./drives.nix ./bluetooth.nix ./acpid.nix + ./piper.nix + ./greetd.nix + ./gnome_services.nix + ./printing.nix + ./layout.nix + ./base_packages.nix + ./home_packages.nix + ./media.nix + ./flatpak.nix ]; } diff --git a/modules/programs/flatpak.nix b/modules/programs/flatpak.nix new file mode 100644 index 0000000..930cbef --- /dev/null +++ b/modules/programs/flatpak.nix @@ -0,0 +1,31 @@ +{ lib, config, options, pkgs, ... }: { + options.mods.flatpak = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables the flatpak package manager"; + }; + additional_packages = lib.mkOption { + default = [ ]; + example = [ ]; + type = with lib.types; listOf str; + description = "Flatpak packages"; + }; + }; + config = lib.mkIf config.mods.flatpak.enable + (lib.optionalAttrs (options?services.flatpak.remote) + { + services.flatpak.remotes = lib.mkOptionDefault [{ + name = "flathub-stable"; + location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; + }]; + services.flatpak.uninstallUnmanaged = true; + } // lib.optionalAttrs (options?services.flatpak.packages) { + services.flatpak.packages = [ + # fallback if necessary, but generally avoided as nix is superior :) + # default flatseal installation since flatpak permissions are totally not a broken idea + "com.github.tchx84.Flatseal" + ] ++ config.mods.flatpak.additional_packages; + }); +} diff --git a/modules/programs/gnome_services.nix b/modules/programs/gnome_services.nix new file mode 100644 index 0000000..96a6aa0 --- /dev/null +++ b/modules/programs/gnome_services.nix @@ -0,0 +1,28 @@ +{ lib, config, options, pkgs, ... }: { + + options.mods = { + gnome_services.enable = lib.mkOption { + default = true; + type = lib.types.bool; + example = false; + description = '' + Enables gnome services: keyring and settings daemon. + Note: Do not use these for environments which ship these functionalities by default: GNOME, KDE + ''; + }; + }; + + config = lib.mkIf config.mods.gnome_services.enable (lib.optionalAttrs (options?services.gnome.gnome-keyring) { + programs.dconf.enable = true; + services = { + # needed for GNOME services outside of GNOME Desktop + dbus.packages = with pkgs; [ + gcr + gnome.gnome-settings-daemon + ]; + + gnome.gnome-keyring.enable = true; + gvfs.enable = true; + }; + }); +} diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix new file mode 100644 index 0000000..b5ae800 --- /dev/null +++ b/modules/programs/greetd.nix @@ -0,0 +1,99 @@ +{ config, lib, inputs, pkgs, options, ... }: { + options.mods = { + greetd = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enables the greetd login manager. + ''; + }; + monitor = lib.mkOption { + default = "${config.conf.monitor}"; + example = "eDP-1"; + type = lib.types.str; + description = '' + main monitor for the login screen. + By default the main monitor is used. + ''; + }; + scale = lib.mkOption { + default = "${config.conf.scale}"; + example = "1.5"; + type = lib.types.str; + description = '' + Scale used by the monitor in the login screen. + By default the scale of the main monitor is used. + ''; + }; + resolution = lib.mkOption { + default = "auto"; + example = "3440x1440@180"; + type = lib.types.str; + description = '' + Resolution/refreshrate used by the monitor in the login screen. + ''; + }; + }; + }; + + config = + let + username = config.conf.username; + session = { + command = "${lib.getExe inputs.hyprland.packages.${config.conf.system}.hyprland} --config /etc/greetd/hyprgreet.conf"; + user = username; + }; + in + lib.mkIf config.mods.greetd.enable + (lib.optionalAttrs (options?environment) { + services.xserver.displayManager.session = [ + { + manage = "desktop"; + name = "Hyprland"; + start = '' + ${lib.getExe pkgs.hyprland} & waitPID=$! + ''; + } + ]; + + # greetd display manager + programs.hyprland.enable = true; + services.greetd = { + enable = true; + settings = { + terminal.vt = 1; + default_session = session; + }; + }; + + environment.etc."greetd/environments".text = '' + Hyprland + ''; + + # should technically be the same, but this is configured instead in order to provide a decent out of the box login experience. + environment.etc."greetd/hyprgreet.conf".text = '' + exec-once=gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' + + monitor=${config.mods.greetd.monitor},${config.mods.greetd.resolution},0x0,${config.mods.greetd.scale} + monitor=_,disable + + input { + kb_layout = ${config.mods.xkb.layout} + kb_variant = ${config.mods.xkb.variant} + force_no_accel = true + } + + misc { + disable_splash_rendering = false + disable_hyprland_logo = false + } + + exec-once=regreet --style /home/${username}/.config/gtk-3.0/gtk.css; hyprctl dispatch exit + ''; + + # unlock GPG keyring on login + security.pam.services.greetd.enableGnomeKeyring = true; + }); +} diff --git a/modules/programs/home_packages.nix b/modules/programs/home_packages.nix new file mode 100644 index 0000000..fe33b3e --- /dev/null +++ b/modules/programs/home_packages.nix @@ -0,0 +1,93 @@ +{ lib, options, config, pkgs, inputs, ... }: { + options.mods.home_packages = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Home manager packages"; + }; + additional_packages = lib.mkOption { + default = [ ]; + example = [ pkgs.flatpak ]; + type = lib.types.str; + description = '' + Additional Home manager packages. + Will be installed regardless of default home manager packages are installed. + ''; + }; + }; + config = + let + callPackage = lib.callPackageWith pkgs; + in + (lib.optionalAttrs (options?home.packages) + { + home.packages = config.mods.home_packages.additional_packages; + } // (lib.mkIf config.mods.home_packages.enable (lib.optionalAttrs (options?home.packages) { + home.packages = with pkgs; [ + keepassxc + nheko + nextcloud-client + xournalpp + vesktop + kitty + fish + ripgrep + rm-improved + bat + fd + lsd + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + noto-fonts + flatpak + networkmanager + zoxide + fastfetch + gnome-keyring + dbus + killall + adw-gtk3 + qt5ct + qt6ct + gnutar + fishPlugins.tide + nix-index + libnotify + zenith + nh + amberol + pulseaudio + playerctl + ncspot + poppler_utils + brave + greetd.regreet + sops + flake-checker + ffmpeg + system-config-printer + brightnessctl + (callPackage + ../../override/cambalache.nix + { }) + ]; + + #my own programs + programs.oxicalc.enable = true; + programs.oxinoti.enable = true; + programs.oxidash.enable = true; + programs.oxishut.enable = true; + programs.oxipaste.enable = true; + programs.hyprdock.enable = true; + programs.ReSet.enable = true; + programs.ReSet.config.plugins = [ + inputs.reset-plugins.packages."x86_64-linux".monitor + inputs.reset-plugins.packages."x86_64-linux".keyboard + ]; + programs.ReSet.config.plugin_config = { + Keyboard = { + path = "/home/${config.conf.username}/.config/reset/keyboard.conf"; + }; + }; + }))); +} diff --git a/modules/programs/layout.nix b/modules/programs/layout.nix new file mode 100644 index 0000000..a6cb853 --- /dev/null +++ b/modules/programs/layout.nix @@ -0,0 +1,23 @@ +{ lib, options, config, ... }: { + options.mods.xkb = { + layout = lib.mkOption { + default = "dashie"; + example = "us"; + type = lib.types.str; + description = "Your layout"; + }; + variant = lib.mkOption { + default = ""; + example = ""; + type = lib.types.str; + description = "Your variant"; + }; + }; + config = (lib.optionalAttrs (options?services.xserver) { + # Configure keymap in X11 + services.xserver = { + xkb.layout = "${config.mods.xkb.layout}"; + xkb.variant = "${config.mods.xkb.variant}"; + }; + }); +} diff --git a/modules/programs/media.nix b/modules/programs/media.nix new file mode 100644 index 0000000..ff52e4d --- /dev/null +++ b/modules/programs/media.nix @@ -0,0 +1,56 @@ +{ lib, options, config, pkgs, ... }: { + options.mods.media_packages = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Default media packages"; + }; + additional_packages = lib.mkOption { + default = [ ]; + example = [ pkgs.flatpak ]; + type = lib.types.str; + description = '' + Additional media packages. + Will be installed regardless of default media packages are installed. + ''; + }; + }; + config = + (lib.optionalAttrs (options?home.packages) + { + home.packages = config.mods.media_packages.additional_packages; + } // (lib.mkIf config.mods.media_packages.enable (lib.optionalAttrs (options?home.packages) { + home.packages = with pkgs; [ + # base audio + pipewire + wireplumber + # audio control + playerctl + # images + imv + # videos + mpv + # pdf + zathura + evince + libreoffice-fresh + onlyoffice-bin + pdftk + pdfpc + polylux2pdfpc + # spotify + # video editing + kdenlive + # image creation + inkscape + gimp + krita + yt-dlp + ]; + programs.obs-studio.enable = true; + programs.obs-studio.plugins = with pkgs; [ + obs-studio-plugins.obs-vaapi + ]; + }))); +} diff --git a/modules/programs/piper.nix b/modules/programs/piper.nix new file mode 100644 index 0000000..fe45bfb --- /dev/null +++ b/modules/programs/piper.nix @@ -0,0 +1,19 @@ +{ lib, config, options, pkgs, ... }: { + options.mods.piper = { + enable = lib.mkOption { + default = false; + example = true; + type = lib.types.bool; + description = "Enables the piper program and its daemon"; + }; + }; + config = lib.mkIf config.mods.piper.enable + (lib.optionalAttrs (options?services.ratbagd) + { + services.ratbagd.enable = true; + } // lib.optionalAttrs (options?home.packages) { + home.packages = with pkgs; [ + piper + ]; + }); +} diff --git a/modules/programs/printing.nix b/modules/programs/printing.nix new file mode 100644 index 0000000..cbb18e5 --- /dev/null +++ b/modules/programs/printing.nix @@ -0,0 +1,24 @@ +{ lib, config, options, pkgs, ... }: { + options.mods.printing = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables the piper program and its daemon"; + }; + }; + config = lib.mkIf config.mods.printing.enable + (lib.optionalAttrs (options?services.printing) + { + # Enable CUPS to print documents. + services.printing.enable = true; + services.printing.browsing = true; + services.printing.drivers = [ pkgs.hplip ]; + services.printing.startWhenNeeded = true; # optional + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + }); +} diff --git a/programs/coding.nix b/programs/coding.nix deleted file mode 100644 index 68b4a38..0000000 --- a/programs/coding.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ pkgs -, lib -, config -, ... -}: -{ - programs.dashvim = { - enable = true; - colorscheme = config.conf.colorscheme; - }; - - home.packages = with pkgs; [ - #basics - gitui - gcc - meson - ninja - tree-sitter - unzip - pkg-config - sqlite - plantuml - d-spy - - # cpp - bear - clang-tools - - #sql - nodePackages.sql-formatter - sqls - - #assembly - asm-lsp - - #yaml - yamlfmt - yamllint - yaml-language-server - - #markdown - marksman - mdformat - - #bash - bash-language-server - shfmt - - #fsharp - fsharp - fsautocomplete - - #haskell - haskellPackages.cabal-install - ghc - haskellPackages.haskell-language-server - - #html - html-tidy - - #json - jq - nodePackages.vscode-json-languageserver - - #css - tailwindcss - tailwindcss-language-server - vscode-langservers-extracted - - #editors - neovide - ##fallback - vscodium - - #rust - rustup - - #python - python3 - python312Packages.python-lsp-server - python312Packages.python-lsp-ruff - python312Packages.python-lsp-black - - #ts/js - nodejs_20 - deno - typescript - nodePackages.typescript-language-server - nodePackages.prettier - - #go - go - gopls - - #typst - typst - tinymist - ltex-ls - - #java - gradle - maven - jdt-language-server - temurin-jre-bin - - #.! - dotnet-sdk_8 - omnisharp-roslyn - csharpier - netcoredbg - - #zig - zig - zls - ]; -} diff --git a/programs/common.nix b/programs/common.nix index 49f0074..02d3034 100644 --- a/programs/common.nix +++ b/programs/common.nix @@ -1,11 +1,5 @@ -{ pkgs -, inputs -, lib -, config -, ... -}: +{ config, ... }: let - callPackage = lib.callPackageWith (pkgs); username = config.conf.username; in { @@ -16,68 +10,6 @@ in }; fonts.fontconfig.enable = true; - home.packages = with pkgs; [ - vesktop - kitty - fish - ripgrep - rm-improved - bat - fd - lsd - (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) - noto-fonts - flatpak - networkmanager - zoxide - fastfetch - pkgs.gnome-keyring - dbus - killall - adw-gtk3 - qt5ct - qt6ct - gnutar - fishPlugins.tide - nix-index - libnotify - zenith - nh - amberol - pulseaudio - playerctl - ncspot - poppler_utils - brave - greetd.regreet - sops - flake-checker - ffmpeg - system-config-printer - brightnessctl - (callPackage - ../override/cambalache.nix - { }) - ]; - - #my own programs - programs.oxicalc.enable = true; - programs.oxinoti.enable = true; - programs.oxidash.enable = true; - programs.oxishut.enable = true; - programs.oxipaste.enable = true; - programs.hyprdock.enable = true; - programs.ReSet.enable = true; - programs.ReSet.config.plugins = [ - inputs.reset-plugins.packages."x86_64-linux".monitor - inputs.reset-plugins.packages."x86_64-linux".keyboard - ]; - programs.ReSet.config.plugin_config = { - Keyboard = { - path = "/home/${username}/.config/reset/keyboard.conf"; - }; - }; - nixpkgs.config.allowUnfree = true; home.username = username; @@ -98,15 +30,6 @@ in [Context] filesystems=xdg-config/gtk-3.0;xdg-config/gtk-4.0 ''; - # - # dconf.settings = { - # "org/gnome/desktop/interface" = { - # gtk-theme = "adw-gtk3"; - # cursor-theme = "Bibata-Modern-Classic"; - # cursor-size = 24; - # icon-theme = "MoreWaita"; - # }; - # }; programs.nix-index = { diff --git a/programs/default.nix b/programs/default.nix index a0e4b2f..e0d86cd 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -33,12 +33,8 @@ in home-manager.users.${config.conf.username} = { imports = [ ./hyprland/default.nix - ./flatpak.nix ./common.nix - ./coding.nix ./xdg.nix - ./media.nix - ./utils.nix ./oxi/default.nix ./themes/default.nix ./individual_configs/default.nix diff --git a/programs/flatpak.nix b/programs/flatpak.nix deleted file mode 100644 index 4abc89d..0000000 --- a/programs/flatpak.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib, ... }: { - - services.flatpak.remotes = lib.mkOptionDefault [{ - name = "flathub-stable"; - location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; - }]; - services.flatpak.uninstallUnmanaged = true; - services.flatpak.packages = [ - # fallback if necessary, but generally avoided as nix is superior :) - "com.github.tchx84.Flatseal" - "io.github.Foldex.AdwSteamGtk" - ]; -} - diff --git a/programs/hyprland/config.nix b/programs/hyprland/config.nix index 4673dd6..df90cfc 100644 --- a/programs/hyprland/config.nix +++ b/programs/hyprland/config.nix @@ -151,7 +151,8 @@ }; input = { - #kb_layout = "dashie"; + kb_layout = "{config.mods.xkb.layout}"; + kb_variant = "{config.mods.xkb.variant}"; repeat_delay = 200; force_no_accel = true; touchpad = { @@ -168,11 +169,14 @@ disable_hyprland_logo = true; swallow_regex = "^(.*)(kitty)(.*)$"; initial_workspace_tracking = 1; + no_direct_scanout = false; }; cursor = { # conversion seems to be borked right now, i want a smooth bibata :( enable_hyprcursor = false; + no_hardware_cursors = true; + no_break_fs_vrr = true; }; gestures = { diff --git a/programs/media.nix b/programs/media.nix deleted file mode 100644 index cf205c6..0000000 --- a/programs/media.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, ... }: -{ - home.packages = with pkgs; [ - # base audio - pipewire - wireplumber - # audio control - playerctl - # images - imv - # videos - mpv - # pdf - zathura - evince - libreoffice-fresh - onlyoffice-bin - pdftk - pdfpc - polylux2pdfpc - # spotify - # video editing - kdenlive - # image creation - inkscape - gimp - krita - yt-dlp - ]; - programs.obs-studio.enable = true; - programs.obs-studio.plugins = with pkgs; [ - obs-studio-plugins.obs-vaapi - ]; -} diff --git a/programs/utils.nix b/programs/utils.nix deleted file mode 100644 index 16960d3..0000000 --- a/programs/utils.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs -, ... -}: -{ - home.packages = with pkgs; [ - keepassxc - nheko - nextcloud-client - xournalpp - ]; -}