Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emad-elsaid/archlinux

Configuration DSL for Archlinux, similar to /etc/nixos/configuration.nix but uses your normal archlinux tools (pacman, systemd, gnu-utils) and doesn't do weird acrobat with stores and stuff
https://github.com/emad-elsaid/archlinux

archlinux linux nixos

Last synced: 3 months ago
JSON representation

Configuration DSL for Archlinux, similar to /etc/nixos/configuration.nix but uses your normal archlinux tools (pacman, systemd, gnu-utils) and doesn't do weird acrobat with stores and stuff

Awesome Lists containing this project

README

        

# Archlinux

[![Gem Version](https://badge.fury.io/rb/archlinux.svg)](https://badge.fury.io/rb/archlinux)

> [!WARNING]
> this can break your system, don't use it on your running system

A ruby API to manage the state of an Archlinux system.

* This project is early alpha
* It aims to have a DSL like NixOS for Archlinux
* It allow declaring the state of the system then it applies that to the current system
* The idea is to have simple and user friendly API to declare everything, system and user related

## Getting started

The project is a Ruby Gem. Create a ruby file and require the gem:

```ruby
require 'bundler/inline'

gemfile do
source "https://rubygems.org"

gem "archlinux", github: "emad-elsaid/archlinux"
end
```

Use `linux` function to define your system state, for example:

```ruby
linux do
hostname 'earth'

timedate timezone: 'Europe/Berlin',
ntp: true

locale "en_US.UTF-8"
keyboard keymap: 'us',
layout: "us,ara",
model: "",
variant: "",
options: "ctrl:nocaps,caps:lctrl,ctrl:swap_lalt_lctl,grp:alt_space_toggle"

package %w[
linux
linux-firmware
linux-headers
base
base-devel
bash-completion
pacman-contrib
docker
locate
syncthing
]

service %w[
docker
NetworkManager
]

timer 'plocate-updatedb'

user 'smith', groups: ['wheel', 'docker'] do
aur %w[
kernel-install-mkinitcpio
google-chrome
]

service %w[
ssh-agent
syncthing
]

copy './user/.config/.', '/home/smith/.config'
end

firewall :syncthing

on_finalize do
sudo 'bootctl install'
sudo 'reinstall-kernels'
end

file '/etc/X11/xorg.conf.d/40-touchpad.conf', <<~EOT
Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
Option "Tapping" "on"
Option "NaturalScrolling" "true"
EndSection
EOT

replace '/etc/mkinitcpio.conf', /^(.*)base udev(.*)$/, '\1systemd\2'
end
```

Now you can run the script with ruby as root:

```shell
sudo ruby
```

It will do the following:
- Install missing packages, remove any other package
- Make sure services and timers are running
- Do other configurations like locale, X11 keyboard settings, hostname
- Ensure users are created and in specified groups

# Concepts

## Declarations:

Functions the user will run to declare the state of the system like packages to
be present, files, services, user, group...etc

## Utilities:

Methods for logging and small predicates, technically any ruby method is a
utility. calling it executes the code directly instead of declaring a state.