]> git.scottworley.com Git - syncthing-autoregister/blame_incremental - README
Verify files sync after "nixos-rebuild switch"
[syncthing-autoregister] / README
... / ...
CommitLineData
1# syncthing-set-id
2
3Modify in-place a nix module that configures syncthing device ids. This file can used as a normal `include` in nixos configs. This eliminates the need to copy-paste these device IDs around.
4
5### Example
6
7 desktop$ syncthing-set-id syncthing-devices.nix
8 Creating /home/user/myNixOSConfigs/syncthing-devices.nix
9
10 desktop$ cat syncthing-devices.nix
11 {
12 "services" = {
13 "syncthing" = {
14 "declarative" = {
15 "devices" = {
16 "desktop" = {
17 "id" =
18 "1234567-89ABCDE-FGHIJKL-MNOPQRS-TUVWXYZ-0123456-789ABCD-EFGHIJK";
19 };
20 };
21 };
22 };
23 };
24 }
25
26Then, later, on another machine:
27
28 laptop$ syncthing-set-id syncthing-devices.nix
29
30 laptop$ cat syncthing-devices.nix
31 {
32 "services" = {
33 "syncthing" = {
34 "declarative" = {
35 "devices" = {
36 "desktop" = {
37 "id" =
38 "1234567-89ABCDE-FGHIJKL-MNOPQRS-TUVWXYZ-0123456-789ABCD-EFGHIJK";
39 };
40 "laptop" = {
41 "id" =
42 "1111111-2222222-3333333-4444444-5555555-6666666-7777777-8888888";
43 };
44 };
45 };
46 };
47 };
48 }
49
50
51### Usage
52
53 $ syncthing-set-id
54
55 usage: syncthing-set-device-id file [name] [id]
56 example: syncthing-set-device-id /etc/nixos/modules/syncthing-devices.nix
57 example: syncthing-set-device-id /etc/nixos/modules/syncthing-devices.nix lappy
58 example: syncthing-set-device-id /etc/nixos/modules/syncthing-devices.nix lappy 1234567-89ABCDE-FGHIJKL-MNOPQRS-TUVWXYZ-0123456-789ABCD-EFGHIJK
59
60 If `name` is not specified, $HOSTNAME is used.
61 If `id` is not specified, the ID of the current system instance is used.
62
63
64### Installation
65
66You can use this repo as a channel.
67
68Or, you can use an overlay. For example, you could create a `~/.config/nixpkgs/overlays/syncthing-set-id.nix` with this in it:
69
70 self: super:
71 let
72 syncthing-set-id-pkgs = import (builtins.fetchGit {
73 url = "https://scottworley.com/syncthing-set-id.git";
74 ref = "master";
75 rev = "0c29f01e83fdadd491b930a9108519be03c7937d";
76 }) { pkgs = self; };
77 in { inherit (syncthing-set-id-pkgs) syncthing-set-id; }
78
79And then
80
81 $ nix-env -iA nixos.syncthing-set-id