☄️ Config Curator
CLI tool for installing static configuration or dotfiles.
Description
- 🦉 Idempotent: syncs directories, copies files,
creates system links, deletes paths, and sets access permissions to ensure
the system will be in a consistent state after each run.
- 🐬 Declarative: all operations are defined
in a manifest file with a simple syntax.
- 🐍 Flexible: operations may be limited only to specific hosts
or only when specific packages are installed,
additionally, since the manifest is written in JavaScript,
it may include arbitrary logic.
- 🐹 Minimal: written in < 500 lines of code
using only the Node.js standard library and a few system calls.
- 🐡 Secure: no additional third party dependencies (except
rsync
):
safe to run with sudo
to install system files. - 🦅 Fast: uses maximal concurrency
and allows custom ordering of groups of operations.
Try it out
- Clone this repo.
- Run
npm install
. - Run
npm test
:
This will install the configuration
defined in test/manifest.js
to test/dest
.
Requirements
- Linux or macOS with rsync installed.
- Node.js version 8 or above.
- For conditional configuration based on installed packages,
the following package managers are supported:
Pacman, Homebrew, dpkg, or pkgng.
Installation
-
Add this as a development dependency to your project using npm with
$ npm install --save-dev config-curator
-
Add a script to your package.json
with "curator": "curator"
so you may run this with
$ npm run curator
Usage
Create a manifest.js
file to define the configuration
and run the curator
command to install the configuration.
- The manifest configuration is defined below.
Copy the example manifest from
manifest.example.js
. - The manifest should be the default export and may be an object, function,
promise, or async function.
- The location of the manifest file may be passed as the first argument,
otherwise it looks for
manifest.js
in the current working directory. - The environment variables
CURATOR_IO
and CURATOR_PKG
may be set
to override the ioType
and pkgType
values from the manifest.
Manifest
Minimal example
import os from 'os'
const targetRoot = os.homedir()
const unlinks = [
{
src: 'old.conf'
}
]
const directories = [
{
src: '.config/envs'
},
{
src: 'vim',
dst: '.vim'
},
{
src: 'private',
dmode: '0700',
fmode: '0600',
user: 'root',
group: 'wheel'
}
]
const files = [
{
src: '.zshrc'
},
{
src: `keys/${os.hostname()}`,
dst: '.ssh/id_rsa',
fmode: '0600',
pkgs: ['openssh']
}
]
const symlinks = [
{
src: '.config/env.conf',
dst: '.config/envs.${os.hostname()}.conf',
hosts: ['alpha', 'delta']
}
]
export default {
targetRoot,
unlinks,
directories,
files,
symlinks
}
Complete manifest API
import os from 'os'
const originRoot = os.homedir()
const targetRoot = os.homedir()
const pkgType = 'homebrew'
const ioType = 'macos'
const defaults = {
order: 100,
dmode: '0750',
fmode: '0640',
user: process.getuid(),
group: process.getgid()
}
const unlinks = [
{
src: 'intruders'
},
{
src: 'warpcore',
hosts: ['enterprise'],
pkgs: ['eject']
}
]
const directories = [
{
src: 'holodeck'
},
{
src: 'panels/exploding',
dst: 'bridge/panels',
user: 'numberone',
group: 'officers',
dmode: '0755',
fmode: '0644',
hosts: ['enterprise', 'defiant'],
pkgs: ['turbolift', 'transporter']
},
{
src: 'decks/sickbay',
dst: 'sickbay',
order: 10
},
{
src: 'beds',
dst: 'sickbay/beds',
order: 11
},
{
src: 'meds',
dst: 'sickbay/meds',
order: 11
}
]
const files = [
{
src: 'bay/torpedo'
},
{
src: 'phaser',
dst: 'brig/phaser',
user: 'warf',
group: 'security',
fmode: '0600',
hosts: ['defiant'],
pkgs: ['stun']
}
]
const symlinks = [
{
src: 'drink',
dst: 'tea/earlgray/hot'
},
{
src: 'hypospray',
dst: 'hyposprays/norepinephrine',
hosts: ['enterprise'],
pkgs: ['sickbay']
}
]
export default {
unlinks,
directories,
files,
symlinks,
originRoot,
targetRoot,
ioType,
pkgType,
defaults
}
Similar Software
This is the successor to my original configuration tool written in Ruby:
https://github.com/razor-x/config_curator.
GitHub maintains an unofficial guide to dotfiles: https://dotfiles.github.io/.
Users
If you are using Config Curator, add a link here and open a pull request.
Contributing
Please submit and comment on bug reports and feature requests.
To submit a patch:
- Fork it (https://github.com/razor-x/config-curator/fork).
- Create your feature branch (
git checkout -b my-new-feature
). - Make changes.
- Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create a new Pull Request.
License
This npm package is licensed under the MIT license.
Warranty
This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright holder or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and on
any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.