/ applications / flatpak.nix
flatpak.nix
1 { config, lib, pkgs, ... }: 2 let 3 # We point directly to 'gnugrep' instead of 'grep' 4 grep = pkgs.gnugrep; 5 # 1. Declare the Flatpaks you *want* on your system 6 desiredFlatpaks = [ 7 "com.github.tchx84.Flatseal" 8 "dev.vencord.Vesktop" 9 "org.telegram.desktop" 10 "io.beekeeperstudio.Studio" 11 "com.parsecgaming.parsec" 12 "md.obsidian.Obsidian" 13 "com.spotify.Client" 14 "com.ktechpit.whatsie" 15 # "com.visualstudio.code" 16 # "com.jetbrains.IntelliJ-IDEA-Ultimate" 17 ]; 18 in 19 { 20 home.packages = [ pkgs.flatpak ]; 21 home.activation.flatpakManagement = 22 lib.hm.dag.entryAfter [ "writeBoundary" ] '' 23 # 2. Ensure the Flathub repo is added 24 ${pkgs.flatpak}/bin/flatpak remote-add --if-not-exists flathub \ 25 https://flathub.org/repo/flathub.flatpakrepo 26 27 # 3. Get currently installed Flatpaks 28 installedFlatpaks=$(${pkgs.flatpak}/bin/flatpak list --app --columns=application) 29 30 # 4. Remove any Flatpaks that are NOT in the desired list 31 for installed in $installedFlatpaks; do 32 if ! echo ${ 33 toString desiredFlatpaks 34 } | ${grep}/bin/grep -q $installed; then 35 echo "Removing $installed because it's not in the desiredFlatpaks list." 36 ${pkgs.flatpak}/bin/flatpak uninstall -y --noninteractive $installed 37 fi 38 done 39 40 # 5. Install or re-install the Flatpaks you DO want 41 for app in ${toString desiredFlatpaks}; do 42 echo "Ensuring $app is installed." 43 ${pkgs.flatpak}/bin/flatpak install -y flathub $app 44 done 45 46 # 6. Remove unused Flatpaks 47 ${pkgs.flatpak}/bin/flatpak uninstall --unused -y 48 49 # 7. Update all installed Flatpaks 50 ${pkgs.flatpak}/bin/flatpak update -y 51 ''; 52 53 # Setting your exec for application running X11 54 # Make sure to try enabling Wayland support in flatseal first 55 # home.file.".local/share/applications/com.parsecgaming.parsec.desktop" = { 56 # text = '' 57 # [Desktop Entry] 58 # Type=Application 59 # Name=Parsec 60 # Comment=Remote Desktop Application 61 # Exec=cage -- flatpak run com.parsecgaming.parsec 62 # Icon=parsec 63 # Terminal=false 64 # ''; 65 # }; 66 # home.file.".local/share/applications/com.visualstudio.code.desktop" = { 67 # text = '' 68 # [Desktop Entry] 69 # Type=Application 70 # Name=VS Code 71 # Comment=Code Editor 72 # Exec=cage -- flatpak run com.visualstudio.code 73 # Icon=visualstudio 74 # Terminal=false 75 # ''; 76 # }; 77 # home.file.".local/share/applications/com.jetbrains.IntelliJ-IDEA-Ultimate.desktop" = { 78 # text = '' 79 # [Desktop Entry] 80 # Type=Application 81 # Name=IntelliJ 82 # Comment=Java IDE 83 # Exec=cage -- flatpak run com.jetbrains.IntelliJ-IDEA-Ultimate 84 # Icon=IntelliJ-IDEA-Ultimate 85 # Terminal=false 86 # ''; 87 # }; 88 }