particle-os-modules/modules/default-flatpaks/v2/post-boot/bluebuild-flatpak-manager
xyny a639f1f64f
refactor(default-flatpaks): version 2 (nushell) (#336)
* feat: initial draft of default-flatpaks v2

this version just sets up the config file but nothing to read it and install the flatpaks after boot

* chore: streamline logging

* chore: replace json with yaml as generated config format

* feat: set up groundwork for post boot scripts

* feat: rename installations -> configurations, initial implementation of post-boot part

* fix: put executable files into /usr/libexec/

* fix: improve fedora remote detection and removal

* feat: implement notifications for system flatpak setup

* chore(default-flatpaks): No need to expose `DISPLAY` for notify-send

* chore(default-flatpaks): Update service & add timers to match v1

* chore(default-flatpaks): Copy & enable timers instead of services

* chore(default-flatpaks): Fix typo for copying `user-flatpak-setup` timer

* chore(default-flatpaks): Copy post-boot files directly instead of placing them in `/usr/share/...`

* chore(default-flatpaks): Forgot to remove copying step of post-boot files to `/usr/share/...`

* chore: update to be in accordance with cli support for nushell

* feat: allow usage of fedora flatpak remote, remove fedora flatpaks and runtimes

* feat: refactor schema to support multiple versions of the module

* docs: separate docs for separate module versions

* fix: copy user-flatpak-setup.timer to correct directory

* chore: correctly document default values in schema

* fix: better flathub package checking
- use API url
- check everything before erroring out

* feat: warn users when giving this module v1 configuration

* fix: prevent addition of http get result into unavailablePackages list

* fix: mkdir before cp

* chore: fix () semantics problems highlighted by debugger

* feat: bluebuild-flatpak-manager CLI

* feat: alert user when trying to use module with old configuration

* docs: write basic documentation page and rewrite example

* fix: attempt to use configFile variable without dollar sign

* fix: no such things as .configurations
(the file is the array)

* fix: ensure no empty list is printed

* docs: add a quick note about learning to use the flatpak manager tool

* fix(schema): distinquish between versions

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>

* fix: add noninteractive flag to flatpak install commands

* fix: ensure repo to be used is enabled

* chore: ignore errors in notify wrapper just in case

* chore: add link to announcement

* docs: run through languagetool

---------

Co-authored-by: fiftydinar <65243233+fiftydinar@users.noreply.github.com>
Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
2025-07-26 14:09:39 +00:00

97 lines
No EOL
4.4 KiB
Text

#!/usr/libexec/bluebuild/nu/nu
def main [] {
print "A CLI tool to manage the installation and setup of Flatpaks by the default-flatpaks BlueBuild module"
print
print $"(ansi default_underline)(ansi default_bold)Usage:(ansi reset) bluebuild-flatpak-manager [command] <args>"
print
print $"(ansi default_underline)(ansi default_bold)Commands:(ansi reset)"
print $" (ansi default_bold)show:(ansi reset) Print out all changes configured to be done by the default-flatpaks module"
print $" (ansi default_bold)apply <all|user|system>:(ansi reset) Manually initiate the setup of Flatpaks"
print $" (ansi default_bold)disable <all|user|system>:(ansi reset) Disable the automatic setup of Flatpaks"
print $" (ansi default_bold)enable <all|user|system>:(ansi reset) Enable the automatic setup of Flatpaks"
}
def "main show" [] {
let configurations = open "/usr/share/bluebuild/default-flatpaks/configuration.yaml"
print $"Found (ansi default_italic)($configurations | length)(ansi reset) configuration\(s)"
for config in $configurations {
print
print $" ($config.install | length) (ansi default_italic)($config.scope)(ansi reset) Flatpak\(s\) from (ansi default_italic)($config.repo.title)(ansi reset) \((ansi default_italic)($config.repo.url)(ansi reset)\)"
if ($config.notify) {
print $" (ansi default_italic)Installer will notify user(ansi reset)"
} else {
print $" (ansi default_italic)Installer will not notify user(ansi reset)"
}
print $" Flatpak\(s) to be installed:"
$config.install | each {|package|
print $" ($package)"
}
}
}
def "main apply" [] {
print $"(ansi default_underline)(ansi default_bold)Usage:(ansi reset)"
print $" (ansi default_italic)bluebuild-flatpak-manager apply all(ansi reset): install and setup both system and user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager apply user(ansi reset): install and setup user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager apply system(ansi reset): install and setup system Flatpaks"
}
def "main apply user" [] {
/usr/libexec/bluebuild/default-flatpaks/user-flatpak-setup
}
def "main apply system" [] {
/usr/libexec/bluebuild/default-flatpaks/system-flatpak-setup
}
def "main apply all" [] {
main apply user
main apply system
}
def "main disable" [] {
print $"(ansi default_underline)(ansi default_bold)Usage:(ansi reset)"
print $" (ansi default_italic)bluebuild-flatpak-manager disable all(ansi reset): disable automatic setup for both system Flatpaks and user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager disable user(ansi reset): disable automatic setup for user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager disable system(ansi reset): disable automatic setup for system Flatpaks"
}
def "main disable user" [] {
print $"Running: (ansi default_italic)run0 systemctl disable --global user-flatpak-setup.timer(ansi reset)"
run0 systemctl disable --global user-flatpak-setup.timer
}
def "main disable system" [] {
print $"Running: (ansi default_italic)systemctl disable --now system-flatpak-setup.timer(ansi reset)"
systemctl disable --now system-flatpak-setup.timer
}
def "main disable all" [] {
main disable system
main disable user
}
def "main enable" [] {
print $"(ansi default_underline)(ansi default_bold)Usage:(ansi reset)"
print $" (ansi default_italic)bluebuild-flatpak-manager enable all(ansi reset): enable automatic setup for both system Flatpaks and user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager enable user(ansi reset): enable automatic setup for user Flatpaks"
print $" (ansi default_italic)bluebuild-flatpak-manager enable system(ansi reset): enable automatic setup for system Flatpaks"
}
def "main enable user" [] {
print $"Running: (ansi default_italic)run0 systemctl enable --global user-flatpak-setup.timer(ansi reset)"
run0 systemctl enable --global user-flatpak-setup.timer
}
def "main enable system" [] {
print $"Running: (ansi default_italic)systemctl enable --now system-flatpak-setup.timer(ansi reset)"
systemctl enable --now system-flatpak-setup.timer
}
def "main enable all" [] {
main enable system
main enable user
}