diff --git a/nix/configuration/roles/ssh/default.nix b/nix/configuration/roles/ssh/default.nix index a73875c..ba69def 100644 --- a/nix/configuration/roles/ssh/default.nix +++ b/nix/configuration/roles/ssh/default.nix @@ -20,4 +20,12 @@ ]; }; }; + + home-manager.users.talexander = + { pkgs, ... }: + { + home.file.".ssh/config" = { + source = ./files/ssh_config; + }; + }; } diff --git a/nix/configuration/roles/ssh/files/ssh_config b/nix/configuration/roles/ssh/files/ssh_config new file mode 100644 index 0000000..31c0f00 --- /dev/null +++ b/nix/configuration/roles/ssh/files/ssh_config @@ -0,0 +1,34 @@ +Host poudriere + ProxyJump talexander@mrmanager + HostName 10.215.1.203 + +Host controller0 + ProxyJump talexander@mrmanager + HostName 10.215.1.204 + +Host controller1 + ProxyJump talexander@mrmanager + HostName 10.215.1.205 + +Host controller2 + ProxyJump talexander@mrmanager + HostName 10.215.1.206 + +Host worker0 + ProxyJump talexander@mrmanager + HostName 10.215.1.207 + +Host worker1 + ProxyJump talexander@mrmanager + HostName 10.215.1.208 + +Host worker2 + ProxyJump talexander@mrmanager + HostName 10.215.1.209 + +Host brianai + ProxyJump talexander@mrmanager + HostName 10.215.1.215 + +Host * + Compression yes diff --git a/nix/steam_deck/configuration/flake.lock b/nix/steam_deck/configuration/flake.lock index bcf4c6b..491c594 100644 --- a/nix/steam_deck/configuration/flake.lock +++ b/nix/steam_deck/configuration/flake.lock @@ -1,12 +1,83 @@ { "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739314552, + "narHash": "sha256-ggVf2BclyIW3jexc/uvgsgJH4e2cuG6Nyg54NeXgbFI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "83bd3a26ac0526ae04fa74df46738bb44b89dcdd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "locked": { + "lastModified": 1737831083, + "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "nix-community", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixGL", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1739019272, - "narHash": "sha256-7Fu7oazPoYCbDzb9k8D/DdbKrC3aU1zlnc39Y8jy/s8=", + "lastModified": 1739138025, + "narHash": "sha256-M4ilIfGxzbBZuURokv24aqJTbdjPA9K+DtKUzrJaES4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "fa35a3c8e17a3de613240fea68f876e5b4896aec", + "rev": "b2243f41e860ac85c0b446eadc6930359b294e79", "type": "github" }, "original": { @@ -18,6 +89,9 @@ }, "root": { "inputs": { + "home-manager": "home-manager", + "impermanence": "impermanence", + "nixgl": "nixgl", "nixpkgs": "nixpkgs" } } diff --git a/nix/steam_deck/configuration/flake.nix b/nix/steam_deck/configuration/flake.nix index 1b41f40..b1fbdbd 100644 --- a/nix/steam_deck/configuration/flake.nix +++ b/nix/steam_deck/configuration/flake.nix @@ -3,34 +3,52 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixgl.url = "github:nix-community/nixGL"; + nixgl.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + impermanence = { + url = "github:nix-community/impermanence"; + }; }; outputs = { nixpkgs, + nixgl, + home-manager, + impermanence, ... }: let system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + overlays = [ nixgl.overlay ]; + }; in + # pkgs = nixpkgs.legacyPackages.${system}; { - packages.${system}.default = pkgs.buildEnv { - name = "default"; - paths = [ - pkgs.emacs - pkgs.mg - pkgs.steam-rom-manager + defaultPackage.${system} = home-manager.defaultPackage.${system}; + homeConfigurations."deck" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + extraSpecialArgs = { inherit nixgl; }; + + modules = [ + { nixpkgs.overlays = [ nixgl.overlay ]; } + impermanence.homeManagerModules.impermanence + ./hosts/deck + ./home.nix ]; }; - - formatter.${system} = pkgs.nixfmt-rfc-style; - # formatter.${system} = pkgs.alejandra; }; - # nixConfig = { - # experimental-features = [ - # "nix-command" - # "flakes" - # ]; - # }; + nixConfig = { + experimental-features = [ + "nix-command" + "flakes" + ]; + }; } diff --git a/nix/steam_deck/configuration/home.nix b/nix/steam_deck/configuration/home.nix new file mode 100644 index 0000000..cbb12f9 --- /dev/null +++ b/nix/steam_deck/configuration/home.nix @@ -0,0 +1,52 @@ +# TODO: Optimize for znver2 +{ + config, + pkgs, + nixgl, + ... +}: +{ + imports = [ + ./roles/2ship2harkinian + ./roles/graphics + ./roles/shipwright + ./roles/sm64ex + ./roles/steam_rom_manager + ./util/unfree_polyfill + ]; + + home.username = "deck"; + home.homeDirectory = "/home/deck"; + home.stateVersion = "24.11"; + + programs.home-manager.enable = true; + + # enable flakes + nix = { + package = pkgs.nix; + settings.experimental-features = [ + "nix-command" + "flakes" + ]; + }; + # Automatic garbage collection + nix.gc = { + # Runs nix-collect-garbage --delete-older-than 30d + automatic = true; + randomizedDelaySec = "14m"; + options = "--delete-older-than 30d"; + }; + nix.settings.auto-optimise-store = true; + + home.packages = with pkgs; [ + pkgs.nixgl.nixGLIntel + (pkgs.nixgl.nixGLCommon pkgs.nixgl.nixGLIntel) + pkgs.nixgl.nixVulkanIntel + ]; + + # This would keep build-time dependencies so I can rebuild while offline. + # nix.settings = { + # keep-outputs = true; + # keep-derivations = true; + # }; +} diff --git a/nix/steam_deck/configuration/hosts/deck/default.nix b/nix/steam_deck/configuration/hosts/deck/default.nix new file mode 100644 index 0000000..fb5c5e5 --- /dev/null +++ b/nix/steam_deck/configuration/hosts/deck/default.nix @@ -0,0 +1,18 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + config = { + me.graphical = true; + me.ship2harkinian.enable = true; + me.shipwright.enable = true; + me.sm64ex.enable = true; + me.steam_rom_manager.enable = true; # Steam rom manager UI does not render. I think it wants to be in an AppImage. + }; +} diff --git a/nix/steam_deck/configuration/roles/2ship2harkinian/default.nix b/nix/steam_deck/configuration/roles/2ship2harkinian/default.nix new file mode 100644 index 0000000..2447746 --- /dev/null +++ b/nix/steam_deck/configuration/roles/2ship2harkinian/default.nix @@ -0,0 +1,78 @@ +# MANUAL: mkdir -p ~/.persist/.local/share/2ship/saves +{ + config, + lib, + pkgs, + ... +}: + +let + steam_2s2h = pkgs.writeScriptBin "steam_2s2h" '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" + exec ${pkgs._2ship2harkinian}/bin/2s2h + ''; +in +{ + imports = [ ]; + + options.me = { + ship2harkinian.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install 2ship2harkinian."; + }; + }; + + config = lib.mkIf config.me.ship2harkinian.enable ( + lib.mkMerge [ + { + allowedUnfree = [ "2ship2harkinian" ]; + } + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + _2ship2harkinian + steam_2s2h + ]; + + home.file.".local/share/2ship/2ship2harkinian.json" = { + source = ./files/2ship2harkinian.json; + }; + + home.persistence."/home/deck/.persist" = { + directories = [ + { + directory = ".local/share/2ship/saves"; + method = "symlink"; + } + ]; + }; + home.persistence."/home/deck/.state" = { + files = [ + ".local/share/2ship/mm.o2r" + ]; + }; + + nixpkgs.overlays = [ + (final: prev: { + _2ship2harkinian = pkgs.buildEnv { + name = prev._2ship2harkinian.name; + paths = [ + (config.lib.nixGL.wrap prev._2ship2harkinian) + ]; + extraOutputsToInstall = [ + "man" + "doc" + "info" + ]; + # We have to use 555 instead of the normal 444 here because the .desktop file ends up inside $HOME on steam deck and desktop files must be either not in $HOME or must be executable, otherwise KDE Plasma refuses to execute them. + postBuild = '' + chmod 0555 $out/share/applications/2s2h.desktop + ''; + }; + }) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/2ship2harkinian/files/2ship2harkinian.json b/nix/steam_deck/configuration/roles/2ship2harkinian/files/2ship2harkinian.json new file mode 100644 index 0000000..87a4f88 --- /dev/null +++ b/nix/steam_deck/configuration/roles/2ship2harkinian/files/2ship2harkinian.json @@ -0,0 +1,15 @@ +{ + "CVars": { + "gInterpolationFPS": 60, + "gSettings": { + "InternalResolution": 2.0, + "MSAAValue": 2, + "OpenMenuBar": 0 + } + }, + "Window": { + "Fullscreen": { + "Enabled": true + } + } +} diff --git a/nix/steam_deck/configuration/roles/blank/default.nix b/nix/steam_deck/configuration/roles/blank/default.nix new file mode 100644 index 0000000..9060e79 --- /dev/null +++ b/nix/steam_deck/configuration/roles/blank/default.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + blank.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install blank."; + }; + }; + + config = lib.mkIf config.me.blank.enable ( + lib.mkMerge [ + { + home.packages = with pkgs; [ + ]; + } + (lib.mkIf config.me.graphical { + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/graphics/default.nix b/nix/steam_deck/configuration/roles/graphics/default.nix new file mode 100644 index 0000000..c6f48d5 --- /dev/null +++ b/nix/steam_deck/configuration/roles/graphics/default.nix @@ -0,0 +1,43 @@ +{ + config, + lib, + pkgs, + nixgl, + ... +}: + +{ + imports = [ ]; + + options.me.graphics_card_type = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "amd" + "intel" + "nvidia" + ] + ); + default = null; + example = "amd"; + description = "What graphics card type is in the computer."; + }; + + options.me.graphical = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install graphical programs."; + }; + + config = ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + nixGL.packages = nixgl.packages; + # home.packages = with pkgs; [ + # mesa-demos # for glxgears + # vulkan-tools # for vkcube + # ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/shipwright/default.nix b/nix/steam_deck/configuration/roles/shipwright/default.nix new file mode 100644 index 0000000..49ad9ee --- /dev/null +++ b/nix/steam_deck/configuration/roles/shipwright/default.nix @@ -0,0 +1,78 @@ +# MANUAL: mkdir -p ~/.persist/.local/share/soh/Save +{ + config, + lib, + pkgs, + ... +}: + +let + steam_shipwright = pkgs.writeScriptBin "steam_soh" '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" + exec ${pkgs.shipwright}/bin/soh + ''; +in +{ + imports = [ ]; + + options.me = { + shipwright.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install shipwright."; + }; + }; + + config = lib.mkIf config.me.shipwright.enable ( + lib.mkMerge [ + { + allowedUnfree = [ "shipwright" ]; + } + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + shipwright + steam_shipwright + ]; + + home.file.".local/share/soh/shipofharkinian.json" = { + source = ./files/shipofharkinian.json; + }; + + home.persistence."/home/deck/.persist" = { + directories = [ + { + directory = ".local/share/soh/Save"; + method = "symlink"; + } + ]; + }; + home.persistence."/home/deck/.state" = { + files = [ + ".local/share/soh/oot.otr" + ]; + }; + + nixpkgs.overlays = [ + (final: prev: { + shipwright = pkgs.buildEnv { + name = prev.shipwright.name; + paths = [ + (config.lib.nixGL.wrap prev.shipwright) + ]; + extraOutputsToInstall = [ + "man" + "doc" + "info" + ]; + # We have to use 555 instead of the normal 444 here because the .desktop file ends up inside $HOME on steam deck and desktop files must be either not in $HOME or must be executable, otherwise KDE Plasma refuses to execute them. + postBuild = '' + chmod 0555 $out/share/applications/soh.desktop + ''; + }; + }) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/shipwright/files/shipofharkinian.json b/nix/steam_deck/configuration/roles/shipwright/files/shipofharkinian.json new file mode 100644 index 0000000..0f440ef --- /dev/null +++ b/nix/steam_deck/configuration/roles/shipwright/files/shipofharkinian.json @@ -0,0 +1,19 @@ +{ + "CVars": { + "gInternalResolution": 2.0, + "gInterpolationFPS": 60, + "gMSAAValue": 2, + "gMatchRefreshRate": 0, + "gOnFileSelectNameEntry": 0, + "gOpenWindows": { + "modalWindowEnabled": 1 + }, + "gZFightingMode": 0 + }, + "ConfigVersion": 2, + "Window": { + "Fullscreen": { + "Enabled": true + } + } +} diff --git a/nix/steam_deck/configuration/roles/sm64ex/default.nix b/nix/steam_deck/configuration/roles/sm64ex/default.nix new file mode 100644 index 0000000..a081885 --- /dev/null +++ b/nix/steam_deck/configuration/roles/sm64ex/default.nix @@ -0,0 +1,91 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + steam_sm64ex = pkgs.writeScriptBin "steam_sm64ex" '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" + exec ${pkgs.sm64ex}/bin/sm64ex + ''; +in +{ + imports = [ ]; + + options.me = { + sm64ex.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install sm64ex."; + }; + }; + + config = lib.mkIf config.me.sm64ex.enable ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + allowedUnfree = [ "sm64ex" ]; + + home.packages = with pkgs; [ + sm64ex + steam_sm64ex + ]; + + # nixpkgs.overlays = [ + # (final: prev: { + # sm4ex = prev.sm64ex.override { + # baseRom.name = "SuperMario64.z64"; + # }; + # }) + # ]; + + home.file.".local/share/sm64ex/sm64config.txt" = { + source = ./files/sm64config.txt; + }; + + home.persistence."/home/deck/.persist" = { + files = [ + ".local/share/sm64ex/sm64_save_file.bin" + ]; + }; + + nixpkgs.overlays = [ + (final: prev: { + sm64ex = + let + desktop_item = pkgs.makeDesktopItem { + name = "sm64ex"; + desktopName = "Super Mario 64"; + comment = "A PC Port of Super Mario 64."; + categories = [ + "Game" + ]; + icon = "sm64ex"; + type = "Application"; + exec = "sm64ex"; + }; + in + pkgs.buildEnv { + name = prev.sm64ex.name; + paths = [ + (config.lib.nixGL.wrap prev.sm64ex) + ]; + extraOutputsToInstall = [ + "man" + "doc" + "info" + ]; + # We have to use 555 instead of the normal 444 here because the .desktop file ends up inside $HOME on steam deck and desktop files must be either not in $HOME or must be executable, otherwise KDE Plasma refuses to execute them. + postBuild = '' + install -m 555 -D "${desktop_item}/share/applications/"* -t $out/share/applications/ + install -m 444 -D "${./files/icon.png}" $out/share/pixmaps/sm64ex.png + ''; + }; + }) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/sm64ex/files/sm64config.txt b/nix/steam_deck/configuration/roles/sm64ex/files/sm64config.txt new file mode 100644 index 0000000..2edf4b9 --- /dev/null +++ b/nix/steam_deck/configuration/roles/sm64ex/files/sm64config.txt @@ -0,0 +1 @@ +fullscreen true diff --git a/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix b/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix new file mode 100644 index 0000000..95b4bb6 --- /dev/null +++ b/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix @@ -0,0 +1,33 @@ +{ + stdenv, + config, + lib, + pkgs, + ... +}: + +let + package = (pkgs.callPackage ./package.nix { }); +in +{ + imports = [ ]; + + options.me = { + steam_rom_manager.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install steam_rom_manager."; + }; + }; + + config = lib.mkIf config.me.steam_rom_manager.enable ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + package + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/steam_rom_manager/package.nix b/nix/steam_deck/configuration/roles/steam_rom_manager/package.nix new file mode 100644 index 0000000..62e4ad9 --- /dev/null +++ b/nix/steam_deck/configuration/roles/steam_rom_manager/package.nix @@ -0,0 +1,49 @@ +{ + stdenv, + lib, + pkgs, + makeDesktopItem, +}: + +let + version = "2.5.29"; + icon = pkgs.fetchurl { + url = "https://github.com/SteamGridDB/steam-rom-manager/blob/master/src/assets/icons/512x512.png?raw=true"; + hash = "sha256-Nx29nJ2+44AYrTLP+CNmDJFAf2sjrH7sfYhg9fJx2qo="; + }; +in +stdenv.mkDerivation { + name = "steam-rom-manager"; + src = pkgs.fetchurl { + url = "https://github.com/SteamGridDB/steam-rom-manager/releases/download/v${version}/Steam-ROM-Manager-${version}.AppImage"; + hash = "sha256-6ZJ+MGIgr2osuQuqD6N9NnPiJFNq/HW6ivG8tyXUhvs="; + }; + phases = [ + "installPhase" + ]; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + install --mode=0755 $src $out/bin/steam-rom-manager + runHook postInstall + ''; + # We have to use 555 instead of the normal 444 here because the .desktop file ends up inside $HOME on steam deck and desktop files must be either not in $HOME or must be executable, otherwise KDE Plasma refuses to execute them. + postInstall = '' + mkdir -p $out/share/{applications,pixmaps} + install -m 555 -D "$desktopItem/share/applications/"* -t $out/share/applications/ + install -m 444 -D "${icon}" $out/share/pixmaps/steamrommanager.png + ''; + + desktopItem = makeDesktopItem { + name = "steam-rom-manager"; + desktopName = "Steam Rom Manager"; + comment = "Manage additional entries in the Steam launcher."; + categories = [ + "Application" + "Utility" + ]; + icon = "steamrommanager"; + type = "Application"; + exec = "steam-rom-manager"; + }; +} diff --git a/nix/steam_deck/configuration/util/unfree_polyfill/default.nix b/nix/steam_deck/configuration/util/unfree_polyfill/default.nix new file mode 100644 index 0000000..d744cf4 --- /dev/null +++ b/nix/steam_deck/configuration/util/unfree_polyfill/default.nix @@ -0,0 +1,15 @@ +{ config, lib, ... }: + +let + inherit (builtins) elem; + inherit (lib) getName mkOption; + inherit (lib.types) listOf str; +in +{ + # Pending https://github.com/NixOS/nixpkgs/issues/55674 + options.allowedUnfree = mkOption { + type = listOf str; + default = [ ]; + }; + config.nixpkgs.config.allowUnfreePredicate = p: elem (getName p) config.allowedUnfree; +}