mirror of
https://github.com/zephrynis/nix-flake.git
synced 2026-02-18 20:21:53 +00:00
Move Flatpak management to system configuration
Flatpak management has been refactored from Home Manager and nix-flatpak to a new system/flatpak.nix module, now imported in system/common.nix. This centralizes Flatpak enablement and declarative app management at the system level, simplifying configuration and maintenance.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./flatpak.nix
|
||||
];
|
||||
|
||||
# Common system configuration shared across all machines
|
||||
|
||||
# Bootloader
|
||||
@@ -10,9 +14,6 @@
|
||||
# Networking
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
# Enable Flatpak
|
||||
services.flatpak.enable = true;
|
||||
|
||||
# Timezone and locale
|
||||
time.timeZone = "Europe/London";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
47
system/flatpak.nix
Normal file
47
system/flatpak.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
grep = pkgs.gnugrep;
|
||||
|
||||
# Declare the Flatpaks you want on your system
|
||||
desiredFlatpaks = [
|
||||
"io.github.zen_browser.zen"
|
||||
# Add more Flatpak apps here
|
||||
# "com.spotify.Client"
|
||||
# "com.discordapp.Discord"
|
||||
];
|
||||
in {
|
||||
# Enable Flatpak
|
||||
services.flatpak.enable = true;
|
||||
|
||||
system.userActivationScripts.flatpakManagement = {
|
||||
text = ''
|
||||
# Ensure the Flathub repo is added
|
||||
${pkgs.flatpak}/bin/flatpak remote-add --if-not-exists flathub \
|
||||
https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
# Get currently installed Flatpaks
|
||||
installedFlatpaks=$(${pkgs.flatpak}/bin/flatpak list --app --columns=application)
|
||||
|
||||
# Remove any Flatpaks that are NOT in the desired list
|
||||
for installed in $installedFlatpaks; do
|
||||
if ! echo ${toString desiredFlatpaks} | ${grep}/bin/grep -q $installed; then
|
||||
echo "Removing $installed because it's not in the desiredFlatpaks list."
|
||||
${pkgs.flatpak}/bin/flatpak uninstall -y --noninteractive $installed
|
||||
fi
|
||||
done
|
||||
|
||||
# Install or re-install the Flatpaks you DO want
|
||||
for app in ${toString desiredFlatpaks}; do
|
||||
echo "Ensuring $app is installed."
|
||||
${pkgs.flatpak}/bin/flatpak install -y flathub $app
|
||||
done
|
||||
|
||||
# Remove unused Flatpaks
|
||||
${pkgs.flatpak}/bin/flatpak uninstall --unused -y
|
||||
|
||||
# Update all installed Flatpaks
|
||||
${pkgs.flatpak}/bin/flatpak update -y
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user