Configma is a powerful yet incredibly simple and efficient config files manager. Main focus is on simplicity, reliability, and ease of use.
-
User-Friendly and Minimalistic: Configma is built with simplicity in mind. Its minimalistic design makes it easy to use, even for beginners.
-
Easy Git Integration: Configma can be easily used with git for even more convinience.
-
Small codebase: There is very little code in this project. Managing config files in a very complex way seems like an overkill. But manually managing them is a pain. So configma provides a nice middleground.
-
Configma add: Adding files or directories to Configma is a breeze with
configma add <file / dir>
, which moves the specified file or directory into the repository directory mentioned in the Configma config file and symlinks it to the original location. The tool doesn't rely on a separate database; instead, it cleverly uses the files and directories in the repository to symlink them at the correct locations. -
Directory stub files: Configma uses a '.configma.stub' file placed within symlinked directories to differentiate directories added to Configma from individual files. Using this approach, Configma avoids the need for a separate database, maintaining its lightweight design.
-
Configma remove: Removing files from Configma is just as straightforward with
configma remove <path>
. Whether the path points to a file within your configs or the repository, Configma handles it correctly. This command restores the files/directories from the repository to their original places in your system, making management effortless. -
Modules: A Module is set of files that can be overriden by modules with higher precedence. simply mentioning a module after another in config.toml gives the later module higher precedence.
configma sync
will figure out what files need to be synced and generate the correct symlinks for you. -
Profiles: Profiles enable users to consolidate config files from various systems into a single repository. A Profile is just a collection of multiple modules. The currently applied profile data is stored in the '~/.config/configma/profile.active.toml' file, allowing users to seamlessly switch between profiles on each system using the
configma switch-profile <name>
command. -
Force sync: Worried about data loss? The -f flag enables you to force sync or apply a config profile, moving your current configs to a temporary directory to safeguard against accidents.
~/.config/configma/config.toml
# this is treated as the default source of modules unless specified
# i recommend using a separate directory for configma modules in your dotfiles repo
repo = "~/.dotfiles/configma"
# These are profiles. very handy if you have multiple devices, or if you like to rice your system
# switching profiles will allow you to quickly switch your rice configurations
[[profiles]]
name = "my-laptop"
# modules specified later have higher precedence.
# modules with higher precedence will override files from other modules in case of a conflict
# NOTE: you need to at least create a directory for each module specified here.
# configma will complain if it does not find any of the mentioned modules
# for example, here you need to create the directory '~/.dotfiles/configma/env'. after this,
# you can just use configma cli commands.
modules = [
"env",
"private-env",
"tools",
]
# your desktop may use different modules than your laptop. so you can simply create a separate
# profile for your desktop.
# here, 'games' module may contain any configuration needed for game runners or even game savefiles.
[[profiles]]
name = "my-desktop"
modules = [
"env",
"private-env",
"env-desktop",
"tools",
"games",
]
# this is an example of a module from a source outside your dotfiles repo
# this is useful in cases where you don't want to upload your private secrets to github.
# module sources do not need to be a git repo.
# NOTE: `path` points to the directory parent to your module.
# In this case configma will look for '~/.dotfiles-private/configma/env-private'
[[modules]]
name = "env-private"
path = "~/.dotfiles-private/configma"
Clone this repository, navigate to the Configma directory and Install Configma using Cargo.
git clone https://github.com/thrombe/configma
cd configma
cargo install --path .
Try it out
nix run github:thrombe/configma
Else add the following to your nix flake
{
inputs = {
...
# define flake input
configma.url = "github:thrombe/configma";
};
...
# then add it to your environment packages
packages = [
inputs.configma.packages."${system}".default
];
...
}
Set up a new profile by creating the Configma configuration file.
mkdir -p ~/.config/configma
echo 'repo = "<path>"' > ~/.config/configma/config.toml
configma new-profile <profile name>
configma switch-profile <profile name>
the repo path is any directory where you would like configma to store your config files in.
configma switch-profile <profile name>
configma add <path>
Whether the path points to a file within your configs or the repository, Configma handles it correctly. This command restores the files/directories from the repository to their original places in your system.
configma remove <path>
Sync any changes made in the repo to the system.
configma sync
- template system
- file names like
configma.toml:my-tag
- templates have something like
^!{my-tag}
which get replaced with the contents of that file
- file names like
- fzf interface for choosing profiles
- Simlinks to dirs are followed when moving stuff to the repo. instead they should just be copied
- fs_extra::dir::copy has this behavior
- Add a set-repo subcommand (with -f) that sets the repo path in configma/config.toml
- keep logs of everything done by configma