Skip to content

Commit

Permalink
feat: rename installations -> configurations, initial implementation …
Browse files Browse the repository at this point in the history
…of post-boot part
  • Loading branch information
xynydev committed Oct 11, 2024
1 parent a45fc97 commit 1415893
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/default-flatpaks/v2/default-flatpaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const flathubURL = "https://dl.flathub.org/repo/flathub.flatpakrepo"

const defaultInstallation = {
const defaultConfiguration = {
notify: true
scope: user
repo: {
Expand All @@ -19,11 +19,11 @@ const configPath = $"($usrSharePath)/configuration.yaml"
def main [configStr: string] {
let config = $configStr | from yaml

let installations = $config.installations | each {|installation|
mut merged = $defaultInstallation | merge $installation
$merged.repo = $defaultInstallation.repo | merge $merged.repo # make sure all repo properties exist
let configurations = $config.configurations | each {|configuration|
mut merged = $defaultConfiguration | merge $configuration
$merged.repo = $defaultConfiguration.repo | merge $merged.repo # make sure all repo properties exist

print $"Validating installation of (ansi default_italic)($merged.install | length)(ansi reset) Flatpaks from (ansi default_italic)($merged.repo.title)(ansi reset)"
print $"Validating configuration of (ansi default_italic)($merged.install | length)(ansi reset) Flatpaks from (ansi default_italic)($merged.repo.title)(ansi reset)"

if (not ($merged.scope == "system" or $merged.scope == "user")) {
print $"(ansi red_bold)Scope must be either(ansi reset) (ansi blue_italic)system(ansi reset) (ansi red_bold)or(ansi reset) (ansi blue_italic)user(ansi reset)"
Expand Down Expand Up @@ -51,11 +51,11 @@ def main [configStr: string] {
}

open $configPath
| append $installations
| append $configurations
| to yaml | save -f $configPath

print $"(ansi green_bold)Successfully generated following installations:(ansi reset)"
print ($installations | to yaml)
print $"(ansi green_bold)Successfully generated following configurations:(ansi reset)"
print ($configurations | to yaml)

print "Setting up Flatpak setup services..."

Expand Down
40 changes: 40 additions & 0 deletions modules/default-flatpaks/v2/post-boot/system-flatpak-setup
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
#!/usr/bin/env nu

const usrSharePath = "/usr/share/bluebuild/default-flatpaks"
const configPath = $"($usrSharePath)/configuration.yaml"

def main [] {
let configFile = open $configPath

if (flatpak remotes | str contains fedora) {
/usr/bin/gnome-software --quit
/usr/lib/fedora-third-party/fedora-third-party-opt-out
/usr/bin/fedora-third-party disable

flatpak remote-delete --system fedora --force
flatpak remote-delete --system fedora-testing --force

# TODO remove Fedora Flatpaks
}

$configFile.configurations | where scope == system | each { |config|
flatpak remote-add --system --if-not-exists $config.repo.name $config.repo.url --title $config.repo.title

if ($config.notify) {
# TODO implement notification sending
# (notify-send
# --app-name "Automatic Flatpak Installation Service"
# $"Starting automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)..."
# )
}

flatpak install --system $config.repo.name ...$config.install

if ($config.notify) {
# (notify-send
# --app-name "Automatic Flatpak Installation Service"
# $"Finished automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)!"
# ($config.install | str join ', ')
# )
}
}
}
33 changes: 33 additions & 0 deletions modules/default-flatpaks/v2/post-boot/user-flatpak-setup
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
#!/usr/bin/env nu

const usrSharePath = "/usr/share/bluebuild/default-flatpaks"
const configPath = $"($usrSharePath)/configuration.yaml"

def main [] {
let configFile = open $configPath

if (flatpak remotes | str contains fedora) {
flatpak remote-delete --user fedora --force
flatpak remote-delete --user fedora-testing --force
}

$configFile.configurations | where scope == user | each { |config|
flatpak remote-add --user --if-not-exists $config.repo.name $config.repo.url --title $config.repo.title

if ($config.notify) {
(notify-send
--app-name "Automatic Flatpak Installation Service"
$"Starting automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)..."
)
}

flatpak install --user $config.repo.name ...$config.install

if ($config.notify) {
(notify-send
--app-name "Automatic Flatpak Installation Service"
$"Finished automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)!"
($config.install | str join ', ')
)
}
}
}

0 comments on commit 1415893

Please sign in to comment.