-
Notifications
You must be signed in to change notification settings - Fork 26
refactor(default-flatpaks): version 2 (nushell) #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
7e33425
feat: initial draft of default-flatpaks v2
xynydev 851ecfd
chore: streamline logging
xynydev 2cd4439
chore: replace json with yaml as generated config format
xynydev a45fc97
feat: set up groundwork for post boot scripts
xynydev 1415893
feat: rename installations -> configurations, initial implementation …
xynydev da675a4
fix: put executable files into /usr/libexec/
xynydev 6510afa
fix: improve fedora remote detection and removal
xynydev 7185ef5
feat: implement notifications for system flatpak setup
xynydev 28a0238
chore(default-flatpaks): No need to expose `DISPLAY` for notify-send
fiftydinar 92f501a
Merge branch 'main' into nu-flatpaks
fiftydinar 9498a79
chore(default-flatpaks): Update service & add timers to match v1
fiftydinar dd5ae9e
chore(default-flatpaks): Copy & enable timers instead of services
fiftydinar ed42c96
chore(default-flatpaks): Fix typo for copying `user-flatpak-setup` timer
fiftydinar 81d210a
chore(default-flatpaks): Copy post-boot files directly instead of pla…
fiftydinar d83856d
chore(default-flatpaks): Forgot to remove copying step of post-boot f…
fiftydinar 832041a
Merge branch 'main' into nu-flatpaks
fiftydinar 5f13d9d
Merge branch 'main' into nu-flatpaks
xynydev 97fea21
chore: update to be in accordance with cli support for nushell
xynydev 4b23110
feat: allow usage of fedora flatpak remote, remove fedora flatpaks an…
xynydev 2de6e0b
feat: refactor schema to support multiple versions of the module
xynydev ba33ac5
Merge branch 'main' into nu-flatpaks
xynydev 56fa555
docs: separate docs for separate module versions
xynydev fefcde5
fix: copy user-flatpak-setup.timer to correct directory
xynydev 44fb906
chore: correctly document default values in schema
xynydev aa74130
fix: better flathub package checking
xynydev b42d1e4
feat: warn users when giving this module v1 configuration
xynydev 5c032d2
fix: prevent addition of http get result into unavailablePackages list
xynydev ab7db0d
fix: mkdir before cp
xynydev 0083dce
chore: fix () semantics problems highlighted by debugger
xynydev ffd8d5a
feat: bluebuild-flatpak-manager CLI
xynydev 993d5c6
feat: alert user when trying to use module with old configuration
xynydev 8f790b8
docs: write basic documentation page and rewrite example
xynydev 6a5f88b
Merge branch 'main' into nu-flatpaks
xynydev 2439215
fix: attempt to use configFile variable without dollar sign
xynydev 19bd31e
fix: no such things as .configurations
xynydev 41476ba
fix: ensure no empty list is printed
xynydev d1e4864
docs: add a quick note about learning to use the flatpak manager tool
xynydev 188d0e8
fix(schema): distinquish between versions
xynydev 10070cb
fix: add noninteractive flag to flatpak install commands
xynydev 0e173e9
fix: ensure repo to be used is enabled
xynydev 2f99df4
chore: ignore errors in notify wrapper just in case
xynydev f62e37e
chore: add link to announcement
xynydev 2cf31c5
docs: run through languagetool
xynydev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,58 @@ | ||
| name: default-flatpaks | ||
| shortdesc: The default-flatpaks module can be used to install or uninstall flatpaks from a configurable remote on every boot. | ||
| example: | | ||
| modules: # configured multiple times to highlight how options are overridden | ||
| - type: default-flatpaks | ||
| notify: true # Send notification after install/uninstall is finished (true/false) | ||
| system: | ||
| # If no repo information is specified, Flathub will be used by default | ||
| repo-url: https://dl.flathub.org/repo/flathub.flatpakrepo | ||
| repo-name: flathub | ||
| repo-title: "Flathub (system-wide)" # Optional; this sets the remote's user-facing name in graphical frontends like GNOME Software | ||
| install: | ||
| - org.gnome.Loupe | ||
| - one.ablaze.floorp//lightning # This is an example of flatpak which has multiple branches in selection (flatpak//branch). | ||
| # Flatpak runtimes are not supported (like org.winehq.Wine//stable-23.08). | ||
| # Only normal flatpak applications are (like Floorp Lightning web browser in this example). | ||
| # Multiple install of same flatpaks with different branches is not supported. | ||
| remove: | ||
| - org.gnome.eog | ||
| # A flatpak repo can also be added without having to install flatpaks, | ||
| # as long as one of the repo- fields is present | ||
| user: | ||
| repo-name: flathub | ||
| versions: | ||
| - version: v1 | ||
| example: | | ||
| modules: # configured multiple times to highlight how options are overridden | ||
| - type: default-flatpaks@v1 | ||
| notify: true # Send notification after install/uninstall is finished (true/false) | ||
| system: | ||
| # If no repo information is specified, Flathub will be used by default | ||
| repo-url: https://dl.flathub.org/repo/flathub.flatpakrepo | ||
| repo-name: flathub | ||
| repo-title: "Flathub (system-wide)" # Optional; this sets the remote's user-facing name in graphical frontends like GNOME Software | ||
| install: | ||
| - org.gnome.Loupe | ||
| - one.ablaze.floorp//lightning # This is an example of flatpak which has multiple branches in selection (flatpak//branch). | ||
| # Flatpak runtimes are not supported (like org.winehq.Wine//stable-23.08). | ||
| # Only normal flatpak applications are (like Floorp Lightning web browser in this example). | ||
| # Multiple install of same flatpaks with different branches is not supported. | ||
| remove: | ||
| - org.gnome.eog | ||
| # A flatpak repo can also be added without having to install flatpaks, | ||
| # as long as one of the repo- fields is present | ||
| user: | ||
| repo-name: flathub | ||
|
|
||
| # Assuming that the above example is configured first in a recipe, | ||
| # a subsequent usage might look like this: | ||
| - type: default-flatpaks | ||
| system: | ||
| # If the repo-* fields are omitted on the subsequent usage, | ||
| # the module will use the previously configured repo. | ||
| # Otherwise, it will overwrite the repo configuration. | ||
| install: | ||
| - org.kde.kdenlive # this Flatpak is appended to the install list | ||
| user: | ||
| # repo-name will overwrite the previously-configured repo-name for the user remote | ||
| repo-name: flathub-user | ||
| repo-title: "Flathub (User) | ||
| # Assuming that the above example is configured first in a recipe, | ||
| # a subsequent usage might look like this: | ||
| - type: default-flatpaks | ||
| system: | ||
| # If the repo-* fields are omitted on the subsequent usage, | ||
| # the module will use the previously configured repo. | ||
| # Otherwise, it will overwrite the repo configuration. | ||
| install: | ||
| - org.kde.kdenlive # this Flatpak is appended to the install list | ||
| user: | ||
| # repo-name will overwrite the previously-configured repo-name for the user remote | ||
| repo-name: flathub-user | ||
| repo-title: "Flathub (User | ||
| - version: v2 | ||
| example: | | ||
| - type: default-flatpaks | ||
| configurations: | ||
| - scope: user | ||
| repo: | ||
| # you can override the title to make inclusion of both system and user repos clearer | ||
| title: Flathub (user) | ||
| - notify: true | ||
| scope: system | ||
| repo: | ||
| title: Flathub (system) | ||
| install: # system flatpaks we want all users to have and not remove | ||
| - org.mozilla.firefox | ||
| - com.github.tchx84.Flatseal | ||
| - io.github.flattool.Warehouse | ||
| - io.missioncenter.MissionCenter | ||
| - com.github.rafostar.Clapper | ||
| - org.gnome.Loupe |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # `default-flatpaks` | ||
|
|
||
| :::note | ||
| For instructions on migration from v1 to v2, see the [announcement blog post](/blog/default-flatpaks-v2). | ||
| ::: | ||
|
|
||
| The `default-flatpaks` module can be used to install Flatpaks from a configurable remote on every boot. By default the module will remove the Fedora Flatpak remote and install the Flathub remote, but you can also configure it to install other Flatpaks from other remotes. | ||
|
|
||
| ## Features | ||
|
|
||
| - System and user systemd services that are based on your configuration | ||
| - Set up a Flatpak remote | ||
| - Install Flatpaks from the remote | ||
| - CLI tool `bluebuild-flatpak-manager` to | ||
| - Display the Flatpak configurations in the image | ||
| - Manually initiate the setup of Flatpaks | ||
| - Disable the automatic Flatpak setup | ||
| - Re-enable the automatic Flatpak setup | ||
| - _run the `bluebuild-flatpak-manager` command for help and documentation_ | ||
|
|
||
| ## Configuration | ||
|
|
||
| The `default-flatpaks` module configuration is based on a list of `configurations:` that each set a scope to install in (`system` or `user`), a Flatpak repository to set up, and a list of Flatpaks to install from the repository. | ||
|
|
||
| Multiple configurations are supported, and subsequent module calls will append new configurations to the list. Overriding previous configurations is currently not supported. | ||
|
|
||
| ### Scope | ||
|
|
||
| The `scope:` property can be set to `system` or `user`. If omitted, the default is `user`. This property determines whether the Flatpak repository and packages are set up for the system or for each user separately. | ||
|
|
||
| For a single-user system, you can safely use the `user` scope, since that will allow installation of Flatpaks from the configured repo and management of the installed Flatpaks without authentication. If you have multiple users for whom you want to set up the same system Flatpaks, you should use the `system` scope. This ensures that the Flatpaks are not duplicated in each user's home directory, and that managing the Flatpaks requires admin permissions. | ||
|
|
||
| ### Flatpak repository | ||
|
|
||
| The `repo:` property is used to configure the Flatpak repository to set up. If omitted, Flathub will be used by default. The URL should be a link to a `.flatpakrepo` file. The name and title are used to identify the repository in the Flatpak CLI; the name should be lowercase and not contain spaces, while the title can be any string. | ||
|
|
||
| ### Notification | ||
|
|
||
| The `notify:` property can be set to `true` or `false`. If omitted, the default is `true`. This will send a notification on each boot to the user(s) when starting the Flatpak installation and when it is finished. | ||
|
|
||
| ### Flatpak installation | ||
|
|
||
| The `install:` property is a list of the Flatpak IDs to install from the configured repository. If omitted, no Flatpaks will be installed, but the Flatpak repository will still be set up. If the repository to use is configured as Flathub, the list of Flatpaks will be validated at build time to ensure that the packages are available on Flathub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/usr/libexec/bluebuild/nu/nu | ||
|
|
||
| const flathubURL = "https://dl.flathub.org/repo/flathub.flatpakrepo" | ||
|
|
||
| const defaultConfiguration = { | ||
| notify: true | ||
| scope: user | ||
| repo: { | ||
| url: $flathubURL | ||
| name: "flathub" | ||
| title: "Flathub" | ||
| } | ||
| install: [] | ||
| } | ||
|
|
||
| const usrSharePath = "/usr/share/bluebuild/default-flatpaks" | ||
| const libExecPath = "/usr/libexec/bluebuild/default-flatpaks" | ||
| const configPath = $"($usrSharePath)/configuration.yaml" | ||
|
|
||
| def main [configStr: string] { | ||
| let config = $configStr | from yaml | ||
|
|
||
| if ('user' in $config or 'system' in $config) { | ||
| print $"(ansi red_bold)CONFIGURATION ERROR(ansi reset)" | ||
| print $"(ansi yellow_reverse)HINT(ansi reset): the default-flatpaks module has been updated with breaking changes!" | ||
| print $"It seems like you are trying to run the new (ansi default_italic)default-flatpaks@v2(ansi reset) module with configuration made for the older version." | ||
| print $"You can read the docs to migrate to the new and improved module, or just change switch back to the old module like this (ansi default_italic)type: default-flatpaks@v1(ansi reset)" | ||
| exit 1 | ||
| } | ||
|
|
||
| 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 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)" | ||
| print $"(ansi blue)Your input:(ansi reset) ($merged.scope)" | ||
| exit 1 | ||
| } | ||
| if (not ($merged.notify == true or $merged.notify == false)) { | ||
| print $"(ansi red_bold)Notify must be either(ansi reset) (ansi blue_italic)true(ansi reset) (ansi red_bold)or(ansi reset) (ansi blue_italic)false(ansi reset)" | ||
| print $"(ansi blue)Your input:(ansi reset) ($merged.notify)" | ||
| exit 1 | ||
| } | ||
| if ($merged.repo.url == $flathubURL) { | ||
| checkFlathub $merged.install | ||
| } | ||
|
|
||
| print $"Validation successful!" | ||
|
|
||
| $merged | ||
| } | ||
|
|
||
|
|
||
| if (not ($configPath | path exists)) { | ||
| mkdir ($configPath | path dirname) | ||
| '[]'| save $configPath | ||
| } | ||
|
|
||
| open $configPath | ||
| | append $configurations | ||
| | to yaml | save -f $configPath | ||
|
|
||
| print $"(ansi green_bold)Successfully generated following configurations:(ansi reset)" | ||
| print ($configurations | to yaml) | ||
|
|
||
| print "Setting up Flatpak setup services..." | ||
|
|
||
| mkdir /usr/lib/systemd/system/ | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/system-flatpak-setup.service" /usr/lib/systemd/system/system-flatpak-setup.service | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/system-flatpak-setup.timer" /usr/lib/systemd/system/system-flatpak-setup.timer | ||
| mkdir /usr/lib/systemd/user/ | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/user-flatpak-setup.service" /usr/lib/systemd/user/user-flatpak-setup.service | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/user-flatpak-setup.timer" /usr/lib/systemd/user/user-flatpak-setup.timer | ||
| systemctl enable --force system-flatpak-setup.timer | ||
| systemctl enable --force --global user-flatpak-setup.timer | ||
|
|
||
| mkdir ($libExecPath) | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/system-flatpak-setup" $"($libExecPath)/system-flatpak-setup" | ||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/user-flatpak-setup" $"($libExecPath)/user-flatpak-setup" | ||
| chmod +x $"($libExecPath)/system-flatpak-setup" | ||
| chmod +x $"($libExecPath)/user-flatpak-setup" | ||
|
|
||
| cp $"($env.MODULE_DIRECTORY)/default-flatpaks/post-boot/bluebuild-flatpak-manager" "/usr/bin/bluebuild-flatpak-manager" | ||
| chmod +x "/usr/bin/bluebuild-flatpak-manager" | ||
| } | ||
|
|
||
| def checkFlathub [packages: list<string>] { | ||
| print "Checking if configured packages exist on Flathub..." | ||
| let unavailablePackages = $packages | each { |package| | ||
| try { | ||
| let _ = http get $"https://flathub.org/api/v2/stats/($package)" | ||
| } catch { | ||
| $package | ||
| } | ||
| } | ||
| if ($unavailablePackages | length) > 0 { | ||
| print $"(ansi red_bold)The following packages are not available on Flathub, which is the specified repository for them to be installed from:(ansi reset) " | ||
| for package in $unavailablePackages { | ||
| print $"(ansi default_italic)($package)(ansi reset)" | ||
| } | ||
| exit 1 | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.