├── .gitignore ├── system ├── usr__lib__ostree__auth.json ├── etc__skel__kde-bootc ├── usr__lib__credstore__home.create.admin ├── usr__local__bin │ └── firstboot-setup ├── usr__local__share__kde-bootc__packages-added └── usr__local__share__kde-bootc__packages-removed ├── systemd ├── usr__lib__systemd__system__bootc-fetch.service ├── usr__lib__systemd__system__bootc-fetch.timer └── usr__lib__systemd__system__firstboot-setup.service ├── scripts ├── config-authselect └── config-users ├── .github └── workflows │ └── container-image.yml ├── Containerfile ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /system/usr__lib__ostree__auth.json: -------------------------------------------------------------------------------- 1 | {"auths":{"ghcr.io/sigulete/kde-bootc":{"auth":""}}} 2 | -------------------------------------------------------------------------------- /systemd/usr__lib__systemd__system__bootc-fetch.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Fetch bootc image 3 | ConditionPathExists=/run/ostree-booted 4 | 5 | [Service] 6 | Type=oneshot 7 | ExecStart=/usr/bin/bootc update 8 | -------------------------------------------------------------------------------- /scripts/config-authselect: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Allow systemd-homed authorisation mechanism 4 | authselect enable-feature with-systemd-homed 5 | 6 | # Allow fingerprint authorisation mechanism 7 | authselect enable-feature with-fingerprint 8 | -------------------------------------------------------------------------------- /systemd/usr__lib__systemd__system__bootc-fetch.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Fetch bootc image daily 3 | ConditionPathExists=/run/ostree-booted 4 | After=multi-user.target 5 | 6 | [Timer] 7 | OnCalendar=*-*-* 12:30:00 8 | Persistent=true 9 | 10 | [Install] 11 | WantedBy=timers.target 12 | -------------------------------------------------------------------------------- /systemd/usr__lib__systemd__system__firstboot-setup.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Setup USERS and /VAR at boot 3 | After=multi-user.target 4 | 5 | [Service] 6 | Type=oneshot 7 | RemainAfterExit=yes 8 | ExecStart=/usr/local/bin/firstboot-setup 9 | ImportCredential=home.create.* 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /system/etc__skel__kde-bootc: -------------------------------------------------------------------------------- 1 | # Alias 2 | alias la='ls --color=auto --time-style=long-iso -hla' 3 | alias laz='ls --color=auto --time-style=long-iso -hlaZ' 4 | alias llz='ls --color=auto --time-style=long-iso -hlZ' 5 | alias ll='ls --color=auto --time-style=long-iso -hl' 6 | 7 | # Prompt 8 | PS1="\n\[\033[00m\][\[\033[01;32m\]\u@\h \[\033[01;34m\]\w\[\033[00m\]]\\n\[\033[00m\]> " 9 | 10 | # Foreground 11 | # Black: 30 12 | # Blue: 34 13 | # Cyan: 36 14 | # Green: 32 15 | # Purple: 35 16 | # Red: 31 17 | # White: 37 18 | # Yellow: 33 19 | -------------------------------------------------------------------------------- /.github/workflows/container-image.yml: -------------------------------------------------------------------------------- 1 | name: build container -> kde-bootc 2 | run-name: building container -> kde-bootc 3 | on: 4 | workflow_dispatch: 5 | #push: 6 | schedule: 7 | # minute (0-59) hour (0-23) day of month (1-31) month (1-12) day of week (SUN-SAT) 8 | # Triggers Fri at 13:30 9 | - cron: '30 13 * * FRI' 10 | 11 | jobs: 12 | kde-bootc: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: run podman build 17 | run: podman build -t kde-bootc --disable-compression=false . 18 | - name: push image to ghcr.io 19 | run: podman push --creds=${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} kde-bootc ghcr.io/sigulete/kde-bootc:latest 20 | -------------------------------------------------------------------------------- /scripts/config-users: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | USER_NAME=admin 4 | 5 | # STANDARD USERS 6 | # Standard users are recorded in /etc/passwd and /etc/group 7 | # Creating users as part of the container build ensures these files won't drift 8 | #useradd -G wheel -u 1000 -K SUB_GID_MIN=1000001 -K SUB_UID_MIN=1000001 $USER_NAME 9 | #echo "Temp#SsaP" | passwd $USER_NAME -s 10 | 11 | # SYSTEMD-HOMED USERS 12 | # systemd-homed users are created by firstboot-setup during the initial boot, as they need systemd to be running 13 | # Setup subuid & subgid for the systemd-homed user 14 | echo "$USER_NAME:1000001:65536">/etc/subuid 15 | echo "$USER_NAME:1000001:65536">/etc/subgid 16 | 17 | # Setup initial password for root 18 | echo "Temp#SsaP" | passwd root -s 19 | -------------------------------------------------------------------------------- /system/usr__lib__credstore__home.create.admin: -------------------------------------------------------------------------------- 1 | { 2 | "userName" : "admin", 3 | "realName" : "Administrator", 4 | "storage" : "luks", 5 | "fileSystemType" : "btrfs", 6 | "diskSize" : 10737418240, 7 | "luksDiscard" : false, 8 | "luksOfflineDiscard" : true, 9 | "luksResizeMode" : "shrink-and-grow", 10 | "rebalanceWeight" : false, 11 | "uid" : 1000, 12 | "gid" : 1000, 13 | "disposition" : "regular", 14 | "memberOf" : [ 15 | "wheel" 16 | ], 17 | "privileged" : { 18 | "hashedPassword" : [ 19 | "$y$j9T$WPamCm9MCUrb7gxhkRS4E0$CKA0aY9b8kaRZVTPJr5PLhYETz43EZTspr8p6HnQWJ6" 20 | ] 21 | }, 22 | "secret" : { 23 | "password" : [ 24 | "Temp#SsaP" 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /system/usr__local__bin/firstboot-setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################### 4 | # Setup HOST 5 | ############################################### 6 | 7 | HOST_NAME=kde-bootc 8 | hostnamectl hostname $HOST_NAME 9 | 10 | ############################################### 11 | # Setup USERS 12 | ############################################### 13 | 14 | homectl firstboot 15 | 16 | ############################################### 17 | # Setup FIREWALL 18 | ############################################### 19 | 20 | if [ "$(firewall-cmd --get-default-zone)" != "public" ]; then firewall-cmd --set-default-zone=public; fi 21 | if [ -z "$(firewall-cmd --list-services | grep kdeconnect)" ]; then firewall-cmd --add-service=kdeconnect --permanent; fi 22 | firewall-cmd --reload 23 | -------------------------------------------------------------------------------- /system/usr__local__share__kde-bootc__packages-added: -------------------------------------------------------------------------------- 1 | #################################################### 2 | # List of packages to install on top of base image 3 | #################################################### 4 | 5 | # LibreOffice 6 | libreoffice 7 | libreoffice-help-en 8 | 9 | # Utilities 10 | vim-default-editor 11 | git 12 | vifm 13 | python3-pip 14 | 15 | # Cockpit 16 | cockpit 17 | cockpit-podman 18 | cockpit-selinux 19 | cockpit-machines 20 | 21 | # Virtualisation 22 | qemu-kvm 23 | libvirt 24 | virt-install 25 | virt-viewer 26 | 27 | # Tailscale network 28 | tailscale 29 | 30 | # Troubleshooting 31 | lshw 32 | htop 33 | ncdu 34 | nmap 35 | 36 | # Printer drivers 37 | # https://pagure.io/workstation-ostree-config/blob/main/f/common.yaml 38 | c2esp 39 | dymo-cups-drivers 40 | printer-driver-brlaser 41 | ptouch-driver 42 | splix 43 | 44 | # System 45 | kamera 46 | lm_sensors 47 | -------------------------------------------------------------------------------- /system/usr__local__share__kde-bootc__packages-removed: -------------------------------------------------------------------------------- 1 | #################################################### 2 | # List of packages to remove from image 3 | #################################################### 4 | 5 | # Discover plugins related to standard repositories (rpm) - Not compatible with bootc 6 | plasma-discover-offline-updates 7 | plasma-discover-packagekit 8 | 9 | # Helper to install package on the command line - Not compatible with bootc 10 | PackageKit-command-not-found 11 | 12 | # Utility for time-oriented job control - systemd-timer is better alternative 13 | at 14 | 15 | # IPTables are deprecated 16 | iptables-services 17 | iptables-utils 18 | 19 | # Enhance logging, but heavy in resources - journalctl is better alternative 20 | rsyslog 21 | 22 | # Generates rescue initramfs image - Bootc already provides rollback image 23 | dracut-config-rescue 24 | 25 | # Remove DNF4 26 | dnf-data 27 | -------------------------------------------------------------------------------- /Containerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/fedora-bootc:43 2 | MAINTAINER First Last 3 | 4 | # SETUP FILESYSTEM 5 | RUN rmdir /opt && ln -s -T /var/opt /opt 6 | RUN mkdir /var/roothome 7 | 8 | # PREPARE PACKAGES 9 | COPY --chmod=0644 ./system/usr__local__share__kde-bootc__packages-removed /usr/local/share/kde-bootc/packages-removed 10 | COPY --chmod=0644 ./system/usr__local__share__kde-bootc__packages-added /usr/local/share/kde-bootc/packages-added 11 | RUN jq -r .packages[] /usr/share/rpm-ostree/treefile.json > /usr/local/share/kde-bootc/packages-fedora-bootc 12 | 13 | # INSTALL REPOS 14 | RUN dnf -y install dnf5-plugins 15 | RUN dnf config-manager addrepo --from-repofile=https://pkgs.tailscale.com/stable/fedora/tailscale.repo 16 | 17 | # INSTALL PACKAGES 18 | RUN dnf -y install @kde-desktop-environment 19 | RUN grep -vE '^#' /usr/local/share/kde-bootc/packages-added | xargs dnf -y install --allowerasing 20 | 21 | # REMOVE PACKAGES 22 | RUN grep -vE '^#' /usr/local/share/kde-bootc/packages-removed | xargs dnf -y remove 23 | RUN dnf -y autoremove 24 | RUN dnf clean all 25 | 26 | # CONFIGURATION 27 | COPY --chmod=0755 ./system/usr__local__bin/* /usr/local/bin/ 28 | COPY --chmod=0644 ./system/etc__skel__kde-bootc /etc/skel/.bashrc.d/kde-bootc 29 | COPY --chmod=0600 ./system/usr__lib__ostree__auth.json /usr/lib/ostree/auth.json 30 | 31 | # USERS 32 | COPY --chmod=0644 ./system/usr__lib__credstore__home.create.admin /usr/lib/credstore/home.create.admin 33 | 34 | COPY --chmod=0755 ./scripts/* /tmp/scripts/ 35 | RUN /tmp/scripts/config-users 36 | RUN /tmp/scripts/config-authselect && rm -r /tmp/scripts 37 | 38 | # SYSTEMD 39 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__firstboot-setup.service /usr/lib/systemd/system/firstboot-setup.service 40 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__bootc-fetch.service /usr/lib/systemd/system/bootc-fetch.service 41 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__bootc-fetch.timer /usr/lib/systemd/system/bootc-fetch.timer 42 | 43 | RUN systemctl enable firstboot-setup.service 44 | RUN systemctl enable bootloader-update.service 45 | RUN systemctl mask bootc-fetch-apply-updates.timer 46 | 47 | # CLEAN & CHECK 48 | RUN find /var/log -type f ! -empty -delete 49 | RUN bootc container lint 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KDE-BOOTC 2 | The motivation for this project is inspired by the increasing popularity of atomic distros as technology advances. The Fedora project is one of the leaders in bringing this concept to the public, with other projects following suit. This approach offers significant benefits in terms of stability and security. 3 | 4 | They apply updates as a single transaction, known as atomic upgrades, which means if an update doesn't work as expected, the system can instantly roll back to its last stable state, saving users from potential issues. The immutable nature of the filesystem components reduces the risk of system corruption and unauthorised modifications as the core system files are read-only, making them impossible to modify. 5 | 6 | If you are planning to spin off various instances from the same image (e.g. setting up computers for members of your family or work), atomic distros provide a reliable desktop experience where every instance of the desktop is consistent with each other, reducing discrepancies in software versions and behaviour. 7 | 8 | Mainstream sources like Fedora and Universal Blue offer various atomic desktops with curated configurations and package selections for the average user. But what if you're ready to take control of your desktop and customise it entirely, from packages and configurations to firewall, DNS, and update schedules? 9 | 10 | Thanks to bootc and the associated tools, building a personalised desktop experience is no longer difficult. This project aims to provide you with basic tips to help you customise your desktop. This is not a final product, but the means and steps to build your own. 11 | 12 | ## What is bootc? 13 | Using existing container building techniques, bootc allows you to build your own OS. Container images adhere to the OCI specification and utilise container tools for building and transporting your containers. Once installed on a node, the container functions as a regular OS. 14 | 15 | The container image includes a Linux kernel (e.g., in `/usr/lib/modules`) for booting. Bootc includes a package manager, allowing you to scrutinise installed and available packages from existing and added repositories. Additionally, using `bootc usr-overlay`, bootc mounts an overlay on `/usr`, enabling temporary package installation via `dnf` for testing purposes. 16 | 17 | The filesystem structure follows ostree specifications: 18 | 19 | - The `/usr` directory is read-only, with all changes managed by the container image. 20 | - The `/etc` directory is editable, but any changes applied in the container image will be transferred to the node unless the file was modified locally. 21 | - Changes to `/var` (including `/var/home`) are made during the first boot. Afterwards, `/var` remains untouched. 22 | 23 | The full documentation for bootc can be found here: https://bootc-dev.github.io/bootc/ 24 | 25 | ## What is kde-bootc? 26 | This project utilises `quay.io/fedora/fedora-bootc` as the base image to create a customizable container for building your personalised Fedora KDE atomic desktop. 27 | 28 | The aim is to explain basic concepts and share some useful tips. It is important to note that this template is meant to be modified according to your needs, so it is not necessarily a final product. However, it will work out of the box. 29 | 30 | Although it is tailored to KDE Plasma, most of the concepts and methodologies also apply to other desktop environments. 31 | 32 | ## Repository structure 33 | I tried to organise the repository for easy reading and maintenance. Files are stored in functional and well-defined directories, making them easy to find and understand their purpose and where they will be placed in the container image. 34 | 35 | Each file follows a specific naming convention. For instance a file `/usr/lib/credstore/home.create.admin` is named as `usr__lib__credstore__home.create.admin` 36 | 37 | **Folders:** 38 | - *.github*: Contains an example of GitHub action to build the container and publish the image 39 | - *scripts*: Contains scripts to be ran from the Containerfile during building 40 | - *system*: Contains files to be copied to `/usr` and `/etc` 41 | - *systemd*: Contains systemd unit files to be copied to `/usr/lib/systemd` 42 | 43 | ## Explaining the Containerfile step by step 44 | ### Image base 45 | The `fedora-bootc` project is part of the Cloud Native Computing Foundation (CNCF) Sandbox projects and  generates reference "base images" of bootable containers designed for use with the bootc project. In this project, I'm using `quay.io/fedora/fedora-bootc` as base image. 46 | ``` 47 | FROM quay.io/fedora/fedora-bootc 48 | ``` 49 | ### Setup filesystem 50 | If you plan to install software on day 2, after the *kde-bootc* installation is complete, you may need to link `/opt` to `/var/opt`. Otherwise, `/opt` will remain an immutable directory that can only be populated from the container build. 51 | ``` 52 | RUN rmdir /opt && ln -s -T /var/opt /opt 53 | ``` 54 | In some cases, for successful package installation the `/var/roothome` directory must exist. If this folder is missing, the container build may fail. It is advisable to create this directory before installing packages. 55 | ``` 56 | RUN mkdir /var/roothome 57 | ``` 58 | ### Prepare packages 59 | To simplify the installation, and to have a record of installed and removed packages for future reference, I found useful keeping them as a resource under `/usr/share`. 60 | - All additional packages to be installed on top of *fedora-bootc* and the *KDE environment* are documented in `packages-added`. 61 | - Packages to be removed from *fedora-bootc* and the *KDE environment* are documented in `packages-removed`. 62 | - For convenience, the packages included in the base *fedora-bootc* are documented in `packages-fedora-bootc`. 63 | ``` 64 | COPY --chmod=0644 ./system/usr__local__share__kde-bootc__packages-removed /usr/local/share/kde-bootc/packages-removed 65 | COPY --chmod=0644 ./system/usr__local__share__kde-bootc__packages-added /usr/local/share/kde-bootc/packages-added 66 | RUN jq -r .packages[] /usr/share/rpm-ostree/treefile.json > /usr/local/share/kde-bootc/packages-fedora-bootc 67 | ``` 68 | ### Install repositories 69 | This section handles adding extra repositories needed before installing packages. 70 | 71 | In this example, I'm adding Tailscale, which is commonly used by the community, but the same principle applies to any other source you may add to your repositories. 72 | 73 | Adding repositories uses the `config-manager` verb, available as a DNF5 plugin. This plugin is not pre-installed by default in *fedora-bootc*, so it will need to be installed beforehand. 74 | ``` 75 | RUN dnf -y install dnf5-plugins 76 | RUN dnf config-manager addrepo --from-repofile=https://pkgs.tailscale.com/stable/fedora/tailscale.repo 77 | ``` 78 | ### Install packages 79 | For clarity and task separation, I divided the installation into two steps. 80 | 81 | Installation of environment and groups: 82 | ``` 83 | RUN dnf -y install @kde-desktop-environment 84 | ``` 85 | And the installation of all other individual packages: 86 | ``` 87 | RUN grep -vE '^#' /usr/local/share/kde-bootc/packages-added | xargs dnf -y install –allowerasing 88 | ``` 89 | The script will select all lines not starting with `#` to be passed as arguments to `dnf -y install`. The `--allowerasing` option is necessary for cases like installing `vim-default-editor`, which would conflict with `nano-default-editor`, removing the latter first. 90 | 91 | This is one of the key files to modify to customise your installation. 92 | ### Remove packages 93 | Some of the standard packages included in `@kde-desktop-environment` don’t behave well and sometimes conflict with an immutable desktop, so they need to be removed. 94 | 95 | This is also an opportunity to remove software you may never use, saving resources and storage. 96 | ``` 97 | RUN grep -vE '^#' /usr/local/share/kde-bootc/packages-removed | xargs dnf -y remove 98 | RUN dnf -y autoremove 99 | RUN dnf clean all 100 | ``` 101 | The criteria used in this project is summarised below: 102 | - Remove packages that conflict with bootc and its immutable nature. 103 | - Remove packages that bring unwanted dependencies, such as DNF4 and GTK3. 104 | - Remove packages that handle deprecated services. 105 | - Remove packages that are resource-heavy, or bring unnecessary services. 106 | ### Configuration 107 | This section is designated for copying all necessary configuration files to `/usr` and `/etc`. As recommended by the *bootc project*, prioritise using `/usr` and use `/etc` as a fallback if needed. 108 | 109 | Bash scripts that will be used by systemd services are stored in `/usr/local/bin`: 110 | ``` 111 | COPY --chmod=0755 ./system/usr__local__bin/* /usr/local/bin/ 112 | ``` 113 | Custom configuration for new users' home directories will be added to `/etc/skel/`. This project adds `.bashrc.d/kde-bootc` to customise bash, and it can be tweaked as needed. 114 | ``` 115 | COPY --chmod=0644 ./system/etc__skel__kde-bootc /etc/skel/.bashrc.d/kde-bootc 116 | ``` 117 | If you're building your container image on GitHub and keeping it private, you'll need to create a **GITHUB_TOKEN** to download the image. Further information on [GitHub container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry). 118 | 119 | A **GITHUB_TOKEN** can be created from global settings under *Developer settings*. The only required scope for the token is `read:packages`, which will allow you to download your image. 120 | 121 | Using this token, create the **GITHUB_CREDENTIAL** by generating a base64 output from your **GitHub USERNAME** and **GITHUB_TOKEN** combination: 122 | ``` 123 | echo : | base64 124 | ``` 125 | The output must be added to `usr__lib__ostree__auth.json` file, which is copied to `/usr/lib/ostree/auth.json` for bootc to reference when downloading the image from your GitHub registry to update the system. 126 | ``` 127 | COPY --chmod=0600 ./system/usr__lib__ostree__auth.json /usr/lib/ostree/auth.json 128 | ``` 129 | ### Users 130 | This section is divided into two groups: one copies configuration files, and the other runs scripts to set up the system. 131 | 132 | I opted for `systemd-homed` users because they are better suited than regular users for immutable desktops, preventing potential drift if `/etc/passwd` is modified locally. Additionally, each user home benefits from LUKS encrypted volume. However, the script includes an option to create regular users as a reference, which is currently commented out. 133 | 134 | The process begins when `firstboot-setup` runs, triggered by `firstboot-setup.service` during boot. It executes `homectl firstboot`, which checks if any regular home areas exist. If none are found, it searches for service credentials starting with `home.create.` to create users at boot. 135 | 136 | You can't create systemd-homed users in the container build, because systemd must be running. 137 | 138 | Service credentials are imported into the systemd service using the following parameter: 139 | ``` 140 | firstboot-setup.service 141 | ... 142 | ImportCredential=home.create.* 143 | ``` 144 | For more details, refer to `homectl` and `systemd.exec` manual pages. 145 | 146 | The homed identity file (`usr__lib__credstore__home.create.admin`) sets the user's parameters, including username, real name, storage type, etc. This file can be modified to customise your user(s). 147 | 148 | This example sets up a homed area using LUKS storage and a BTRF filesystem. I noticed that for LUKS storage, at least two parameters must be defined: `diskSize` and `rebalanceWeight`. If either is missing, `systemd-homed` will add a `perMachine` section defining these parameters, which will take precedence over the top-level user record (you may have set) because `perMachine` section supersedes them. 149 | 150 | **Most common parameters to adjust:** 151 | - `userName`: A single word for your username and home directory. In this example, it is `admin`. 152 | - `realName`: Full Name 153 | - `diskSize`: The size of the LUKS storage volume, calculated in bytes. For instance, 1 GB equals 1024x1024x1024 bytes, which is 1073741824 bytes. This example sets up a 10GB storage volume. 154 | - `rebalanceWeight`: Relevant only when multiple user accounts share the available storage. If `diskSize` is defined, this parameter can be set to `false`. 155 | - `uid/gid`: User and Group ID. The default range for regular users is 1000-6000, and for `systemd-homed` users, it is 60001-60513. However, you can assign uid/gid for `systemd-homed` users from both ranges; in this example, they are set to `1000`. 156 | - `memberOf`: The groups the user belongs to. As a power user, it should be part of the `wheel` group. 157 | - `hashedPassword`: This is the hashed version of the password stored under secret. Setting up an initial password allows `homectl firstboot` to create the user without prompting. This password should be changed afterwards (`homectl passwd admin`). This hash can be created using `mkpasswd` utility. 158 | 159 | The identity file is stored in one of the directories where `systemd-homed` expects to find credentials. 160 | ``` 161 | COPY --chmod=0644 ./system/usr__lib__credstore__home.create.admin /usr/lib/credstore/home.create.admin 162 | ``` 163 | For more information on user records, visit: https://systemd.io/USER_RECORD/ 164 | 165 | Another key parameter to set up is the range for `/etc/subuid` and `/etc/subgid` for the `admin` user. This range is necessary for running rootless containers, as each uid inside the container will be mapped to a uid outside the container within this range. When using `systemd-homed`, note that the available uid/gid ranges are predefined by systemd, and some ranges may be unavailable. Therefore, the chosen range in these files must adhere to these limitations. 166 | 167 | When running `findmnt` or `mount` command, the mount option `idmapped` will show for `/var/home/admin`, indicating that it was pre-mapped by systemd. 168 | 169 | The available range is 524288…1879048191. In this example, I chose 1000001 to easily identify the service running in the container. For instance, if the container is running Apache with uid=48, the volume or folder bound to it will have uid=1000048. 170 | 171 | For more information on available ranges, visit: https://systemd.io/UIDS-GIDS/ 172 | 173 | The `config-users` script sets this up and also creates a temporary password for the root user. As I will explain later, having a root user as an alternative login is important. 174 | 175 | The next script will set up `authselect` to enable authenticating the `admin` user on the login page. To achieve this, we need to enable the features `with-systemd-homed` and `with-fingerprint` (if your computer has a fingerprint reader) for the local profile. 176 | ``` 177 | COPY --chmod=0755 ./scripts/* /tmp/scripts/ 178 | RUN /tmp/scripts/config-users 179 | RUN /tmp/scripts/config-authselect && rm -r /tmp/scripts 180 | ``` 181 | ### Systemd services 182 | The first service completes the configuration during machine boot. These tasks can't be done while building the container as they require systemd to be running. 183 | 184 | It sets the hostname: 185 | ``` 186 | HOST_NAME=kde-bootc 187 | hostnamectl hostname $HOST_NAME 188 | ``` 189 | It creates the `systemd-homed` user `admin`: 190 | ``` 191 | homectl firstboot 192 | ``` 193 | And it sets up the firewall to allow kdeconnect to communicate: 194 | ``` 195 | firewall-cmd –set-default-zone=public 196 | firewall-cmd --add-service=kdeconnect –permanent 197 | ``` 198 | The systemd unit will be placed, and enabled by default: 199 | ``` 200 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__firstboot-setup.service /usr/lib/systemd/system/firstboot-setup.service 201 | RUN systemctl enable firstboot-setup.service 202 | ``` 203 | The second service automates updates, replacing the default `bootc-fetch-apply-updates` service, which would download and apply updates as soon as they are available. This approach is problematic because it causes your computer to shut down without warning, so it is better to disable by masking the timer: 204 | ``` 205 | RUN systemctl mask bootc-fetch-apply-updates.timer 206 | ``` 207 | The replacement `bootc-fetch` service will download the image from the registry and queue it for the next reboot. It is not enabled by default and can be turned on or off by the user as needed. 208 | ``` 209 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__bootc-fetch.service /usr/lib/systemd/system/bootc-fetch.service 210 | COPY --chmod=0644 ./systemd/usr__lib__systemd__system__bootc-fetch.timer /usr/lib/systemd/system/bootc-fetch.timer 211 | ``` 212 | The systemd service in charge to update the bootloader is enabled by default. It will be triggered at boot. 213 | ``` 214 | RUN systemctl enable bootloader-update.service 215 | ``` 216 | ### Clean and Checks 217 | This section focuses on cleaning the container before converting it into an image. The strategy includes using the latest `bootc container lint` option. 218 | ``` 219 | RUN find /var/log -type f ! -empty -delete 220 | RUN bootc container lint 221 | ``` 222 | ## How to create an ISO? 223 | Creating an ISO to install your *kde-bootc* desktop is simple. First, build the container image either on GitHub or locally. 224 | 225 | The instructions below will build the container locally, and ensure you do this as root so `bootc-image-builder` can use the image to make the ISO. 226 | ``` 227 | cd /path-to-your-repo 228 | sudo podman build -t kde-bootc . 229 | ``` 230 | Then, outside the repository on a different directory, create a folder named `output` for the ISO image. Next, create the configuration file `config.toml` to be used by the installer with the content below to kick off a graphical installation: 231 | ``` 232 | [customizations.installer.kickstart] 233 | contents = "graphical" 234 | 235 | [customizations.installer.modules] 236 | disable = [ 237 | "org.fedoraproject.Anaconda.Modules.Users" 238 | ] 239 | ``` 240 | If you prefer a non-interactive text installation, you may use the variation below: 241 | ``` 242 | [customizations.installer.kickstart] 243 | contents = """ 244 | text 245 | clearpart --all --initlabel --disklabel=gpt 246 | autopart --noswap 247 | """ 248 | 249 | [customizations.installer.modules] 250 | disable = [ 251 | "org.fedoraproject.Anaconda.Modules.Users" 252 | ] 253 | ``` 254 | The latter will setup systemd default target to `multi-user.target`, so you will need to run `systemctl set-default graphical.target` to boot into a graphical environment. 255 | In both configurations, the user module is disabled. We do not need to set up a user during installation, as this is already being taken care of. 256 | 257 | Within the directory where `./output/` and `./config.toml` exists, run `bootc-image-builder` utility which is available as a container. It must be ran as root. 258 | ``` 259 | sudo podman run --rm -it --privileged --pull=newer \ 260 | --security-opt label=type:unconfined_t \ 261 | -v ./output:/output \ 262 | -v /var/lib/containers/storage:/var/lib/containers/storage \ 263 | -v ./config.toml:/config.toml:ro \ 264 | quay.io/centos-bootc/bootc-image-builder:latest \ 265 | --type iso \ 266 | --chown 1000:1000 \ 267 | --rootfs btrfs \ 268 | --use-librepo=true \ 269 | localhost/kde-bootc 270 | ``` 271 | If everything goes well, the ISO image will be available in the `./output/` directory. 272 | 273 | For more information on `bootc-image-builder`, visit: https://github.com/osbuild/bootc-image-builder 274 | ## Post installation 275 | Once *kde-bootc* is installed, there are additional settings to improve usability. 276 | 277 | The first step is to restore the SELinux context for the `systemd-homed` home directory. Without this, you may not be able to log in as `admin`. To complete this task, log in as `root`, activate `admin` home area, and then run `restorecon` to restore the SELinux context. 278 | ``` 279 | homectl activate admin 280 | << enter password for admin: Temp#SsaP 281 | restorecon -R /home/admin 282 | homectl deactivate admin 283 | ``` 284 | At this point, you can change the passwords for `root` and `admin`: 285 | ``` 286 | passwd root 287 | homectl passwd admin 288 | ``` 289 | After completing these steps, you can log out from `root` and log in to `admin`. 290 | 291 | If your computer has a fingerprint reader, setting it up is not possible from Plasma's user settings, as `systemd-homed` is not yet recognised by the desktop. However, you can manually enrol your fingerprint by running `fprintd-enroll` and placing your finger on the reader as you normally would. 292 | ``` 293 | sudo fprintd-enroll admin 294 | ``` 295 | Same as above, you cannot set up the avatar from Plasma's user settings, but you can copy an available avatar (PNG file) from Plasma's avatar directory to the account service's directory. Ensure it is named the same as the username: 296 | ``` 297 | /usr/share/plasma/avatars/ -> /var/lib/AccountsService/icons/admin 298 | ``` 299 | Finally, enable the service to keep your system updated, and any other you may need: 300 | ``` 301 | systemctl enable --now bootc-fetch.timer 302 | systemctl enable --now tailscaled 303 | ``` 304 | To pull your image from a private GitHub repository using podman, copy `/usr/lib/ostree/auth.json` to `/home/admin/.config/containers/auth.json` for user space, and `/root/.config/containers/auth.json` for root. It will allow you to use `podman pull ..` and `sudo podman pull ..` respectively. 305 | ## Troubleshooting 306 | ### Drifts on `/etc` 307 | Please note that a configuration file in `/etc` drifts when it is modified locally. Consequently, bootc will no longer manage this file, and new releases won't be transferred to your installation. While this might be desired in some cases, it can also lead to issues. 308 | 309 | For instance, if `/etc/passwd` is locally modified, `uid` or `gid` allocations for services may not get updated, resulting in service failures. Also, if you have installed packages using `bootc usr-overlay`, it is advisable to remove them before unmounting `/usr` to ensure any configuration files in `/etc` are also removed. 310 | 311 | Use `ostree admin config-diff` to list the files in your local `/etc` that are no longer managed by bootc, because they are modified or added. 312 | 313 | If a particular configuration file needs to be managed by bootc, you can revert it by copying the version created by the container build from `/usr/etc` to `/etc`. 314 | ### Adding packages after first installation 315 | The `/var` directory is populated in the container image and transferred to your OS during initial installation. Subsequent updates to the container image will not affect `/var`. This is the expected behavior of bootc and generally works fine. However, some RPM packages execute scriptlets after installation, resulting in changes to `/var` that will not be transferred to your OS. 316 | 317 | Instead of trying to identify and update the missing bits in `/var`, I found it easier to overlay `/usr` and reinstall the packages after updating and rebooting bootc. 318 | ``` 319 | --> Add your packages to: usr__local__share__sigulete__packages-added, update bootc and reboot 320 | 321 | # Overlay /usr 322 | sudo bootc usr-overlay 323 | 324 | # Reinstall the package(s), so scriptlets can run and sort out /var 325 | sudo dnf reinstall 326 | 327 | # Remove /usr overlay 328 | sudo reboot 329 | ``` 330 | ### Wrong `owner` and `group` attributes in `/var` 331 | If `/etc/passwd` is managed by bootc while building the container image and hasn't been modified locally, the UID and GID allocations in `/etc/passwd` and `/etc/group` will inevitably change at some point. 332 | 333 | This is an issue for services that assign `user/group` ownership to files and directories in `/var`. The problem is that these files and directories will remain unchanged, and they won’t match the new UID and GID in `/etc/passwd` and `/etc/group`. As a result, it will cause the relevant services to stop working, so it needs to be addressed as it occurs. 334 | 335 | For example, the following instruction will update the ownership for the `pcp` (Performance Co-Pilot) package. This service generates files with the `owner:group` set to `pcp:pcp` under `/var/log/pcp` and `/var/lib/pcp`. When the `pcp` UID changes, their ownership must be updated accordingly. 336 | ``` 337 | sudo find /var/lib/pcp ! -user root ! -user pcp -exec chown pcp:pcp {} + 338 | sudo find /var/log/pcp ! -user root ! -user pcp -exec chown pcp:pcp {} + 339 | ``` 340 | --------------------------------------------------------------------------------