Update README.md & examples

This commit is contained in:
Kivi Kaitaniemi
2025-03-08 19:07:04 +02:00
parent 23620e86f5
commit 47ea816d3f
3 changed files with 39 additions and 14 deletions
+22 -5
View File
@@ -1,5 +1,15 @@
# Decman
> 🎉 Decman now has a AUR package! 🎉
>
> To start using the AUR package simply add `decman` to `decman.aur_packages`. To ensure a smooth change, add decman-git to ignored_packages during the conversion.
>
> ```py
> import decman
> decman.aur_packages += ["decman"]
> decman.ignored_packages += ["decman-git"]
> ```
Decman is a declarative package & configuration manager for Arch Linux. It allows you to manage installed packages, your dotfiles, enabled systemd units, and run commands automatically. Your system is configured using python so your configuration can be very adaptive.
If you want, you can also use decman with other configuration languages. See the [example with TOML later in this README](#decman-with-other-configuration-languages).
@@ -111,17 +121,22 @@ decman --help
Clone the decman PKGBUILD:
```sh
git clone https://github.com/kiviktnm/decman-pkgbuild.git
git clone https://aur.archlinux.org/decman.git
```
Review the PKGBUILD and install it.
```sh
cd decman-pkgbuild
cd decman
makepkg -si
```
So far I have not created an AUR package for decman, because I'm not sure if other people would find decman useful.
Remember to add decman to its own configuration.
```py
import decman
decman.aur_packages += ["decman"]
```
## What decman manages?
@@ -145,10 +160,11 @@ Decman can install AUR packages as well as user defined packages. Foreign packag
Here is an example of a user package. Managing user packages is somewhat cumbersome as you have to declare their versions, dependencies and make dependencies manually. However, you probably won't install many user packages anyway.
```py
# Note, decman now has a aur package, I recommend using that instead.
# Also, this example may be out of date
decman.user_packages.append(
decman.UserPackage(
pkgname="decman-git",
# Note, this example may not be up to date
provides=["decman"],
version="0.3.3",
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
@@ -278,8 +294,9 @@ aur_packages = ["protonvpn"]
enabled_systemd_units = ["NetworkManager.service"]
ignored_packages = ["yay"]
user_packages = [{
# Note, decman now has a aur package, I recommend using that instead.
# Also, this example may be out of date
pkgname="decman-git",
# Note, this example may not be up to date
provides=["decman"],
version="0.3.3",
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
+13 -7
View File
@@ -4,7 +4,6 @@ from decman import Module, File, Directory, UserPackage, sh, prg
class MyModule(Module):
def __init__(self):
self.pkgs = ["rust"]
self.update_rustup = False
@@ -28,6 +27,8 @@ class MyModule(Module):
# or run a program with arguments.
prg(["usermod", "--append", "--groups", "mygroup", "kk"])
# NOTE! Removing a enabled module from decman.module means that on_disable will not run.
# Instead disable the module.
def on_disable(self):
# You can run commands as any user
sh("whoami", user="kk")
@@ -58,18 +59,21 @@ class MyModule(Module):
def files(self) -> dict[str, File]:
# Variables are substituted in text files automatically.
return {
"/usr/local/bin/say-hello":
File(content="#!/usr/bin/env bash\necho %msg%", permissions=0o755),
"/usr/local/bin/say-hello": File(
content="#!/usr/bin/env bash\necho %msg%", permissions=0o755
),
# Variables are not substituted in binary files.
"/usr/local/share/say-hello/image.png":
File(source_file="files/i-dont-exist.png", bin_file=True),
"/usr/local/share/say-hello/image.png": File(
source_file="files/i-dont-exist.png", bin_file=True
),
}
def directories(self) -> dict[str, Directory]:
# Directories are handeled the same way. Variables are substituted in text files.
return {
"/home/kk/.config/mod-app/":
Directory(source_directory="files/app-config", owner="kk")
"/home/kk/.config/mod-app/": Directory(
source_directory="files/app-config", owner="kk"
)
}
# Packages and systemd units are basically the same with modules as without modules.
@@ -79,6 +83,8 @@ class MyModule(Module):
return self.pkgs
def user_packages(self) -> list[UserPackage]:
# Note, decman now has a aur package, I recommend using that instead.
# Also, this example may be out of date
return [
UserPackage(
pkgname="decman-git",
+4 -2
View File
@@ -26,7 +26,7 @@ decman.packages += ["python", "python", "devtools", "git", "networkmanager"]
decman.ignored_packages += ["rustup", "yay"]
# Installing AUR packages is easy.
decman.aur_packages += ["protonvpn"]
decman.aur_packages += ["decman", "protonvpn"]
# To import GPG keys, set the GNUPGHOME environment variable.
# It can easily be done with python as well.
@@ -36,7 +36,9 @@ decman.config.makepkg_user = "kk"
# You can also install packages from anywhere, but then you must include some
# information about the package. The git_url is the url to the PKGBUILD,
# This example may not be up to date, but you should keep these up to date with the PKGBUILD.
#
# Note, decman now has a aur package, I recommend using that instead.
# Also, this example may be out of date
decman.user_packages.append(
UserPackage(
pkgname="decman-git",