diff --git a/flake.nix b/flake.nix index 9566a13..852eae2 100644 --- a/flake.nix +++ b/flake.nix @@ -92,7 +92,8 @@ importDir = dir: (lib.attrsets.mapAttrs' ( - m: _: lib.attrsets.nameValuePair (lib.strings.removeSuffix ".nix" m) (import "${dir}/${m}") + m: _: + lib.attrsets.nameValuePair (lib.strings.removeSuffix ".nix" m) { imports = [ "${dir}/${m}" ]; } ) (builtins.readDir dir)); in rec { @@ -113,6 +114,16 @@ stateVersion = "22.11"; autoUpgrade.flake = "git+https://git.berlin.ccc.de/vinzenz/nixos-configuration.git"; }; + + nixpkgs.overlays = [ + overlays.unstable-packages + overlays.zerforschen + ]; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; } ./hosts/${device}/hardware.nix @@ -124,27 +135,25 @@ self.nixosModules.autoupdate self.nixosModules.openssh self.nixosModules.tailscale + self.nixosModules.allowed-unfree-list + self.nixosModules.extra-caches ./modules/nixpkgs.nix - - { - nixpkgs.overlays = [ - overlays.unstable-packages - overlays.zerforschen - ]; - } ] ++ (nixpkgs.lib.optionals (builtins.elem device homeDevices) [ { home-manager.extraSpecialArgs = specialArgs; time.timeZone = "Europe/Berlin"; + + home-manager.sharedModules = [ + self.homeModules.adwaita + ]; } self.nixosModules.pkgs-unstable self.nixosModules.niri self.nixosModules.kdeconnect self.nixosModules.en-de - self.nixosModules.adwaita self.nixosModules.gnome ./modules/home-manager.nix @@ -178,6 +187,8 @@ }; }; + homeModules = importDir ./homeModules; + formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-tree); }; } diff --git a/nixosModules/adwaita.nix b/homeModules/adwaita.nix similarity index 100% rename from nixosModules/adwaita.nix rename to homeModules/adwaita.nix diff --git a/hosts/ronja-pc/imports.nix b/hosts/ronja-pc/imports.nix index 8b9ed4b..ca628cc 100644 --- a/hosts/ronja-pc/imports.nix +++ b/hosts/ronja-pc/imports.nix @@ -1,7 +1,9 @@ +{ nixosModules, ... }: { imports = [ ../../modules/gnome.nix ../../modules/gaming.nix + nixosModules.steam ../../modules/desktop-environment.nix ../../modules/desktop-hardware.nix diff --git a/hosts/vinzenz-lpt2/imports.nix b/hosts/vinzenz-lpt2/imports.nix index 751d35b..9335800 100644 --- a/hosts/vinzenz-lpt2/imports.nix +++ b/hosts/vinzenz-lpt2/imports.nix @@ -3,6 +3,7 @@ imports = [ ../../modules/gnome.nix ../../modules/gaming.nix + nixosModules.steam nixosModules.printing nixosModules.podman ../../modules/desktop-environment.nix diff --git a/hosts/vinzenz-pc2/imports.nix b/hosts/vinzenz-pc2/imports.nix index 73bf957..ca29682 100644 --- a/hosts/vinzenz-pc2/imports.nix +++ b/hosts/vinzenz-pc2/imports.nix @@ -3,6 +3,7 @@ imports = [ ../../modules/gnome.nix ../../modules/gaming.nix + nixosModules.steam nixosModules.printing nixosModules.podman #../../modules/niri.nix diff --git a/modules/desktop-environment.nix b/modules/desktop-environment.nix index 50d6245..1f1efe0 100644 --- a/modules/desktop-environment.nix +++ b/modules/desktop-environment.nix @@ -56,6 +56,7 @@ enable = true; binfmt = true; }; + xwayland.enable = true; }; systemd = { diff --git a/modules/gaming.nix b/modules/gaming.nix index 4214c23..478c200 100644 --- a/modules/gaming.nix +++ b/modules/gaming.nix @@ -8,7 +8,6 @@ extraPackages32 = with pkgs; [ mangohud ]; }; - steam-hardware.enable = true; xpadneo.enable = true; }; @@ -23,59 +22,9 @@ lutris ]; - programs = { - xwayland.enable = true; - steam = { - enable = true; - remotePlay.openFirewall = true; - dedicatedServer.openFirewall = true; - localNetworkGameTransfers.openFirewall = true; - gamescopeSession.enable = false; - }; - gamemode.enable = true; - }; - - networking.firewall = { - allowedUDPPorts = [ - # Factorio - 34197 - - # steam network transfer - 3478 - ]; - - allowedTCPPorts = [ - # steam network transfer - 24070 - ]; - - allowedTCPPortRanges = [ - # steam network transfer - { - from = 27015; - to = 27050; - } - ]; - - allowedUDPPortRanges = [ - # steam network transfer - { - from = 4379; - to = 4380; - } - { - from = 27000; - to = 27100; - } - ]; - }; - - allowedUnfreePackages = [ - "steam" - "steam-original" - "steam-run" - "steam-unwrapped" - "ut1999" + networking.firewall.allowedUDPPorts = [ + # Factorio + 34197 ]; }; } diff --git a/modules/nixpkgs.nix b/modules/nixpkgs.nix index 5fdb60d..7fb99a7 100644 --- a/modules/nixpkgs.nix +++ b/modules/nixpkgs.nix @@ -1,41 +1,9 @@ -{ config, lib, ... }: { - options.allowedUnfreePackages = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ ]; - example = [ "steam" ]; - }; - config = { - nixpkgs.config = { - # https://github.com/NixOS/nixpkgs/issues/197325#issuecomment-1579420085 - allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.allowedUnfreePackages; - }; - - nix.settings = { - substituters = [ - "https://cache.nixos.org/" - "https://nix-community.cachix.org" - "https://cache.lix.systems" - "https://niri.cachix.org" - ]; - trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=" - "niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964=" - ]; - experimental-features = [ - "nix-command" - "flakes" - ]; - }; - - documentation = { - enable = true; # documentation of packages - nixos.enable = false; # nixos documentation - man.enable = true; # manual pages and the man command - info.enable = false; # info pages and the info command - doc.enable = false; # documentation distributed in packages' /share/doc - }; + documentation = { + enable = true; # documentation of packages + nixos.enable = false; # nixos documentation + man.enable = true; # manual pages and the man command + info.enable = false; # info pages and the info command + doc.enable = false; # documentation distributed in packages' /share/doc }; } diff --git a/nixosModules/allowed-unfree-list.nix b/nixosModules/allowed-unfree-list.nix new file mode 100644 index 0000000..a5583cf --- /dev/null +++ b/nixosModules/allowed-unfree-list.nix @@ -0,0 +1,15 @@ +{ lib, config, ... }: +{ + options.allowedUnfreePackages = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + example = [ "steam" ]; + }; + + config = { + nixpkgs.config = { + # https://github.com/NixOS/nixpkgs/issues/197325#issuecomment-1579420085 + allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.allowedUnfreePackages; + }; + }; +} diff --git a/nixosModules/extra-caches.nix b/nixosModules/extra-caches.nix new file mode 100644 index 0000000..6af372f --- /dev/null +++ b/nixosModules/extra-caches.nix @@ -0,0 +1,16 @@ +{ + nix.settings = { + substituters = [ + "https://cache.nixos.org/" + "https://nix-community.cachix.org" + "https://cache.lix.systems" + "https://niri.cachix.org" + ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=" + "niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964=" + ]; + }; +} diff --git a/nixosModules/steam.nix b/nixosModules/steam.nix new file mode 100644 index 0000000..6e3c997 --- /dev/null +++ b/nixosModules/steam.nix @@ -0,0 +1,48 @@ +{ nixosModules, ... }: +{ + imports = [ nixosModules.allowed-unfree-list ]; + + hardware.steam-hardware.enable = true; + + programs = { + steam = { + enable = true; + remotePlay.openFirewall = true; + dedicatedServer.openFirewall = true; + localNetworkGameTransfers.openFirewall = true; + gamescopeSession.enable = false; + }; + gamemode.enable = true; + }; + + # steam network transfer + networking.firewall = { + allowedUDPPorts = [ 3478 ]; + allowedTCPPorts = [ 24070 ]; + + allowedTCPPortRanges = [ + { + from = 27015; + to = 27050; + } + ]; + + allowedUDPPortRanges = [ + { + from = 4379; + to = 4380; + } + { + from = 27000; + to = 27100; + } + ]; + }; + + allowedUnfreePackages = [ + "steam" + "steam-original" + "steam-run" + "steam-unwrapped" + ]; +}