diff --git a/common/gui/default.nix b/common/gui/default.nix index fda0dd1..a81a95f 100644 --- a/common/gui/default.nix +++ b/common/gui/default.nix @@ -1,5 +1,9 @@ {lib, ...}: { - imports = [./thunar.nix]; + imports = [ + ./thunar.nix + ./steam.nix + ]; thunar.enable = lib.mkDefault true; + steam.enable = lib.mkDefault false; } diff --git a/common/gui/steam.nix b/common/gui/steam.nix index 84aa9a3..2cb7b47 100644 --- a/common/gui/steam.nix +++ b/common/gui/steam.nix @@ -4,44 +4,48 @@ pkgs, ... }: { - hardware.opengl.driSupport32Bit = true; - - nixpkgs.config.packageOverrides = pkgs: { - steam = pkgs.steam.override { - extraPkgs = pkgs: - with pkgs; [ - xorg.libXcursor - xorg.libXi - xorg.libXinerama - xorg.libXScrnSaver - libpng - libpulseaudio - libvorbis - stdenv.cc.cc.lib - libkrb5 - keyutils - ]; - }; + options = { + steam.enable = lib.mkEnableOption "Enables steam"; }; - programs.steam = { - enable = true; - remotePlay.openFirewall = true; - gamescopeSession = { + config = lib.mkIf config.steam.enable { + hardware.opengl.driSupport32Bit = true; + + nixpkgs.config.packageOverrides = pkgs: { + steam = pkgs.steam.override { + extraPkgs = pkgs: + with pkgs; [ + xorg.libXcursor + xorg.libXi + xorg.libXinerama + xorg.libXScrnSaver + libpng + libpulseaudio + libvorbis + stdenv.cc.cc.lib + libkrb5 + keyutils + ]; + }; + }; + + programs.steam = { enable = true; - args = [ - "-F fsr" - "-f" - ]; + remotePlay.openFirewall = true; + gamescopeSession = { + enable = true; + args = [ + "-F fsr" + "-f" + ]; + }; }; - }; - environment.sessionVariables = { - # Proton GE flag - WINE_FULLSCREEN_FSR = "1"; - }; + environment.sessionVariables = { + # Proton GE flag + WINE_FULLSCREEN_FSR = "1"; + }; - environment.systemPackages = with pkgs; [ - protonup - ]; + environment.systemPackages = with pkgs; [protonup]; + }; } diff --git a/common/nixos/bluetooth.nix b/common/nixos/bluetooth.nix index bcf60ba..eaff4f0 100644 --- a/common/nixos/bluetooth.nix +++ b/common/nixos/bluetooth.nix @@ -1,9 +1,21 @@ -{...}: { - services.blueman.enable = true; - hardware.bluetooth = { - enable = true; - powerOnBoot = true; +{ + config, + lib, + ... +}: { + options = { + bluetooth.enable = lib.mkEnableOption "Enables Bluetooth"; }; - services.upower = {enable = true;}; + config = lib.mkIf config.bluetooth.enable { + services.blueman.enable = true; + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; + + services.upower = { + enable = true; + }; + }; } diff --git a/common/nixos/default.nix b/common/nixos/default.nix new file mode 100644 index 0000000..e6d3920 --- /dev/null +++ b/common/nixos/default.nix @@ -0,0 +1,13 @@ +{lib, ...}: { + imports = [ + ./common.nix + ./laptop.nix + ./nfs.nix + ./restic.nix + ./ssh/default.nix + ]; + + laptop.enable = lib.mkDefault false; + nfs.enable = lib.mkDefault false; + restic.enable = lib.mkDefault true; +} diff --git a/common/nixos/laptop.nix b/common/nixos/laptop.nix index 8d37c61..1dbf5d3 100644 --- a/common/nixos/laptop.nix +++ b/common/nixos/laptop.nix @@ -1,8 +1,20 @@ -{...}: { +{ + config, + lib, + ... +}: { imports = [./bluetooth.nix]; - # enable's backlight switching - programs.light.enable = true; + options = { + laptop.enable = lib.mkEnableOption "Enables Laptop options"; + }; - # use TLP for power management - services.tlp.enable = true; + config = lib.mkIf config.laptop.enable { + # enable's backlight switching + programs.light.enable = true; + + # use TLP for power management + services.tlp.enable = true; + + bluetooth.enable = true; + }; } diff --git a/common/nixos/nfs.nix b/common/nixos/nfs.nix index 21f70e5..0804fa2 100644 --- a/common/nixos/nfs.nix +++ b/common/nixos/nfs.nix @@ -1,33 +1,68 @@ -{...}: { - fileSystems = { - "/media" = { - device = "192.168.10.2:/mnt/tank/media"; - fsType = "nfs"; - options = ["x-systemd.automount" "noauto" "x-systemd.after=network-online.target" "x-systemd.mount-timeout=90"]; - }; +{ + config, + lib, + ... +}: { + options = { + nfs.enable = lib.mkEnableOption "Enables NFS and sets up mounts"; + }; - "/books" = { - device = "192.168.10.2:/mnt/tank/books"; - fsType = "nfs"; - options = ["x-systemd.automount" "noauto" "x-systemd.after=network-online.target" "x-systemd.mount-timeout=90"]; - }; + config = lib.mkIf config.nfs.enable { + fileSystems = { + "/media" = { + device = "192.168.10.2:/mnt/tank/media"; + fsType = "nfs"; + options = [ + "x-systemd.automount" + "noauto" + "x-systemd.after=network-online.target" + "x-systemd.mount-timeout=90" + ]; + }; - "/music" = { - device = "192.168.10.2:/mnt/tank/music"; - fsType = "nfs"; - options = ["x-systemd.automount" "noauto" "x-systemd.after=network-online.target" "x-systemd.mount-timeout=90"]; - }; + "/books" = { + device = "192.168.10.2:/mnt/tank/books"; + fsType = "nfs"; + options = [ + "x-systemd.automount" + "noauto" + "x-systemd.after=network-online.target" + "x-systemd.mount-timeout=90" + ]; + }; - "/projects" = { - device = "192.168.10.2:/mnt/tank/projects"; - fsType = "nfs"; - options = ["x-systemd.automount" "noauto" "x-systemd.after=network-online.target" "x-systemd.mount-timeout=90"]; - }; + "/music" = { + device = "192.168.10.2:/mnt/tank/music"; + fsType = "nfs"; + options = [ + "x-systemd.automount" + "noauto" + "x-systemd.after=network-online.target" + "x-systemd.mount-timeout=90" + ]; + }; - "/backups" = { - device = "192.168.10.2:/mnt/tank/backups"; - fsType = "nfs"; - options = ["x-systemd.automount" "noauto" "x-systemd.after=network-online.target" "x-systemd.mount-timeout=90"]; + "/projects" = { + device = "192.168.10.2:/mnt/tank/projects"; + fsType = "nfs"; + options = [ + "x-systemd.automount" + "noauto" + "x-systemd.after=network-online.target" + "x-systemd.mount-timeout=90" + ]; + }; + + "/backups" = { + device = "192.168.10.2:/mnt/tank/backups"; + fsType = "nfs"; + options = [ + "x-systemd.automount" + "noauto" + "x-systemd.after=network-online.target" + "x-systemd.mount-timeout=90" + ]; + }; }; }; } diff --git a/common/nixos/restic.nix b/common/nixos/restic.nix index 808cb65..83bc439 100644 --- a/common/nixos/restic.nix +++ b/common/nixos/restic.nix @@ -1,21 +1,33 @@ { config, + lib, user, ... }: { - sops.secrets.restic_key = { - owner = config.users.users.${user}.name; + options = { + restic.enable = lib.mkEnableOption "Enables Restic"; }; - services.restic.backups = { - backups = { - user = "${user}"; - repository = "/backups"; - initialize = true; - passwordFile = "${config.sops.secrets.restic_key.path}"; - paths = ["/home/${user}/repos" "/home/${user}/Documents" "/home/${user}/.local/share/password-store" "/home/${user}/.local/share/buku"]; - timerConfig = { - onCalendar = "saturday 23:00"; + config = lib.mkIf config.nfs.enable { + sops.secrets.restic_key = { + owner = config.users.users.${user}.name; + }; + + services.restic.backups = { + backups = { + user = "${user}"; + repository = "/backups"; + initialize = true; + passwordFile = "${config.sops.secrets.restic_key.path}"; + paths = [ + "/home/${user}/repos" + "/home/${user}/Documents" + "/home/${user}/.local/share/password-store" + "/home/${user}/.local/share/buku" + ]; + timerConfig = { + onCalendar = "saturday 23:00"; + }; }; }; }; diff --git a/hosts/candlekeep/configuration.nix b/hosts/candlekeep/configuration.nix index aeea012..60141de 100644 --- a/hosts/candlekeep/configuration.nix +++ b/hosts/candlekeep/configuration.nix @@ -5,7 +5,6 @@ outputs, lib, config, - pkgs, user, ... }: { @@ -14,21 +13,14 @@ # If you want to use modules your own flake exports (from modules/nixos): # outputs.nixosModules.example ../../common/nixos/common.nix - ../../common/nixos/laptop.nix - ../../common/networking/default.nix - ../../common/nixos/bluetooth.nix - ../../common/nixos/restic.nix - ../../common/nixos/ssh/ssh.nix - ../../common/gui/steam.nix - ../../common/nixos/ssh/ssh_client.nix - ../../common/nixos/ssh/ssh_guard.nix ../../common/gui/hyprland.nix - ../../common/gui/default.nix ../../common/style/stylix.nix - ../../common/virtualization/default.nix - ../../common/nixos/sysctl/default.nix + ../../common/nixos/sysctl ../../common/networking + ../../common/nixos + ../../common/gui + ../../common/virtualization ./auditd.nix ./kernel.nix @@ -49,6 +41,11 @@ ./hardware-configuration.nix ]; + laptop.enable = true; + nfs.enable = true; + ssh.enable = true; + ssh_guard.enable = true; + # Bootloader. boot = { loader = {