fix: Git-annex fixes

This commit is contained in:
Madeleine Sydney
2025-01-24 18:09:37 -07:00
parent 83a37f2288
commit 3616248c20
8 changed files with 50 additions and 13 deletions

View File

@@ -78,7 +78,8 @@ in {
# The user that users log in as to access managed repos.
users.groups.annex = {};
users.users.annex = {
isSystemUser = true;
# Necessary to enable cloning over SSH.
isNormalUser = true;
group = "annex";
home = "/var/sydnix/annex";
createHome = true;
@@ -92,9 +93,25 @@ in {
name = ${cfg.user.name}
[init]
defaultBranch = main
[core]
symlinks = true
'';
in ''
ln -sf "${gitconfig-file}" ~/.gitconfig
set -e
annexHome="${config.users.users.annex.home}"
ln -sf "${gitconfig-file}" "$annexHome/.gitconfig"
# Symlink repos into annex's home for easy access. This is particularly nice for cloning:
# git clone annex@deertopia.net:org
# instead of
# git clone annex@deertopia.net:/persist/deertopia.net/org
# Less assumptions about the host's file system!
${lib.strings.toShellVar "repos" (builtins.attrNames cfg.repos)}
for repoPath in ''${!repos[@]}; do
target="$annexHome/$(basename "$repoPath")"
ln -sf "$repoPath" "$target"
done
'';
systemd.services =
@@ -103,13 +120,18 @@ in {
pkgs.writeScript "git-annex-init-if-necessary" ''
#!/usr/bin/env bash
set -e
[ -e .git ] || git init
[ -e .git/annex ] || git annex init
# Symlink repo into user `annex` for easy access.
ln -sf "$(pwd)" "$HOME/"
${lib.strings.toShellVar "remotes" repo.remotes}
for remoteName in ''${!remotes[@]}; do
git remote get-url "$remoteName"
if [ $? -eq 0 ]; then
err=0
git remote get-url "$remoteName" || err=$?
if [ $err -eq 0 ]; then
git remote set-url "$remoteName" "''${remotes["$remoteName"]}"
else
git remote add "$remoteName" "''${remotes["$remoteName"]}"