1
2
Fork
You've already forked snac2nex
0
Export Snac profiles to the Nex blog format https://crates.io/crates/snac2nex
  • Rust 100%
2025年07月13日 16:23:49 +03:00
src use trim_start_matches 2025年07月13日 16:23:49 +03:00
.gitignore initial commit 2025年07月01日 17:39:30 +03:00
Cargo.toml update version 2025年07月13日 16:04:24 +03:00
LICENSE initial commit 2025年07月01日 17:39:30 +03:00
README.md init filesystem-dir-permissions option 2025年07月05日 23:26:14 +03:00

snac2nex

Dependencies crates.io

Convert Snac profiles to the Nex blog format. Useful as a mirroring tool for an existing fediverse instance or for migrating the data once.

Install

cargo install snac2nex

Usage

snac2nex -s /path/to/snac/storage -t /path/to/nex -u user1 -u user2

Options

 -s, --source <SOURCE>
 Path to the Snac2 profile directory
 -t, --target <TARGET>
 Target directory for public data export
 -u, --user <USER>
 Username(s) to export
 -a, --attachment <ATTACHMENT>
 Include attachment files export
 Supported values:
 * `c` (`copy`) - copy files
 * `h` (`hard`) - create hard links
 * `s` (`soft`) - create soft links (macos, linux, windows only)
 -r, --rotate <ROTATE>
 Keep running as the daemon, renew every `n` seconds
 -f, --format-content <FORMAT_CONTENT>
 Post template pattern
 [default: {content}{attachments}{link}{tags}{updated}]
 --format-filename <FORMAT_FILENAME>
 Post filenames format
 * append trailing slash to parse documents as the directory
 * append `.gmi` or `.gemtext` extension to format documents as Gemtext
 * escape with `%%` when using in `systemd` context
 * be careful when removing the seconds part, as it may cause overwrite collisions!
 [default: %H-%M-%S]
 --format-updated <FORMAT_UPDATED>
 Post `{updated}` time format
 * escaped with `%%`
 [default: "%Y/%m/%d %H:%M:%S"]
 --filesystem-sync-time
 Sync file meta with Snac entry time (e.g. time modified)
 --filesystem-dir-permissions <FILESYSTEM_DIR_PERMISSIONS>
 Set new directory permissions (macos, linux only)
 --filesystem-file-permissions <FILESYSTEM_FILE_PERMISSIONS>
 Set new file permissions (macos, linux only)
 -k, --keep
 Keep Nex entry on Snac post was removed
 -d, --daemon
 Disables some debug output
 -h, --help
 Print help (see a summary with '-h')
 -V, --version
 Print version

Systemd

To use snac2nex as the systemd service, install binary to the canonical system location:

  • git clone https://codeberg.org/postscriptum/snac2nex.git && cd snac2nex
  • cargo build --release
  • sudo install target/release/snac2nex /usr/local/bin/snac2nex
    • tip: now you may want to clean the snac2nex sources folder to free up disk space

Setup shared access permissions:

  1. useradd -m snac2nex - create new user with home dir (for log files)
  2. usermod -aG snac snac2nex - replace snac with the systemd group for your Snac server
    • chmod -R g+r /path/to/snac/storage - give the group read permissions to Snac directories
  3. usermod -aG nexy snac2nex - replace nexy with the systemd group for your your Nex protocol server (e.g. Nexy)
    • chmod -R g+rw /path/to/nex - give the group read/write permissions to Nex directories

Create new systemd configuration file /etc/systemd/system/snac2nex.service:

[Unit]
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=snac2nex
Group=snac2nex
# Uncomment if your Snac or Nex unit has ExecStartPre timeout option
# ExecStartPre=/bin/sleep 15
ExecStart=/usr/local/bin/snac2nex -s /path/to/snac/storage -t /path/to/nex -u user1 -u user2 -r 3600 -d
StandardOutput=file:/home/snac2nex/debug.log
StandardError=file:/home/snac2nex/error.log
[Install]
WantedBy=multi-user.target
  • replace ExecStart arguments with your values, where:
    • -s - Snac storage location
    • -u - Snac user(s) to sync
    • -t - Nex server target location for public files
    • -r - is rotate every hour (3600 seconds) to apply Snac instance updates (instead of export once)
    • -d - enable daemon mode, which disables some debug output, to prevent extra write operations
    • optionally, include -a (attachment) as c (copy) | h (hard link) | s (soft link)
  • systemctl daemon-reload - apply new systemd configuration
  • systemctl enable snac2nex - auto-start snac2nex sync on system boot
  • systemctl start snac2nex - start snac2nex sync now

Demo

  • nex://[302:68d0:f0d5:b88d::b]/ | nex://ps.ygg/ - My personal Yggdrasil / Alfis DNS mirror

See also

  • Nexy - Server for the Nex protocol, written in Rust
  • Yoda - Client for the Gemini & Nex protocols, written in Rust