diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index f621663..a18d814 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -32,6 +32,7 @@ ./roles/graphics ./roles/hydra ./roles/iso + ./roles/iso_mount ./roles/kanshi ./roles/kodi ./roles/kubernetes @@ -49,6 +50,7 @@ ./roles/python ./roles/qemu ./roles/reset + ./roles/rpcs3 ./roles/rust ./roles/shikane ./roles/shipwright diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index d5042f7..11be98b 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -75,6 +75,7 @@ me.gpg.enable = true; me.graphical = true; me.graphics_card_type = "amd"; + me.iso_mount.enable = true; me.kanshi.enable = false; me.kubernetes.enable = true; me.latex.enable = true; @@ -85,6 +86,7 @@ me.pcsx2.enable = true; me.python.enable = true; me.qemu.enable = true; + me.rpcs3.enable = true; me.rust.enable = true; me.shikane.enable = true; me.sops.enable = true; diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix index 317912d..672428a 100644 --- a/nix/configuration/hosts/quark/default.nix +++ b/nix/configuration/hosts/quark/default.nix @@ -13,94 +13,101 @@ ./wifi.nix ]; - # Generate with `head -c4 /dev/urandom | od -A none -t x4` - networking.hostId = "47ee7d7c"; + config = { + # Generate with `head -c4 /dev/urandom | od -A none -t x4` + networking.hostId = "47ee7d7c"; - networking.hostName = "quark"; # Define your hostname. + networking.hostName = "quark"; # Define your hostname. - time.timeZone = "America/New_York"; - i18n.defaultLocale = "en_US.UTF-8"; + time.timeZone = "America/New_York"; + i18n.defaultLocale = "en_US.UTF-8"; - me.secureBoot.enable = true; + me.secureBoot.enable = true; - me.optimizations = { - enable = true; - arch = "znver5"; - system_features = [ - "gccarch-znver4" - "gccarch-znver5" - "gccarch-skylake" - # "gccarch-alderlake" missing WAITPKG - "gccarch-x86-64-v3" - "gccarch-x86-64-v4" - "benchmark" - "big-parallel" - "kvm" - "nixos-test" + me.optimizations = { + enable = true; + arch = "znver5"; + system_features = [ + "gccarch-znver4" + "gccarch-znver5" + "gccarch-skylake" + # "gccarch-alderlake" missing WAITPKG + "gccarch-x86-64-v3" + "gccarch-x86-64-v4" + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + }; + + # Early KMS + boot.initrd.kernelModules = [ "amdgpu" ]; + + # Mount tmpfs at /tmp + boot.tmp.useTmpfs = true; + + # Enable TRIM + # services.fstrim.enable = lib.mkDefault true; + + # RPCS3 has difficulty with znver5 + me.rpcs3.config.Core."Use LLVM CPU" = "znver4"; + + me.alacritty.enable = true; + me.ansible.enable = true; + me.ares.enable = true; + me.bluetooth.enable = true; + me.chromecast.enable = true; + me.chromium.enable = true; + me.docker.enable = true; + me.ecc.enable = true; + me.emacs_flavor = "full"; + me.firefox.enable = true; + me.flux.enable = true; + me.gcloud.enable = true; + me.git.config = ../../roles/git/files/gitconfig_home; + me.gnuplot.enable = true; + me.gpg.enable = true; + me.graphical = true; + me.graphics_card_type = "amd"; + me.iso_mount.enable = true; + me.kanshi.enable = false; + me.kubernetes.enable = true; + me.latex.enable = true; + me.launch_keyboard.enable = true; + me.lvfs.enable = true; + me.media.enable = true; + me.nix_index.enable = true; + me.nix_worker.enable = true; + me.pcsx2.enable = true; + me.python.enable = true; + me.qemu.enable = true; + me.rpcs3.enable = true; + me.rust.enable = true; + me.shikane.enable = true; + me.sops.enable = true; + me.sound.enable = true; + me.steam.enable = true; + me.steam_run_free.enable = true; + me.sway.enable = true; + me.tekton.enable = true; + me.terraform.enable = true; + me.thunderbolt.enable = true; + me.vnc_client.enable = true; + me.vscode.enable = true; + me.wasm.enable = true; + me.waybar.enable = true; + me.wireguard.activated = [ + "drmario" + "wgh" + "colo" ]; + me.wireguard.deactivated = [ "wgf" ]; + me.zrepl.enable = true; + me.zsh.enable = true; + + me.sm64ex.enable = true; + me.shipwright.enable = true; + me.ship2harkinian.enable = true; }; - - # Early KMS - boot.initrd.kernelModules = [ "amdgpu" ]; - - # Mount tmpfs at /tmp - boot.tmp.useTmpfs = true; - - # Enable TRIM - # services.fstrim.enable = lib.mkDefault true; - - me.alacritty.enable = true; - me.ansible.enable = true; - me.ares.enable = true; - me.bluetooth.enable = true; - me.chromecast.enable = true; - me.chromium.enable = true; - me.docker.enable = true; - me.ecc.enable = true; - me.emacs_flavor = "full"; - me.firefox.enable = true; - me.flux.enable = true; - me.gcloud.enable = true; - me.git.config = ../../roles/git/files/gitconfig_home; - me.gnuplot.enable = true; - me.gpg.enable = true; - me.graphical = true; - me.graphics_card_type = "amd"; - me.kanshi.enable = false; - me.kubernetes.enable = true; - me.latex.enable = true; - me.launch_keyboard.enable = true; - me.lvfs.enable = true; - me.media.enable = true; - me.nix_index.enable = true; - me.nix_worker.enable = true; - me.pcsx2.enable = true; - me.python.enable = true; - me.qemu.enable = true; - me.rust.enable = true; - me.shikane.enable = true; - me.sops.enable = true; - me.sound.enable = true; - me.steam.enable = true; - me.steam_run_free.enable = true; - me.sway.enable = true; - me.tekton.enable = true; - me.terraform.enable = true; - me.thunderbolt.enable = true; - me.vnc_client.enable = true; - me.vscode.enable = true; - me.wasm.enable = true; - me.waybar.enable = true; - me.wireguard.activated = [ - "drmario" - "wgh" - "colo" - ]; - me.wireguard.deactivated = [ "wgf" ]; - me.zrepl.enable = true; - me.zsh.enable = true; - - me.sm64ex.enable = true; - me.shipwright.enable = true; - me.ship2harkinian.enable = true; } diff --git a/nix/configuration/roles/iso_mount/default.nix b/nix/configuration/roles/iso_mount/default.nix new file mode 100644 index 0000000..32c0af6 --- /dev/null +++ b/nix/configuration/roles/iso_mount/default.nix @@ -0,0 +1,45 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + iso_mount = + (pkgs.writeScriptBin "iso_mount" (builtins.readFile ./files/iso_mount.bash)).overrideAttrs + (old: { + buildCommand = "${old.buildCommand}\n patchShebangs $out"; + + }); + iso_unmount = + (pkgs.writeScriptBin "iso_unmount" (builtins.readFile ./files/iso_unmount.bash)).overrideAttrs + (old: { + buildCommand = "${old.buildCommand}\n patchShebangs $out"; + + }); + +in +{ + imports = [ ]; + + options.me = { + iso_mount.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install iso_mount."; + }; + }; + + config = lib.mkIf config.me.iso_mount.enable ( + lib.mkMerge [ + { + environment.systemPackages = [ + iso_mount + iso_unmount + ]; + } + ] + ); +} diff --git a/nix/configuration/roles/iso_mount/files/iso_mount.bash b/nix/configuration/roles/iso_mount/files/iso_mount.bash new file mode 100644 index 0000000..143e14d --- /dev/null +++ b/nix/configuration/roles/iso_mount/files/iso_mount.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Mount a full-disk image as a loopback device so you can mount individual partitions from inside of it. +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +exec udisksctl loop-setup -r -f "${@}" diff --git a/nix/configuration/roles/iso_mount/files/iso_unmount.bash b/nix/configuration/roles/iso_mount/files/iso_unmount.bash new file mode 100644 index 0000000..1771e21 --- /dev/null +++ b/nix/configuration/roles/iso_mount/files/iso_unmount.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Mount a full-disk image as a loopback device so you can mount individual partitions from inside of it. +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +exec udisksctl loop-delete "${@}" diff --git a/nix/configuration/roles/rpcs3/default.nix b/nix/configuration/roles/rpcs3/default.nix new file mode 100644 index 0000000..f034f6d --- /dev/null +++ b/nix/configuration/roles/rpcs3/default.nix @@ -0,0 +1,170 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + rpcs3_config_yaml = settingsFormat.generate "config.yml" config.me.rpcs3.config; + settingsFormat = pkgs.formats.yaml { }; +in +{ + imports = [ ]; + + options.me = { + rpcs3.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install rpcs3."; + }; + + rpcs3.config = lib.mkOption rec { + apply = lib.recursiveUpdate default; + inherit (settingsFormat) type; + default = { + Core = { + "Use LLVM CPU" = lib.mkIf (config.me.optimizations.enable) config.me.optimizations.arch; + }; + VFS = { + "Enable /host_root/" = false; + }; + Video = { + "Write Color Buffers" = true; + VSync = true; + "Performance Overlay" = { + Enabled = false; + }; + }; + Miscellaneous = { + "Pause emulation on RPCS3 focus loss" = true; + "Start games in fullscreen mode" = true; + "Pause Emulation During Home Menu" = false; # true makes the home menu slow + }; + }; + example = null; + description = "RPCS3's config.yml in nix form."; + }; + }; + + config = lib.mkIf config.me.rpcs3.enable ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + environment.systemPackages = with pkgs; [ + rpcs3 + ]; + + security.pam.loginLimits = [ + { + domain = "@wheel"; + item = "memlock"; + type = "hard"; + value = "unlimited"; + } + { + domain = "@wheel"; + item = "memlock"; + type = "soft"; + value = "unlimited"; + } + ]; + + home-manager.users.talexander = + { pkgs, ... }: + { + home.file.".config/rpcs3/config.yml" = lib.mkIf (config.me.rpcs3.config != null) { + source = rpcs3_config_yaml; + }; + home.file.".config/rpcs3/GuiConfigs/CurrentSettings.ini" = { + source = ./files/CurrentSettings.ini; + }; + }; + + environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) { + hideMounts = true; + users.talexander = { + directories = [ + { + # Location of ROMs. + directory = ".config/rpcs3/games"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + directory = ".config/rpcs3/dev_hdd0"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + directory = ".config/rpcs3/dev_hdd1"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + directory = ".config/rpcs3/savestates"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + directory = ".config/rpcs3/dev_usb000"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + # Seems to be where the firmware is installed. + directory = ".config/rpcs3/dev_flash"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + # Controller config. + directory = ".config/rpcs3/input_configs"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + { + # Game icons. + directory = ".config/rpcs3/Icons"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + ]; + files = [ + { + # play times and recently played + file = ".config/rpcs3/GuiConfigs/persistent_settings.dat"; + parentDirectory = { + mode = "0755"; + }; + } + ]; + }; + }; + + environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) { + hideMounts = true; + users.talexander = { + directories = [ + { + # Game saves + directory = ".cache/rpcs3"; + user = "talexander"; + group = "talexander"; + mode = "0755"; + } + ]; + }; + }; + }) + ] + ); +} diff --git a/nix/configuration/roles/rpcs3/files/CurrentSettings.ini b/nix/configuration/roles/rpcs3/files/CurrentSettings.ini new file mode 100644 index 0000000..b6354c4 --- /dev/null +++ b/nix/configuration/roles/rpcs3/files/CurrentSettings.ini @@ -0,0 +1,5 @@ +[Meta] +currentStylesheet=Darker Style by TheMitoSan + +[main_window] +infoBoxEnabledWelcome=false diff --git a/nix/steam_deck/configuration/roles/rpcs3/default.nix b/nix/steam_deck/configuration/roles/rpcs3/default.nix index dc944ab..8ca37dc 100644 --- a/nix/steam_deck/configuration/roles/rpcs3/default.nix +++ b/nix/steam_deck/configuration/roles/rpcs3/default.nix @@ -10,6 +10,9 @@ let export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" exec ${pkgs.rpcs3}/bin/rpcs3 "''${@}" ''; + rpcs3_config_yaml = settingsFormat.generate "config.yml" config.me.rpcs3.config; + settingsFormat = pkgs.formats.yaml { }; + in { imports = [ ]; @@ -21,6 +24,33 @@ in example = true; description = "Whether we want to install rpcs3."; }; + + rpcs3.config = lib.mkOption rec { + apply = lib.recursiveUpdate default; + inherit (settingsFormat) type; + default = { + Core = { + "Use LLVM CPU" = "znver2"; + }; + VFS = { + "Enable /host_root/" = false; + }; + Video = { + "Write Color Buffers" = true; + VSync = true; + "Performance Overlay" = { + Enabled = false; + }; + }; + Miscellaneous = { + "Pause emulation on RPCS3 focus loss" = true; + "Start games in fullscreen mode" = true; + "Pause Emulation During Home Menu" = false; # true makes the home menu slow + }; + }; + example = null; + description = "RPCS3's config.yml in nix form."; + }; }; config = lib.mkIf config.me.rpcs3.enable ( @@ -31,15 +61,25 @@ in steam_rpcs3 ]; - # .config/rpcs3/config.yml - # .config/rpcs3/GuiConfigs/CurrentSettings.ini + home.file.".config/rpcs3/config.yml" = lib.mkIf (config.me.rpcs3.config != null) { + source = rpcs3_config_yaml; + }; + home.file.".config/rpcs3/GuiConfigs/CurrentSettings.ini" = { + source = ./files/CurrentSettings.ini; + }; me.persist.directories = [ + ".config/rpcs3/games" # Location of ROMs. ".config/rpcs3/dev_hdd0" ".config/rpcs3/dev_hdd1" ".config/rpcs3/savestates" ".config/rpcs3/dev_usb000" ".config/rpcs3/dev_flash" # Seems to be where the firmware is installed. + ".config/rpcs3/input_configs" # Controller config. + ".config/rpcs3/Icons" # Game icons. + ]; + me.persist.files = [ + ".config/rpcs3/GuiConfigs/persistent_settings.dat" # play times and recently played ]; me.state.directories = [ ".cache/rpcs3" ]; diff --git a/nix/steam_deck/configuration/roles/rpcs3/files/CurrentSettings.ini b/nix/steam_deck/configuration/roles/rpcs3/files/CurrentSettings.ini new file mode 100644 index 0000000..b6354c4 --- /dev/null +++ b/nix/steam_deck/configuration/roles/rpcs3/files/CurrentSettings.ini @@ -0,0 +1,5 @@ +[Meta] +currentStylesheet=Darker Style by TheMitoSan + +[main_window] +infoBoxEnabledWelcome=false diff --git a/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix b/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix index 082781f..864ffdd 100644 --- a/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix +++ b/nix/steam_deck/configuration/roles/steam_rom_manager/default.nix @@ -24,21 +24,12 @@ in config = lib.mkIf config.me.steam_rom_manager.enable ( lib.mkMerge [ (lib.mkIf config.me.graphical { - home.packages = with pkgs; [ + home.packages = [ package ]; me.persist.directories = [ ".config/steam-rom-manager/userData" ]; - home.persistence."/home/deck/.persist" = { - directories = [ - { - directory = ".config/steam-rom-manager/userData"; - method = "symlink"; - } - ]; - }; - # TODO: Install a fully configured /home/deck/.persist/.config/steam-rom-manager/userData/userConfigurations.json (which contains the parser definitions) and /home/deck/.persist/.config/steam-rom-manager/userData/userSettings.json (which contains the applications settings like steam directory). # TODO: Maybe only persist /home/deck/.persist/.config/steam-rom-manager/userData/artworkBackups and /home/deck/.persist/.config/steam-rom-manager/userData/artworkCache.json after the parser config is being installed. diff --git a/nix/steam_deck/configuration/util/persist_symlink/default.nix b/nix/steam_deck/configuration/util/persist_symlink/default.nix index 0860d66..6339bab 100644 --- a/nix/steam_deck/configuration/util/persist_symlink/default.nix +++ b/nix/steam_deck/configuration/util/persist_symlink/default.nix @@ -16,6 +16,12 @@ example = [ ".local/share/dolphin-emu/Wii" ]; description = "List of folders relative to the home directory to persist."; }; + persist.files = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + example = [ ".local/share/foo.sqlite3" ]; + description = "List of files relative to the home directory to persist."; + }; state.directories = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; @@ -50,6 +56,11 @@ ); }; }) + (lib.mkIf (config.me.persist.files != [ ]) { + home.persistence."/home/deck/.persist" = { + files = config.me.persist.files; + }; + }) (lib.mkIf (config.me.state.directories != [ ]) { home.persistence."/home/deck/.state" = { directories = (