Regenerated
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
|
||||
let
|
||||
# Module name
|
||||
moduleName = "flatpaks";
|
||||
|
||||
# Top-level toggle for this module
|
||||
enableProgram = config.enableFlatpaks or false;
|
||||
|
||||
# Path to your Flatpak list
|
||||
assetPath = ../../../assets/system/apps/flatpaks.conf;
|
||||
|
||||
# Resolve user safely
|
||||
username = config.defaultUser or "henrov";
|
||||
in
|
||||
{
|
||||
# --- Top-level toggle option ---
|
||||
options.enableFlatpaks = lib.mkEnableOption "Enable automatic Flatpak installation";
|
||||
|
||||
# --- Config only applied if enabled ---
|
||||
config = lib.mkIf enableProgram {
|
||||
|
||||
# Deploy the Flatpak conf file
|
||||
environment.etc."flatpak/flatpaks.conf".source = assetPath;
|
||||
|
||||
# Enable system Flatpak service
|
||||
services.flatpak.enable = true;
|
||||
xdg.portal.enable = true;
|
||||
|
||||
# Systemd service to install Flatpaks from the list
|
||||
systemd.services."${moduleName}-sync" = {
|
||||
description = "Install Flatpak apps listed in flatpaks.conf";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = ''
|
||||
set -euo pipefail
|
||||
CONF="${assetPath}"
|
||||
|
||||
# Add Flathub if not present
|
||||
if ! flatpak remotes --system --columns=name | grep -qx flathub; then
|
||||
flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
fi
|
||||
|
||||
# Install every Flatpak listed in the conf file
|
||||
while IFS= read -r app || [ -n "$app" ]; do
|
||||
app=$(echo "$app" | sed 's/#.*//;s/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
if [ -n "$app" ]; then
|
||||
if ! flatpak info --system "$app" >/dev/null 2>&1; then
|
||||
flatpak install --system -y --noninteractive flathub "$app"
|
||||
fi
|
||||
fi
|
||||
done < "$CONF"
|
||||
'';
|
||||
};
|
||||
|
||||
restartTriggers = [ assetPath ];
|
||||
|
||||
# Include only the packages needed for this service
|
||||
path = [ pkgs.flatpak pkgs.coreutils pkgs.gnugrep pkgs.gnused ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user