Add symlink support

This commit is contained in:
Kivi Kaitaniemi
2026-01-07 00:52:18 +02:00
parent 8ca2ca8a06
commit 360e0fcf9e
8 changed files with 286 additions and 4 deletions
+26 -1
View File
@@ -129,7 +129,9 @@ decman.config.arch = "x86_64"
## Files and directories
Decman functions as a dotfile manager. It will install the defined files and directories to their destinations. You can set file permissions, owners as well as define variables that will be substituted in the installed files. Decman keeps track of all files it creates and when a file is no longer present in your source, it will be also removed from its destination. This helps with keeping your system clean. However, decman won't remove directories as they might contain files that weren't created by decman.
Decman functions as a dotfile manager. It will install the defined files, directories and symlinks to their destinations. You can set file permissions, owners as well as define variables that will be substituted in the installed files. Decman keeps track of all files it creates and when a file is no longer present in your source, it will be also removed from its destination. This helps with keeping your system clean. However, decman won't remove directories as they might contain files that weren't created by decman.
Symlinks management is simpler and more limited than for files since symlinks cannot have file permissions or ownership.
Variables can only be defined for files within modules. See the module example for using file variables.
@@ -204,6 +206,18 @@ Ownership, permissions, and parent directories are enforced on creation. Missing
- `group: str`: System group name to own the files and directories. By default the `owner`'s group is used.
- `permissions: int`: File mode applied to the created or updated files (e.g. `0o644`).
### Symlink
Declare a link to a target. Missing directories are created.
```py
import decman
# Replaces sudo with doas
# /usr/bin/sudo -> /usr/bin/doas
decman.symlinks["/usr/bin/sudo"] = "/usr/bin/doas"
```
## Modules
Modules allow grouping related functionality together.
@@ -332,6 +346,17 @@ def file_variables(self) -> dict[str, str]:
}
```
#### Symlinks
Defines symlinks fro the module.
```py
def symlinks(self) -> dict[str, str]:
return {
"/etc/resolv.conf": "/run/systemd/resolve/resolv.conf",
}
```
### Extending with plugins
To include plugin functionality inside a module, create a new method and mark it with the plugin's decorator. During the execution of decman, the plugin will call the marked method and use its result. Here is an example with the pacman plugin.