Refactor flake patching/recursion
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -192,11 +192,7 @@ cat <<EOF > "./hosts/$host/README.md"
|
||||
EOF
|
||||
|
||||
sed -i "/nixosConfigurations = {/a\\
|
||||
$host = nixpkgs.lib.nixosSystem rec {\\
|
||||
system = \"x86_64-linux\";\\
|
||||
modules = [ ./hosts/$host ];\\
|
||||
specialArgs = { inherit inputs system; };\\
|
||||
};\n\n" flake.nix
|
||||
$host = mkNixosConfiguration inputs system [ ./hosts/$host ];\n" flake.nix
|
||||
|
||||
sed -i "/knownHosts = {/a\\ $host.publicKeyFile = ../../../../$host/secrets/ssh_host_ed25519_key.pub;" ./hosts/common/configs/system/ssh/default.nix
|
||||
|
||||
|
@@ -18,9 +18,8 @@ find . -type f -name "sops.yaml" | while IFS= read -r sops_file; do
|
||||
sed -i "/ - \*$host/d" "$sops_file"
|
||||
done
|
||||
|
||||
sed -i "/$host/d" ./hosts/common/configs/system/ssh/default.nix
|
||||
sed -i "/$host = nixpkgs.lib.nixosSystem rec {/,/^[[:space:]]*};/d" flake.nix
|
||||
sed -i "/$host/d" ./README.md
|
||||
sed -i "/$host = mkNixosConfiguration/d" flake.nix
|
||||
sed -i "/`$host`/d" ./README.md
|
||||
|
||||
rm -rf "./hosts/$host"
|
||||
|
||||
|
@@ -4,43 +4,6 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "Updating submodules..."
|
||||
|
||||
paths=$(git config --file .gitmodules --name-only --get-regexp path | while read -r line; do
|
||||
path=$(git config --file .gitmodules --get "$line")
|
||||
url=$(git config --file .gitmodules --get "${line%.*}.url")
|
||||
if [[ $url == *"karaolidis"* ]]; then
|
||||
echo "$path"
|
||||
fi
|
||||
done)
|
||||
|
||||
for path in $paths; do
|
||||
echo "Processing submodule: $path"
|
||||
|
||||
cd "$path" || exit
|
||||
|
||||
default_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
||||
git checkout "$default_branch"
|
||||
git fetch upstream
|
||||
git merge "upstream/$default_branch"
|
||||
|
||||
branches=$(git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v "^${default_branch}$")
|
||||
for branch in $branches; do
|
||||
git checkout "$branch"
|
||||
git rebase "$default_branch"
|
||||
done
|
||||
|
||||
git checkout integration
|
||||
git push origin --all --force-with-lease
|
||||
git push origin --tags --force-with-lease
|
||||
|
||||
cd - > /dev/null || exit
|
||||
done
|
||||
|
||||
echo "All submodules updated successfully."
|
||||
|
||||
echo "Updating packages..."
|
||||
|
||||
find packages -type f -name "*.nix" | while read -r file; do
|
||||
update_command=$(grep -oP '^#\s*AUTO-UPDATE:\s*\K.+' "$file" || true)
|
||||
if [[ -n "$update_command" ]]; then
|
||||
@@ -49,6 +12,4 @@ find packages -type f -name "*.nix" | while read -r file; do
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All packages updated successfully."
|
||||
|
||||
nix flake update
|
||||
|
Reference in New Issue
Block a user