Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
refactor: fetch modules from bling
Browse files Browse the repository at this point in the history
  • Loading branch information
xynydev committed Sep 10, 2023
1 parent 393d54e commit 4e0095b
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 434 deletions.
7 changes: 6 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ COPY --from=ghcr.io/ublue-os/bling:latest /files /tmp/bling/files

# Copy build scripts & configuration
COPY build.sh /tmp/build.sh
COPY modules /tmp/modules/
COPY config /tmp/config/

# Copy modules
# The default modules are inside ublue-os/bling
COPY --from=ghcr.io/ublue-os/bling:latest /modules /tmp/modules/
# Custom modules overwrite defaults
COPY modules /tmp/modules/

# `yq` is used for parsing the yaml configuration
# It is copied from the official container image since it's not available as an RPM.
COPY --from=docker.io/mikefarah/yq /usr/bin/yq /usr/bin/yq
Expand Down
30 changes: 1 addition & 29 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ At the top of the recipe, there are four *mandatory* configuration options.

The core of startingpoint's configuration is built around the idea of modules. Modules are scripts in the [`../modules`](../modules/) directory that you list out under `modules:` in the recipe. They are executed in order, and can run arbitrary shell commands and write any files.

This repository comes with some modules out of the box, like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For a comprehensive list of modules, check out [the modules directory](../modules/).

For more in-depth documentation on each module, check out the README.md files in each module folder.
This repository fetches some useful default modules from [`ublue-os/bling`](https://github.com/ublue-os/bling/), like [`rpm-ostree`](../modules/rpm-ostree) for pseudo-declarative package management, [`bling`](../modules/bling) for pulling extra components from [`ublue-os/bling`](https://github.com/ublue-os/bling), and [`files`](../modules/files) for copying files from the `config/files/` directory into your image. For a comprehensive list of modules and their in-depth documentation, check out [the modules page on the website](https://universal-blue.org/tinker/modules/).

### Including modules from other files and building multiple images

Expand All @@ -30,30 +28,4 @@ Module configuration can be included from other files using the `from-file` synt
```yml
modules:
- from-file: common-packages.yml
```
### Making modules
If you want to extend Startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of the [`../modules`](../modules/) directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix.

Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option.

Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`.

Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`.

A helper bash function called `get_yaml_array` is exported from the main build script.
```bash
# "$1" is the first cli argument, being the module configuration.
# If you need to read from some other JSON string, just replace "$1" with "$VARNAME".
get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1"
for THING in "${OUTPUT_VAR_NAME[@]}"; do
echo "$THING"
done
```

All bash-based modules should start with the following lines to ensure the image builds fail on errors, and that the correct shell is used to run them.
```bash
#!/usr/bin/env bash
set -oue pipefail
```
26 changes: 24 additions & 2 deletions modules/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# Modules
# Making modules

This directory includes all the different modules for Startingpoint. Refer to the README files inside each module's corresponding directory for in-depth documentation, and the README inside `config/` for more general documentation.
If you want to extend Startingpoint with custom functionality that requires configuration, you should create a module. Modules are scripts in the subdirectories of this directory. The `type:` key in the recipe.yml should be used as both the name of the folder and script, with the script having an additional `.sh` suffix. Creating a custom module with the same name as a default module will override it.

Each module intended for public usage should include a `README.md` file inside it's directory with a short description of the module and documentation for each configuration option.

Modules get only the configuration options given to them in the recipe.yml, not the configuration of other modules or any top-level keys. The configuration is given as the first argument as a single-line json string. You can check out the default modules for examples on how to parse such string using `yq` or `jq`.

Additionally, each module has access to four environment variables, `CONFIG_DIRECTORY` pointing to the Startingpoint directory in `/usr/share/ublue-os/`, `IMAGE_NAME` being the name of the image as declared in the recipe, `BASE_IMAGE` being the URL of the container image used as the base (FROM) in the image, and `OS_VERSION` being the `VERSION_ID` from `/usr/lib/os-release`.

A helper bash function called `get_yaml_array` is exported from the main build script.
```bash
# "$1" is the first cli argument, being the module configuration.
# If you need to read from some other JSON string, just replace "$1" with "$VARNAME".
get_yaml_array OUTPUT_VAR_NAME '.yq.key.to.array[]' "$1"
for THING in "${OUTPUT_VAR_NAME[@]}"; do
echo "$THING"
done
```

All bash-based modules should start with the following lines to ensure the image builds fail on errors, and that the correct shell is used to run them.
```bash
#!/usr/bin/env bash
set -oue pipefail
```
20 changes: 0 additions & 20 deletions modules/bling/README.md

This file was deleted.

19 changes: 0 additions & 19 deletions modules/bling/bling.sh

This file was deleted.

7 changes: 0 additions & 7 deletions modules/bling/installers/dconf-update-service.sh

This file was deleted.

6 changes: 0 additions & 6 deletions modules/bling/installers/devpod.sh

This file was deleted.

6 changes: 0 additions & 6 deletions modules/bling/installers/fonts.sh

This file was deleted.

6 changes: 0 additions & 6 deletions modules/bling/installers/justfiles.sh

This file was deleted.

7 changes: 0 additions & 7 deletions modules/bling/installers/nix-installer.sh

This file was deleted.

6 changes: 0 additions & 6 deletions modules/bling/installers/ublue-os-wallpapers.sh

This file was deleted.

20 changes: 0 additions & 20 deletions modules/bling/installers/ublue-update.sh

This file was deleted.

16 changes: 0 additions & 16 deletions modules/files/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions modules/files/files.sh

This file was deleted.

33 changes: 0 additions & 33 deletions modules/rpm-ostree/README.md

This file was deleted.

58 changes: 0 additions & 58 deletions modules/rpm-ostree/rpm-ostree.sh

This file was deleted.

26 changes: 0 additions & 26 deletions modules/script/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions modules/script/script.sh

This file was deleted.

Loading

0 comments on commit 4e0095b

Please sign in to comment.