A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow.
Find a file
Christina Sørensen 6b317ee6af refactor(link): add LinkError and use for handle_file_exists
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2023-10-17 05:09:30 +00:00
.github/workflows ci: borrow ci setup from eza 2023-08-09 14:40:17 +00:00
benches build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
bin feat(git): made SUCCESS/FAILURE emoji const 2023-07-03 11:34:22 +02:00
doc chore: name project seidr 2023-08-09 16:27:56 +02:00
src refactor(link): add LinkError and use for handle_file_exists 2023-10-17 05:09:30 +00:00
tests chore: name project seidr 2023-08-09 16:27:56 +02:00
.envrc build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
.gitignore build(git): add .direnv to gitignore 2023-10-06 16:54:08 +02:00
Cargo.lock chore: name project seidr 2023-08-09 16:27:56 +02:00
Cargo.toml build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
CHANGELOG.md chore(version): bump to v0.2.0 2023-07-07 04:13:59 +00:00
cliff.toml doc(git-cliff): added git cliff config 2023-07-02 10:45:39 +02:00
CODE_OF_CONDUCT.md chore: fix code of conduct 2023-08-09 16:44:09 +02:00
flake.lock build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
flake.nix build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
flake.nix.old build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
LICENSE initial commit 2023-06-08 18:50:09 +02:00
README.md docs: remove outdated gif, make readme cool 2023-10-06 13:54:19 +00:00
rust-toolchain.toml build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00
treefmt.nix build(nix): do crane EZA style 2023-10-06 16:16:56 +02:00

SEIÐR

seidr

An experimental Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow.

Built with Nix Contributor Covenant Unit tests Crates.io Crates.io

Warning

Seiðr is experimental. I'm gonna change how links work soon. Every update might mean rewriting your config. You're warned.

A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. Useful for dealing with "dotfiles", and with git support as a first class feature. Configuration is done through a single yaml file, giving it a paradigm that should bring joy to those that use declarative operating systems and package managers.

Although this isn't really a case where it matters that much for performance, being written in rust instead of e.g. /janky/ scripting languages does also mean it is snappy and reliable, and the /extensive/ (hardly, but eventually) testing helps ensure regressions aren't introduced.

That said, we're in 0.Y.Z, here be dragons for now (although a little less each commit).

Installation

git clone https://github.com/cafkafk/seidr
cd seidr
cargo install --path .

Configuration

If you want a template, you can copy the file from src/test/config.yaml:

mkdir -p ~/.config/seidr/
cp src/test/config.yaml ~/.config/seidr/config.yaml

You should seriously change this file before running any commands.

The configuration format will likely break regularly in versions 0.Y.Z.

Dhall

I already daily drive seidr, and here's an example of how I keep it manageable with dhall. Writing the .yaml files by hand and keeping them up to date quickly felt like writing aterm .drv files for Nix by hand... that is to say not pleasant. This somewhat makes it better.

let {- First, we define some useful variables
    -}
    home
    : Text
    = "/home/ces/"

let config
    : Text
    = "${home}/.config/"

let gitProjectsDir
    : Text
    = "${home}/org/src/git/"

let nixosConfigName
    : Text
    = "afk-nixos"

let nixosConfigDir
    : Text
    = gitProjectsDir

let nixosConfigPath
    : Text
    = "${home}/org/src/git/${nixosConfigName}/"

let seidrConfigPath
    : Text
    = "${nixosConfigPath}/seidr/"

let {- Now, we create some schemes and types and such to make our lives easier

       TODO: We could totally also write some functions, but I haven't gotten to that yet.
    -}
    Flags
    : Type
    = < Clone | Fast >

let Repo
    : Type
    = { name : Optional Text
      , path : Optional Text
      , url : Optional Text
      , kind : Optional Text
      , flags : Optional (List Flags)
      }

let Link
    : Type
    = { name : Optional Text, rx : Text, tx : Text }

let {- Here, we define our repositories
    -}
    nixosConfigRepo
    : Repo
    = { name = Some nixosConfigName
      , path = Some nixosConfigDir
      , url = Some "git@github.com:cafkafk/afk-nixos.git"
      , kind = Some "GitRepo"
      , flags = Some [ Flags.Clone, Flags.Fast ]
      }

let ezaDevelopmentRepo
    : Repo
    = { name = Some "eza"
      , path = Some gitProjectsDir
      , url = Some "git@github.com:eza-community/eza.git"
      , kind = Some "GitRepo"
      , flags = Some [ Flags.Clone, Flags.Fast ]
      }

let {- Here, we define our repositories
    -}
    starship
    : Link
    = { name = Some "starship"
      , tx = "${seidrConfigPath}/starship.toml"
      , rx = "${config}/starship.toml"
      }

let {- And now we pull it all together -}
    categories =
      { seidr.repos
        =
        { -- dots = { name = "seidr", path = path },
          nixosConfigRepo
        , ezaDevelopmentRepo
        }
      , starship.links.starship = starship
      }

in  { categories }

Then it's as easy as running something like this:

dhall-to-yaml --file seidr.dhall --explain --output seidr.yaml
seidr -c seidr.yaml --help

Ofc, you replace --help with whatever you wanna do here.