refactor: separate pass (package) from pass-store (git remotes)
This commit is contained in:
parent
eec7efabd1
commit
df2d756a08
3 changed files with 39 additions and 43 deletions
|
|
@ -7,6 +7,7 @@
|
|||
./zsh.nix
|
||||
./duti.nix
|
||||
./pass.nix
|
||||
./pass-store.nix
|
||||
];
|
||||
|
||||
home.stateVersion = "24.11";
|
||||
|
|
|
|||
38
home/pass-store.nix
Normal file
38
home/pass-store.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ config, pkgs, ... }:
|
||||
{
|
||||
# Setup git remotes for pass store
|
||||
# This file manages the git remote configuration for ~/.password-store
|
||||
# (pass itself is configured in home/pass.nix)
|
||||
|
||||
home.activation.passStoreRemotes = {
|
||||
data = ''
|
||||
set -e
|
||||
|
||||
if [ ! -d "$HOME/.password-store" ]; then
|
||||
mkdir -p "$HOME/.password-store"
|
||||
fi
|
||||
|
||||
cd "$HOME/.password-store"
|
||||
|
||||
# Init git if needed
|
||||
if [ ! -d ".git" ]; then
|
||||
${pkgs.git}/bin/git init -q
|
||||
fi
|
||||
|
||||
# Add origin (forgejo) if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url origin >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add origin "ssh://git@git.iscg.dev:2222/mikl/password-store.git"
|
||||
fi
|
||||
|
||||
# Add github remote if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url github >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add github "git@github.com:isogonalconjugate/password-store.git"
|
||||
fi
|
||||
|
||||
# Add git.sol.moe remote if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url "git.sol.moe" >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add "git.sol.moe" "git@git.sol.moe:mikl/password-store.git"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -19,47 +19,4 @@
|
|||
defaultCacheTtl = 3600;
|
||||
enableSshSupport = true;
|
||||
};
|
||||
|
||||
# Activation: setup pass git origins (forgejo + github + sol.moe)
|
||||
# Uses pkgs.writeShellScript to avoid home.activation.data string issues
|
||||
home.activation.passOrigins = {
|
||||
data = let
|
||||
setupScript = pkgs.writeShellScript "pass-origins-setup" ''
|
||||
set -e
|
||||
|
||||
# Initialize pass if not yet
|
||||
if [ ! -d "$HOME/.password-store" ]; then
|
||||
echo "Initializing pass store..."
|
||||
mkdir -p "$HOME/.password-store"
|
||||
fi
|
||||
|
||||
# Initialize git if not yet
|
||||
if [ ! -d "$HOME/.password-store/.git" ]; then
|
||||
cd "$HOME/.password-store"
|
||||
${pkgs.git}/bin/git init -q
|
||||
fi
|
||||
|
||||
cd "$HOME/.password-store"
|
||||
|
||||
# Add origin (forgejo) if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url origin >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add origin "ssh://git@git.iscg.dev:2222/mikl/password-store.git"
|
||||
fi
|
||||
|
||||
# Add github remote if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url github >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add github "git@github.com:isogonalconjugate/password-store.git"
|
||||
fi
|
||||
|
||||
# Add git.sol.moe remote if not present
|
||||
if ! ${pkgs.git}/bin/git remote get-url git.sol.moe >/dev/null 2>&1; then
|
||||
${pkgs.git}/bin/git remote add "git.sol.moe" "git@git.sol.moe:mikl/password-store.git"
|
||||
fi
|
||||
|
||||
cd - >/dev/null
|
||||
'';
|
||||
in builtins.toFile "pass-origins.sh" ''
|
||||
${setupScript}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue