From ab0ccf25192b59ade80916f4d5aa3134d33c5425 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 23 Dec 2024 01:18:36 -0800 Subject: [PATCH] refactor: modularize flatpak and make roblox an option --- modules/linux/flatpak/default.nix | 67 +++++++++++++++----------- modules/linux/flatpak/sober.flatpakref | 10 ++++ modules/linux/gaming/default.nix | 26 ++++++++-- 3 files changed, 71 insertions(+), 32 deletions(-) create mode 100644 modules/linux/flatpak/sober.flatpakref diff --git a/modules/linux/flatpak/default.nix b/modules/linux/flatpak/default.nix index d5d4a34..29d5851 100644 --- a/modules/linux/flatpak/default.nix +++ b/modules/linux/flatpak/default.nix @@ -2,44 +2,53 @@ # versioned. Therefore, they are not included in generational rollbacks and # persist between generations. This is not ideal, but at least it is a better # situation than imperative installation -{ inputs, ... }: +{ + inputs, + config, + lib, + ... +}: +let + cfg = config.liminalOS.programs.flatpaks; +in { imports = [ - inputs.nix-flatpak.nixosModules.nix-flatpak + inputs.${cfg.moduleName}.nixosModules.nix-flatpak ]; - services.flatpak = { - enable = true; + options.liminalOS.programs.flatpaks = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to enable Nix flatpak support with some fixes as well as declarative flatpak management. + ''; + }; + }; - overrides = { - global = { - Context.sockets = [ - "wayland" - "!x11" - "!fallback-x11" - ]; + config = lib.mkIf cfg.enable { + services.flatpak = { + enable = true; - Environment = { - # Fix un-themed cursor in some Wayland apps - XCURSOR_PATH = "/run/host/user-share/icons:/run/host/share/icons"; + overrides = { + global = { + Context.sockets = [ + "wayland" + "!x11" + "!fallback-x11" + ]; + + Environment = { + # Fix un-themed cursor in some Wayland apps + XCURSOR_PATH = "/run/host/user-share/icons:/run/host/share/icons"; + }; }; }; - }; - update.auto = { - enable = true; - onCalendar = "weekly"; + update.auto = { + enable = true; + onCalendar = "weekly"; + }; }; - - packages = [ - { - flatpakref = "https://sober.vinegarhq.org/sober.flatpakref"; - sha256 = "sha256:1pj8y1xhiwgbnhrr3yr3ybpfis9slrl73i0b1lc9q89vhip6ym2l"; - } - { - appId = "org.vinegarhq.Sober"; - origin = "sober"; - } - ]; }; } diff --git a/modules/linux/flatpak/sober.flatpakref b/modules/linux/flatpak/sober.flatpakref new file mode 100644 index 0000000..215f5c3 --- /dev/null +++ b/modules/linux/flatpak/sober.flatpakref @@ -0,0 +1,10 @@ +[Flatpak Ref] +Title=Sober +Name=org.vinegarhq.Sober +Url=https://sober.vinegarhq.org/repo/ +SuggestRemoteName=sober +Homepage=https://sober.vinegarhq.org +Icon=https://sober.vinegarhq.org/sober.svg +RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo +IsRuntime=false +GPGKey=LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUdOQkdhc3U4QUJEQURUQzExYjFmUG9LZU9Ea1hTT3lrYzllajRZeFZMSlZQN2NFZmRnV05aWllsYnFsZ0xECms2MTNxK1dnOE0xb0Zrem00MjMvSUhyT050TEZpVG9sN0paTE1DS0w0d05Id1dnOWpmcmwzak5EUUtKb2lUQVEKZllsWFJiZ09IeVNLYmxFRDVaRm9hQ3BRM0pMQkdaalRUZ1VJck9mK3lSU3lZU09pUHFucEJuM1NHZEh3L0pXegpkY3hRUUd4OVdNL2ZlNGFSVVJMS0k1VG9Ya244cGNZWE4wdE50T2tlOUUzeDI5b3pOcVg0b3BicDJkWXJnejlqCklVM1Zka2VUdTRlSmhJQ2tWMzFVbGpQcVg5VVc1azViTjM4VDRMaEJqQ0kzS1Q2TkJhaXVab1FselFsbXNkYVIKMEdWK3kvSUFhdXNOUzdjMHhCUithUnNnOExpa3h1cXBqWGl6RS9HRTYydCtZeVZBVEs1S0J6aThRZWdVSVMwZgpHRUxkV0RydzBmMUkzc1RuUTBqL2xpZWNneUppMmtmUnlqMThFSmx6WDlYWTdqcHArL2pPUGlqaXYrbXlvaEJXCm1hY3N5UUZCQkg0dEpZUUt4TW1Mc0Y2eUsyWVNTV0IvcS9CZEZ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lhc1N1cTZ5MlIKQ2hIR2lzOUtWcnhGWmZxMW1oU2xheVFZcWlkRGV3cm9Qa2pUZ2dvSjhPL1NxeEwyejdkK01vQ1pDZEpubnVadwpVRHpxN0RUSHhPYmlmdlUrclkybGNveE8vTzkvZ21mZ28vTTFma0xTTmdxN1ZYd0hMV2lSNmFVSjFyOFY5WnRZCmIxbXI4aVIxbGNlR2lRRVFxSTJPMm1KeHptWWlTaHEzZ1dMZjdzaXpnZjk0NFlBVy9rTGUxdVdsSlFpQUcyb0IKa1MzT0RTRUxkdVhFR3NxRGJ2QlQvSVpveGgyMjQ2QzR5MlhiOTZFYUlpYlFxRzJDVTZ3T2xTQktmb09IRTAzegpoQmJSc3dBZlFBPT0KPVp4Q1YKLS0tLS1FTkQgUEdQIFBVQkxJQyBLRVkgQkxPQ0stLS0tLQo= diff --git a/modules/linux/gaming/default.nix b/modules/linux/gaming/default.nix index 2e4493c..133b2b8 100755 --- a/modules/linux/gaming/default.nix +++ b/modules/linux/gaming/default.nix @@ -10,7 +10,14 @@ in { options.liminalOS.extras.gaming = { enable = lib.mkEnableOption "gaming"; - withHamachi = lib.mkEnableOption "hamachi"; + utilities.hamachi.enable = lib.mkEnableOption "hamachi"; + roblox.enable = lib.mkOption { + type = lib.types.bool; + default = config.liminalOS.extras.gaming && cfg.enable; + description = '' + Whether to install the Roblox Sober flatpak automatically. Note that this will enable the nix-flatpak service and automatic flatpak updates.` + ''; + }; }; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ @@ -21,6 +28,19 @@ in mangojuice ]; + liminalOS.programs.flatpaks.enable = true; + + services.flatpak.packages = lib.mkIf cfg.roblox.enable [ + { + flatpakref = "https://sober.vinegarhq.org/sober.flatpakref"; + sha256 = "sha256:1pj8y1xhiwgbnhrr3yr3ybpfis9slrl73i0b1lc9q89vhip6ym2l"; + } + { + appId = "org.vinegarhq.Sober"; + origin = "sober"; + } + ]; + programs.steam = { enable = true; remotePlay.openFirewall = true; @@ -47,8 +67,8 @@ in users.users.${config.liminalOS.username}.extraGroups = [ "gamemode" ]; - services.logmein-hamachi.enable = cfg.withHamachi; - programs.haguichi.enable = cfg.withHamachi; + services.logmein-hamachi.enable = cfg.utilities.hamachi.enable; + programs.haguichi.enable = cfg.utilities.hamachi.enable; nixpkgs.config.packageOverrides = pkgs: { steam = pkgs.steam.override {