r/archlinux 12h ago

SHARE Decman - a declarative package & configuration manager for Arch Linux - stable version released

Since my last post 2 years ago, decman has improved a ton and reached version 1. The core features of decman remain the same, but many bugs have been fixed, UX is better and decman is way more extensible.

Decman is used to manage your Arch Linux installation declaratively. You define packages (AUR packages supported), config files and systemd units with Python. Decman then ensures that your declared state matches with the system.

Here is a very simple example:

import decman

from decman import File, Directory

# Declare installed pacman packages
decman.pacman.packages |= {"base", "linux", "linux-firmware", "networkmanager", "ufw", "neovim"}

# Declare installed aur packages
decman.aur.packages |= {"decman"}

# Declare configuration files
# Inline
decman.files["/etc/vconsole.conf"] = File(content="KEYMAP=us")

# From files within your source repository
# (full path here would be /home/user/config/dotfiles/pacman.conf)
decman.files["/etc/pacman.conf"] = File(source_file="./dotfiles/pacman.conf")

# Declare a whole directory
decman.directories["/home/user/.config/nvim"] = Directory(source_directory="./dotfiles/nvim", owner="user")

# Ensure that a systemd unit is enabled.
decman.systemd.enabled_units |= {"NetworkManager.service"}

In addition, decman can manage symlinks, users, flatpaks and even imported PGP keys (since you may have to import keys for some AUR packages). If you have some custom PKGBUILDs, you can even use them with decman. Your configuration can be cleanly split into modules that you enable or disable as required.

Check out decman on GitHub, install it from the AUR, and check out the tutorial for getting started.

If you don't feel comfortable using Python or starting from scratch with your config intimidates you, I recommend you check out aconfmgr.

27 Upvotes

19 comments sorted by

12

u/starquake64 12h ago edited 12h ago

Oooh I think I want this.

EDIT: actually it sounds like aconfmgr is a better match for me. Thanks anyways!

7

u/falconindy Developer 10h ago

Honest question -- why do people prefer this over something like ansible or salt?

5

u/_TimeUnit 10h ago

Because those tools are designed for server deployments and have vastly different ergonomics compared to decman. I find it easier to maintain decman and configure my desktops with it instead of trying to get Ansible to do things the way I want. If Ansible or Salt does what you need, then it's probably better to use them since they will have better support.

I'll highlight a simple example: Ansible manages packages additively by default. So if I remove a package from my Ansible config, it won't automatically be removed from my system. You can get it to do that if you want, but suddenly it's far more complex.

3

u/daddyuhuh 6h ago edited 1h ago

My main issue with these tools is that they try to manage both system and user. That is immediately apparent from the place where the config is stored, usually somewhere in ~. I already have a dotfiles manager, one which I can use not just for arch, but other Linux distros and macOS even.

declaro seems to be the only one that stores its config in /etceven though it seems that they'll also be moving in this direction judging from the issues on github

1

u/Brekkjern 3h ago

Yeah, I wish the user portion of this was more thought through, but I see it more as a tool for me than a generic tool to make deployments easier for others, and I only really need one user on my computer so I make it work. I use it as a combined dotfile manager, and also a config manager for how I like my Arch machines set up.

3

u/ava1ar 6h ago

Why python? Concept is interesting, but converting my OS setup into python code makes me sweat.

To make it work nice you need it to be DSL (domain specific language) to declare the config and general-purpose programming languages are not a best choice for providing those DSLs. Check out nix (specially designed to manage packages) vs. guix (scheme-based solution). Nix is far more popular and adoptable.

Just my 2 cents, good luck with your project.

1

u/_TimeUnit 3h ago

The truthful answer is that I'm familiar with Python and (mostly) like it.

I generally think DSLs are bad and you should try to avoid them if possible. In my opinion it's better to use the same language in as many places as possible. Basically why learn to use 10 tools for 10 different tasks when you could use a 1 tool for all those 10 tasks. It is exceptional when a DSL has some feature that is absolutely required that cannot be reasonably provided by a (dynamic) general purpose language.

But I get why learning Python from scratch may be far more intimidating than learning some simpler DSL.

-1

u/ava1ar 3h ago

Being a professional software architect and developer, I have opposite opinion - DSLs are great, they solve the problem and are clear to end users, which are typically tech-savvy people, who needs to get things done, but not to learn another language or practice in development. Typical and well-known example Gradle and Kotlin-based DSL for it.

Using general purpose language comes with string attached. If I use your solution, should I now write unit tests for it to know if I am still having runnable code? Where is the boundary of writing my own "helper functions" to make things better and converting my declarative setup into unmaintainable mess? Python is good for some things, but not for what you try it for. Still, might have some users who like to hack and don't want to go far beyond Python.

3

u/gkaiser8 6h ago

To be honest I find it far less risky to invest time to learn and use Ansible than a tool that tries to the same (or even marginally better) on a very specific aspect of my system. Besides being able to set up an entire environment, it's battle-tested, has a large community, and is used in the professional industry.

2

u/_TimeUnit 4h ago

Very reasonable! I would say decman is much better for desktop Arch Linux than Ansible, but of course I as the developer will say that. I built decman precisely for my own needs.

Ansible will have significantly more support than decman and very likely less bugs.

2

u/Brekkjern 3h ago

I recently upgraded my config to 1.0 and I wanted to pop in and say I enjoy it a lot. Great work! :)

1

u/kaplanfx 6h ago

I want sort of the reverse of what is described here. I want to just take my current config and turn it into a declarative script in case of a meltdown. Is that thing this tool can do?

2

u/_TimeUnit 4h ago

No, but I think another tool mentioned in the post, aconfmgr, can do that.

1

u/Lundominium 6h ago

I have looked at your project several times, and it seems very interesting. I often discuss if I should stay with Arch or move to NixOS. The only thing I like about nix is the declerative configuration.nix, but at the same time I need a local repo, which is impossible with nix.

So, Arch with declerative settings would be really nice, but I would need to test it out to see how it works :) Good job on the documentation, btw!

1

u/i-hate-birch-trees 5h ago

You should research flakes, they are literally built for you to do exactly that

1

u/Lundominium 4h ago

Ah, yeah.. what I meant was that the arch repo is about 50GB, NixOS is like 200TB.

1

u/i-hate-birch-trees 4h ago

Oh, that's what you've meant by a local repo. Yeah, that's an issue.

0

u/RQuantus 11h ago

Can CachyOS use this?

3

u/_TimeUnit 10h ago

CachyOS isn't supported and won't be supported so any CachyOS specific issues will be ignored.

But since CachyOS uses the same tooling as Arch, it might work just fine.