From 2948dc4dbfa8b1f12b22e50cc626370a663650e5 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Fri, 22 May 2026 18:33:51 +0100 Subject: [PATCH] feat(gaming): register Flathub remote via one-shot systemd unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit services.flatpak.enable = true (set inside core/system/gaming.nix's mkIf cfg.enable block) ships flatpak but doesn't add any remotes, so `flatpak install` and the Discover GUI returned empty results until the user ran the manual `flatpak remote-add` one-liner. nixpkgs has no declarative remote-add API yet. Added systemd.services.nomarchy-flathub-init: a Type=oneshot, RemainAfterExit=true unit that runs `flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo` after network-online.target. The --if-not-exists flag keeps it idempotent across reboots and re-runs. Lives under the gaming preset (where flatpak is wired today); lift to a dedicated module when another preset needs flatpak. Closes the "Gaming — declarative flathub remote" Next-column item. `nix flake check --no-build` clean. --- core/system/gaming.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/core/system/gaming.nix b/core/system/gaming.nix index 32ae4dc..4290d00 100644 --- a/core/system/gaming.nix +++ b/core/system/gaming.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let cfg = config.nomarchy.system.gaming; @@ -16,5 +16,29 @@ in programs.gamemode.enable = true; services.flatpak.enable = true; + + # `services.flatpak.enable = true` ships flatpak but does NOT add any + # remotes — without a remote, `flatpak install` and the Discover GUI + # can't find anything. nixpkgs has no declarative remote-add API yet, + # so we run a one-shot system unit after flatpak.service is ready that + # adds the flathub remote idempotently (`--if-not-exists`). Lives under + # the gaming preset because Pillar 5 ships flatpak as part of the + # gaming wiring; if another preset later needs flatpak, lift this to a + # dedicated module. + systemd.services.nomarchy-flathub-init = { + description = "Register the Flathub remote on first start"; + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + path = [ pkgs.flatpak ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + flatpak remote-add --if-not-exists flathub \ + https://dl.flathub.org/repo/flathub.flatpakrepo + ''; + }; }; }