# Inside RLXOS 2.0 Source Code - Part 1

Hey there, tech enthusiasts! Today, we're taking a fun dive into the source code of RLXOS and building one from source.

Hold on a sec, ever heard of RLXOS? It's not just your average operating system – it's an open-source, independent, and <s>immutable</s> securely mutable distribution. Picture this: it's like taking the best parts of Android security and workflow and bringing them to your desktop. Cool, right? (Also keep in mind that RLXOS is newer Linux distribution and can lack features and occasional instability)

If you're curious, you can dive into RLXOS 2.0 and explore all its features right here. It's a neat way to learn about building and tinkering with operating systems. Visit the [Project website](https://rlxos.dev) to learn more about the project and take a test drive of it.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1715097500792/370b1da6-bef3-4054-b502-c7147529b4d1.png align="center")

## Hardware Requirements

Building RLXOS doesn't demand a high-end system. But you'll need at least 100 GiB of storage space, a x86\_64 multi-core system, and a minimum of 8 GiB of memory (consider adding swap space if you plan to build LLVM and Webkitgtk-like tools). In essence, you can compile RLXOS on your laptop overnight.

Compilation times vary depending on your system configuration, ranging from 2 days to 6 hours. For instance, it took me 52 hours to compile RLXOS from source on the lowest configuration [Contabo Cloud VPS 1](https://contabo.com/en/vps/cloud-vps-1/?image=ubuntu.267&qty=1&contract=1&storage-type=vps-1-400-gb), and nearly 6 hours on [Contabo Intel 10-Core](https://contabo.com/en/dedicated-servers/intel-10-core/?image=ubuntu.267&ds-storage=1592.1._.P&qty=1&contract=1).

## Software Requirements

To successfully compile RLXOS, ensure you have a native Linux system installed. Additionally, install the following tools and libraries:

* GNU C++20 compiler
    
* libostree
    
* bwrap
    
* bsdtar or libarchive-tools
    

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">RLXOS utilizes a temporary lightweight bwrap container to isolate the build process of each component from the system, ensuring no alterations are made to your system in any way.</div>
</div>

## Obtaining Source Code

Simply fork my GitHub repository at [https://github.com/itsManjeet/rlxos/](https://github.com/itsManjeet/rlxos/) containing the meta-configuration files for building RLXOS. Your star would be much appreciated to support my work.

If you're not on GitHub, clone the project using:

```bash
git clone --recurse-submodules --branch stable https://github.com/itsManjeet/rlxos
```

## Project Structure

| File/Folder | Description |
| --- | --- |
| elements/ | YAML configuration files for each component |
| files/ | Files required by one or more components to build, such as icons, service files, background wallpaper, or logos. |
| patches/ | Patch files used for fixes or customization of each component. |
| scripts/ | Scripts utilized in CI/CD pipelines. |
| config-&lt;ARCH&gt;.yml | Project configuration file used by Ignite to set up environment variables, provide global variables, and compiler information. |
| include/ | Shared configurations imported in config-&lt;ARCH&gt;.yml |

## Ignite! the build process🔥

Now that we have the source code, let's build our first RLXOS distribution. You'll understand why I call it Ignite! the build process later.

Firstly, create your own GPG key to sign the updates

Begin by removing the default rlxos.gpg key:

```bash
rm -v files/rlxos.gpg
```

Then generate a new one:

```bash
make file/rlxos.gpg
```

This action will create a public key at `files/rlxos.gpg` and a private key at `ostree-gpg/`. The private key is utilized to sign the OTA updates, while the public key is provided to users within the release ISO to verify OTA updates.

Execute:

```bash
make ELEMENT=installer/image.yml
```

Now, sit back and watch HIMYM to know how Ted meets his children's mother. Yes, it may take that long (unless you're Barney with NASA's hardware).

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Please raise the <a target="_blank" rel="noopener noreferrer nofollow" href="https://github.com/itsManjeet/rlxos/issues/new?assignees=itsManjeet&amp;labels=ignition-failed&amp;projects=&amp;template=ignite-failed--.md&amp;title=Ignition+failed%21" style="pointer-events: none">GitHub Issue</a> with the error message along with system configuration if the process failed.</div>
</div>

## Testing the output

Once the build process concludes, check out the artifact by executing:

```bash
make checkout ELEMENT=installer/image.yml DESTDIR=out
```

This will check out the installer/image.yml component inside the out directory (essentially the ISO file).

```bash
out
├── rlxos-stable-installer.iso
└── rlxos-stable-installer.iso.sha265sum

0 directories, 2 files
```

You can use any other virtual machine or even real hardware to test the built ISO.

I prefer to use QEMU with KVM for nearly native-like performance. First, create a hard disk image by:

```bash
qemu-img create -f qcow2 disk.img 16G
```

This will create a dynamically allocated 16G disk image where you can virtually install RLXOS without impacting your system..

Now, execute the command to boot into the RLXOS ISO:

```bash
qemu-system-x86_64 -cdrom out/rlxos-stable-installer.iso \
    -m 2G -smp 2 -enable-kvm -cpu host \
    -soundhw hda -vga virtio \
    -drive "file=disk.img,format=qcow2"
```

| Option | Description |
| --- | --- |
| \-cdrom &lt;ISO&gt; | Specify the ISO file in this case path to our generated ISO. |
| \-m 2G | 2GiB Size of virtual memory allocated to virtual machine, Like RAM in hardware |
| \-smp 2 | Number of CPU allocated to the machine |
| \-enable-kvm | Use Kernel virtual machine extension of Linux kernel to enhance performance. |
| \-cpu host | Use CPU instruction similar to host CPU |
| \-soundhw hda | Specify sound hardware |
| \-drive "file=.." | Specify the storage drive in this case our generated disk.img. |

I reckon that's sufficient for this part. You now have the RLXOS source code and know how to build and test it. You're all set to explore the project source code and various files.

In the upcoming parts, I'll delve into:

* Setting up update mechanisms and managing different update channels
    
* Establishing CI/CD Pipelines for continuous deployment
    
* Contributing to the project
    
* Customizing components, theming, and creating your own custom RLXOS distribution
    
* Adding support for other Desktop Environments
    
* Writing element files and porting packages to RLXOS
    
* Or we can delve deeper into the build process
    

Until then, please like the post, follow the blog, and star my GitHub repository. Your support keeps me motivated. Feel free to leave a comment if you encounter any doubts or hurdles. 🌟
