Automatic syncing of desktop files to git
 
 
 
Go to file
Joshua Potter f1df43b457
Update README.md
2023-11-26 16:45:25 -07:00
.githooks Update readme and prehook. 2022-01-12 06:02:49 -05:00
rsrc Allow ignoring certain files from being managed in the git repository. (#3) 2022-03-05 19:36:02 -05:00
src Allow ignoring certain files from being managed in the git repository. (#3) 2022-03-05 19:36:02 -05:00
.envrc Basic project template. 2021-12-28 17:06:17 -05:00
.gitignore Installation instructions. 2022-01-09 10:01:26 -05:00
.homesync.yml Add tests to `path` and `copy` modules. 2022-01-09 07:13:30 -05:00
Cargo.nix Setup flake to produce project. 2022-01-09 09:39:31 -05:00
Cargo.toml Add LICENSE. 2022-02-15 07:13:54 -05:00
LICENSE Add LICENSE. 2022-02-15 07:13:54 -05:00
README.md Update README.md 2023-11-26 16:45:25 -07:00
default.nix Add flake-compat. 2022-03-23 12:22:49 -04:00
flake.lock Add flake-compat. 2022-03-23 12:22:49 -04:00
flake.nix Add flake-compat. 2022-03-23 12:22:49 -04:00

README.md

homesync

Caution! This was an experimental project

This project was an exploration in the Rust language, which I do not plan on exploring any further. I do want to rewrite this tool properly (in C) at a later date, but I have no definitive timeline on when I'll start.

Introduction

Homesync provides a way of automatically syncing files across your desktop to a git repository. By registering files with homesync, upstream and downstream syncing can be done as requested, without any manual need to twiddle files and copy them into a local git repository. Separately, a daemon service exists that watches for changes as they happen.

Installation

Currently nix is the only distribution channel available. You can run directly from the shell like so:

$ nix shell github:jrpotter/homesync/main

Likewise, you can install the binary using home-manager:

{
  inputs = {
    homesync.url = "github:jrpotter/homesync/main";
  };

  # ...

  configuration = { ... }: {
    home.packages = [
      homesync.defaultPackage.${system}
    ];
  };
}

Lastly, you can always just build from source:

$ git clone https://github.com/jrpotter/homesync.git
$ cd homesync
$ cargo build --release

Configuration

Homesync uses a YAML file, to be found in anyone of the following locations. Locations are searched in the following priority:

  • $HOME/.homesync.yml
  • $HOME/.config/homesync/homesync.yml
  • $XDG_CONFIG_HOME/homesync.yml
  • $XDG_CONFIG_HOME/homesync/homesync.yml

The config file should look like the following:

---
user:
  name: name
  email: email@email.com
ssh:
  public: $HOME/.ssh/id_ed25519.pub
  private: $HOME/.ssh/id_ed25519
repos:
  local: $HOME/.homesync
  remote:
    name: origin
    branch: master
    url: "https://github.com/owner/repo.git"
unmanaged:
  - LICENSE
  - README.md
packages:
  homesync:
    - $HOME/.homesync.yml
    - $HOME/.config/homesync/homesync.yml
    - $XDG_CONFIG_HOME/homesync.yml
    - $XDG_CONFIG_HOME/homesync/homesync.yml

Copy over examples/template.yaml to where you'd like as a starting point.

Usage

Verify your installation by running homesync from the command line. To have your local repository match the remote, run

$ homesync pull

If you make a change to a configuration tracked by homesync, you can tell homesync to prep pushing those changes via the stage subcommand or rely on the daemon service to do it for you:

$ homesync stage
$ homesync daemon &

Homesync will find all tracked files that have changed and stage them in the local repository. You can then push those changes using

$ homesync push

If looking to copy a configuration tracked by homesync to your desktop, you can run either:

$ homesync apply <PACKAGE>
$ homesync apply --all

The latter command overwrites all configuration files in favor of those found in the local repository.

Known Issues

If using (neo)vim, the daemon watcher will stop watching a given configuration file after editing. Refer to this issue for more details. As a workaround, you can set the following in your init.vim file:

backupcopy=yes

Refer to :h backupcopy for details on how this works.

Contribution

To get started, we recommend reviewing the documentation:

cargo doc --open

Install git hooks as follows:

git config --local core.hooksPath .githooks/