Skip to content

Commit

Permalink
nixos/services/flatpak: add support for adding flatpakrepos
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Dec 22, 2024
1 parent a0e28f8 commit 8bd3f2b
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion modules/nixos/services/flatpak/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config,
lib,
namespace,
pkgs,
...
}:
let
Expand All @@ -13,7 +14,31 @@ in
{
options.${namespace}.services.flatpak = {
enable = mkBoolOpt false "Whether or not to enable flatpak support.";
extraRepos = lib.mkOption {
default = {
flathub = "https://flathub.org/repo/flathub.flatpakrepo";
};
type = lib.types.attrsOf lib.types.str;
description = "Extra flatpak repositories to add.";
};
};

config = mkIf cfg.enable { services.flatpak.enable = true; };
config = mkIf cfg.enable {
services.flatpak.enable = true;
systemd.services.flatpak-repos = {
wantedBy = [ "multi-user.target" ];
path = [ pkgs.flatpak ];
script =
let
generateRepoScript =
repos:
lib.concatStringsSep "\n" (
lib.mapAttrsToList (name: url: ''
flatpak remote-add --if-not-exists ${name} ${url}
'') repos
);
in
generateRepoScript cfg.extraRepos;
};
};
}

0 comments on commit 8bd3f2b

Please sign in to comment.