updates: (also build system back?)
This commit is contained in:
parent
2606d3f2a7
commit
8498f7d121
6 changed files with 548 additions and 481 deletions
259
.github/workflows/daily-flake-update.yml
vendored
Normal file
259
.github/workflows/daily-flake-update.yml
vendored
Normal file
|
|
@ -0,0 +1,259 @@
|
||||||
|
name: Daily Flake Update for Earth System
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Run daily at midnight UTC
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: automated/flake-update
|
||||||
|
PR_TITLE: "Automated: Update flake inputs"
|
||||||
|
HYDRA_URL: "https://hydra.zoeys.computer"
|
||||||
|
SYSTEM_NAME: "earth"
|
||||||
|
HYDRA_PROJECT: "config"
|
||||||
|
HYDRA_JOBSET: "config-build"
|
||||||
|
HYDRA_JOB: "x86_64-linux.earth"
|
||||||
|
FORGEJO_API_URL: "${{ github.server_url }}/api/v1"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-flake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v24
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Check for existing PR
|
||||||
|
id: check-pr
|
||||||
|
run: |
|
||||||
|
# Get repository information from GitHub context
|
||||||
|
REPO_OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
|
||||||
|
REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
||||||
|
|
||||||
|
# Query Forgejo API for existing PRs
|
||||||
|
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/pulls?state=open&head=${REPO_OWNER}:${{ env.BRANCH_NAME }}")
|
||||||
|
|
||||||
|
# Check if PR exists and extract PR number
|
||||||
|
PR_COUNT=$(echo "$PR_DATA" | jq '. | length')
|
||||||
|
|
||||||
|
if [[ "$PR_COUNT" -gt 0 ]]; then
|
||||||
|
PR_NUMBER=$(echo "$PR_DATA" | jq -r '.[0].number')
|
||||||
|
echo "Found existing PR #$PR_NUMBER"
|
||||||
|
echo "pr_exists=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "No existing PR found"
|
||||||
|
echo "pr_exists=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "pr_number=" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Set up branch
|
||||||
|
run: |
|
||||||
|
git config --global user.name "Flake Update Bot"
|
||||||
|
git config --global user.email "bot@example.com"
|
||||||
|
|
||||||
|
if [[ "${{ steps.check-pr.outputs.pr_exists }}" == "true" ]]; then
|
||||||
|
# Update existing branch
|
||||||
|
git fetch origin ${{ env.BRANCH_NAME }}
|
||||||
|
git checkout ${{ env.BRANCH_NAME }}
|
||||||
|
else
|
||||||
|
# Create new branch
|
||||||
|
git checkout -b ${{ env.BRANCH_NAME }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Update flake inputs
|
||||||
|
id: flake-update
|
||||||
|
run: |
|
||||||
|
cd nixos
|
||||||
|
nix flake update
|
||||||
|
|
||||||
|
if [[ -z "$(git status --porcelain)" ]]; then
|
||||||
|
echo "No changes to commit"
|
||||||
|
echo "changes_made=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
git add flake.lock
|
||||||
|
git commit -m "chore: update flake inputs"
|
||||||
|
git push -f origin ${{ env.BRANCH_NAME }}
|
||||||
|
echo "changes_made=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create or update PR
|
||||||
|
id: create-pr
|
||||||
|
if: steps.flake-update.outputs.changes_made == 'true'
|
||||||
|
run: |
|
||||||
|
# Get repository information
|
||||||
|
REPO_OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
|
||||||
|
REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
||||||
|
|
||||||
|
if [[ "${{ steps.check-pr.outputs.pr_exists }}" == "true" ]]; then
|
||||||
|
echo "Updating existing PR #${{ steps.check-pr.outputs.pr_number }}"
|
||||||
|
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
|
||||||
|
|
||||||
|
# Update PR with comment about new update
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"body": "Updated flake inputs with latest versions"}' \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments"
|
||||||
|
|
||||||
|
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Creating new PR"
|
||||||
|
|
||||||
|
# Create new PR using API
|
||||||
|
PR_DATA=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"title": "'"${{ env.PR_TITLE }}"'",
|
||||||
|
"body": "This is an automated PR to update flake inputs. It will be automatically merged if the Hydra build for the Earth system passes.",
|
||||||
|
"head": "'"${{ env.BRANCH_NAME }}"'",
|
||||||
|
"base": "main",
|
||||||
|
"draft": true
|
||||||
|
}' \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/pulls")
|
||||||
|
|
||||||
|
PR_NUMBER=$(echo "$PR_DATA" | jq -r '.number')
|
||||||
|
echo "Created PR #$PR_NUMBER"
|
||||||
|
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Wait for Hydra build to start
|
||||||
|
run: |
|
||||||
|
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
|
||||||
|
if [[ -z "$PR_NUMBER" ]]; then
|
||||||
|
PR_NUMBER="${{ steps.create-pr.outputs.pr_number }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Waiting for Hydra build to start (checking every 60 seconds, timeout after 30 minutes)..."
|
||||||
|
MAX_ATTEMPTS=30
|
||||||
|
ATTEMPT=0
|
||||||
|
|
||||||
|
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||||
|
ATTEMPT=$((ATTEMPT+1))
|
||||||
|
|
||||||
|
# Get the latest commit SHA from the branch
|
||||||
|
COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
|
|
||||||
|
# Check if Hydra build exists for this commit using API
|
||||||
|
BUILD_STATUS=$(curl -s "${{ env.HYDRA_URL }}/api/jobsets?project=${{ env.HYDRA_PROJECT }}" || echo "")
|
||||||
|
|
||||||
|
if [[ "$BUILD_STATUS" == *"${{ env.HYDRA_JOBSET }}"* ]]; then
|
||||||
|
echo "Hydra jobset found! Monitoring build status..."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: No Hydra build found yet, waiting 60 seconds..."
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $ATTEMPT -ge $MAX_ATTEMPTS ]; then
|
||||||
|
echo "Timeout waiting for Hydra build to start. PR will remain in draft state."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Monitor Hydra build
|
||||||
|
id: hydra-build
|
||||||
|
run: |
|
||||||
|
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
|
||||||
|
if [[ -z "$PR_NUMBER" ]]; then
|
||||||
|
PR_NUMBER="${{ steps.create-pr.outputs.pr_number }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Monitoring Hydra build status (checking every 5 minutes, timeout after 6 hours)..."
|
||||||
|
MAX_ATTEMPTS=72
|
||||||
|
ATTEMPT=0
|
||||||
|
|
||||||
|
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||||
|
ATTEMPT=$((ATTEMPT+1))
|
||||||
|
|
||||||
|
# Get latest evaluation ID
|
||||||
|
EVAL_INFO=$(curl -s "${{ env.HYDRA_URL }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}/evals" || echo "")
|
||||||
|
LATEST_EVAL_ID=$(echo "$EVAL_INFO" | grep -o -E '"id":[0-9]+' | head -n 1 | cut -d ':' -f 2)
|
||||||
|
|
||||||
|
if [[ -z "$LATEST_EVAL_ID" ]]; then
|
||||||
|
echo "No evaluation found yet, continuing to wait..."
|
||||||
|
sleep 300
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Found latest evaluation ID: $LATEST_EVAL_ID"
|
||||||
|
|
||||||
|
# Get build status for the specific job from evaluation
|
||||||
|
EVAL_BUILDS=$(curl -s "${{ env.HYDRA_URL }}/eval/$LATEST_EVAL_ID/builds" || echo "")
|
||||||
|
|
||||||
|
# Look for our specific job in the evaluation
|
||||||
|
if [[ "$EVAL_BUILDS" == *"${{ env.HYDRA_JOB }}"* ]]; then
|
||||||
|
# Extract buildstatus for our job
|
||||||
|
JOB_STATUS=$(echo "$EVAL_BUILDS" | grep -o -E '"buildstatus":[0-9]+' | head -n 1 | cut -d ':' -f 2)
|
||||||
|
|
||||||
|
if [[ "$JOB_STATUS" == "0" ]]; then
|
||||||
|
echo "Build succeeded (status: $JOB_STATUS)!"
|
||||||
|
echo "build_success=true" >> $GITHUB_OUTPUT
|
||||||
|
break
|
||||||
|
elif [[ "$JOB_STATUS" == "1" || "$JOB_STATUS" == "2" || "$JOB_STATUS" == "3" || "$JOB_STATUS" == "4" ||
|
||||||
|
"$JOB_STATUS" == "6" || "$JOB_STATUS" == "7" || "$JOB_STATUS" == "9" || "$JOB_STATUS" == "10" ||
|
||||||
|
"$JOB_STATUS" == "11" ]]; then
|
||||||
|
echo "Build failed (status: $JOB_STATUS)!"
|
||||||
|
echo "build_success=false" >> $GITHUB_OUTPUT
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Build still in progress or not found, waiting 5 minutes..."
|
||||||
|
sleep 300
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $ATTEMPT -ge $MAX_ATTEMPTS ]; then
|
||||||
|
echo "Timeout waiting for build to complete. PR will remain in draft state."
|
||||||
|
echo "build_success=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Mark PR ready for review or merge if build succeeded
|
||||||
|
if: steps.hydra-build.outputs.build_success == 'true'
|
||||||
|
run: |
|
||||||
|
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
|
||||||
|
if [[ -z "$PR_NUMBER" ]]; then
|
||||||
|
PR_NUMBER="${{ steps.create-pr.outputs.pr_number }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get repository information
|
||||||
|
REPO_OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
|
||||||
|
REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
||||||
|
|
||||||
|
# Mark PR as ready for review (not draft)
|
||||||
|
curl -s -X PATCH \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"draft": false}' \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/pulls/${PR_NUMBER}"
|
||||||
|
|
||||||
|
# Add comment about successful build
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"body": "Hydra build succeeded! Merging PR."}' \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments"
|
||||||
|
|
||||||
|
# Merge the PR
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"merge_method": "merge",
|
||||||
|
"commit_title": "'"${{ env.PR_TITLE }}"'",
|
||||||
|
"commit_message": "Automated merge after successful Hydra build for the Earth system."
|
||||||
|
}' \
|
||||||
|
"${{ env.FORGEJO_API_URL }}/repos/${REPO_OWNER}/${REPO_NAME}/pulls/${PR_NUMBER}/merge"
|
||||||
395
.github/workflows/update.yml
vendored
395
.github/workflows/update.yml
vendored
|
|
@ -1,395 +0,0 @@
|
||||||
name: Nix Flake Update
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *' # Run daily at midnight UTC
|
|
||||||
workflow_dispatch: # Allow manual trigger
|
|
||||||
|
|
||||||
env:
|
|
||||||
BRANCH_NAME: auto-update-flake-${{ github.run_number }}
|
|
||||||
HYDRA_INSTANCE: https://hydra.zoeys.computer
|
|
||||||
HYDRA_PROJECT: config
|
|
||||||
HYDRA_JOBSET: pr-${{ github.run_number }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check-existing-pr:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
pr_exists: ${{ steps.check-pr.outputs.pr_exists }}
|
|
||||||
pr_number: ${{ steps.check-pr.outputs.pr_number }}
|
|
||||||
steps:
|
|
||||||
- name: Check for existing PR
|
|
||||||
id: check-pr
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
existing_pr=$(gh pr list --repo ${{ github.repository }} --state open --json number,headRefName --jq '.[] | select(.headRefName | startswith("auto-update-flake")) | .number' | head -n1)
|
|
||||||
echo "$existing_pr"
|
|
||||||
if [ -n "$existing_pr" ]; then
|
|
||||||
echo "pr_exists=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "pr_number=$existing_pr" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "pr_exists=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
update-flake:
|
|
||||||
needs: check-existing-pr
|
|
||||||
if: needs.check-existing-pr.outputs.pr_exists == 'false'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Fetch all history for all branches and tags
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: cachix/install-nix-action@v30
|
|
||||||
|
|
||||||
- name: Update flake dependencies
|
|
||||||
id: update-flake
|
|
||||||
run: |
|
|
||||||
git config user.name github-actions
|
|
||||||
git config user.email github-actions@github.com
|
|
||||||
nix flake update --accept-flake-config
|
|
||||||
git diff
|
|
||||||
if [[ -n $(git status -s) ]]; then
|
|
||||||
echo "CHANGED=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Changes detected:"
|
|
||||||
git status -s
|
|
||||||
else
|
|
||||||
echo "CHANGED=false" >> $GITHUB_OUTPUT
|
|
||||||
echo "No changes detected."
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create branch and commit changes
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
run: |
|
|
||||||
git checkout -b ${{ env.BRANCH_NAME }}
|
|
||||||
git add .
|
|
||||||
git commit -m "chore: update flake dependencies"
|
|
||||||
git push -u origin ${{ env.BRANCH_NAME }}
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
gh pr create --title "Auto-update Nix flake dependencies" \
|
|
||||||
--body "This PR updates the Nix flake dependencies." \
|
|
||||||
--base main \
|
|
||||||
--head ${{ env.BRANCH_NAME }}
|
|
||||||
|
|
||||||
- name: Get Hydra session token
|
|
||||||
id: hydra-session
|
|
||||||
run: |
|
|
||||||
response=$(curl -X POST -i \
|
|
||||||
'${{ env.HYDRA_INSTANCE }}/login' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H 'Origin: ${{ env.HYDRA_INSTANCE }}' \
|
|
||||||
-d '{
|
|
||||||
"username": "${{ secrets.HYDRA_USERNAME }}",
|
|
||||||
"password": "${{ secrets.HYDRA_PASSWORD }}"
|
|
||||||
}')
|
|
||||||
session_cookie=$(echo "$response" | grep -i 'set-cookie' | sed -n 's/.*hydra_session=\([^;]*\).*/\1/p')
|
|
||||||
echo "SESSION_COOKIE=$session_cookie" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create Hydra jobset
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X PUT -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-d '{
|
|
||||||
"enabled": 1,
|
|
||||||
"visible": false,
|
|
||||||
"keepnr": 3,
|
|
||||||
"schedulingshares": 100,
|
|
||||||
"checkinterval": 60,
|
|
||||||
"description": "PR #${{ github.event.pull_request.number }} - Auto-update flake dependencies",
|
|
||||||
"flake": "github:${{ github.repository }}/${{ env.BRANCH_NAME }}",
|
|
||||||
"type": 1
|
|
||||||
}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}"
|
|
||||||
|
|
||||||
- name: Trigger Hydra build
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-H "Origin: ${{ env.HYDRA_INSTANCE }}" \
|
|
||||||
-d '{"jobsets": ["${{ env.HYDRA_PROJECT }}:${{ env.HYDRA_JOBSET }}"]}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/api/push"
|
|
||||||
|
|
||||||
- name: Wait for Hydra build
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
id: wait-for-build
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
max_attempts=60 # 30 minutes (30 * 2 minutes)
|
|
||||||
attempt=0
|
|
||||||
build_status="unknown"
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status
|
|
||||||
while [ $attempt -lt $max_attempts ]; do
|
|
||||||
echo "Attempt $((attempt + 1))/$max_attempts"
|
|
||||||
response=$(curl -s -H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/api/jobsets?project=${{ env.HYDRA_PROJECT }}")
|
|
||||||
jobset=$(echo "$response" | jq -r '.[] | select(.name == "${{ env.HYDRA_JOBSET }}")')
|
|
||||||
|
|
||||||
if [ -z "$jobset" ]; then
|
|
||||||
echo "Jobset ${{ env.HYDRA_JOBSET }} not found. Waiting..."
|
|
||||||
sleep 120
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
nrscheduled=$(echo "$jobset" | jq -r '.nrscheduled')
|
|
||||||
nrfailed=$(echo "$jobset" | jq -r '.nrfailed')
|
|
||||||
nrsucceeded=$(echo "$jobset" | jq -r '.nrsucceeded')
|
|
||||||
nrtotal=$(echo "$jobset" | jq -r '.nrtotal')
|
|
||||||
|
|
||||||
echo "Status: nrscheduled=$nrscheduled, nrfailed=$nrfailed, nrsucceeded=$nrsucceeded, nrtotal=$nrtotal"
|
|
||||||
|
|
||||||
if [ "$nrtotal" = "0" ]; then
|
|
||||||
echo "Build not started yet. Waiting..."
|
|
||||||
elif [ "$nrfailed" != "0" ]; then
|
|
||||||
build_status="failed"
|
|
||||||
break
|
|
||||||
elif [ "$nrsucceeded" = "$nrtotal" ] && [ "$nrtotal" != "0" ]; then
|
|
||||||
build_status="succeeded"
|
|
||||||
break
|
|
||||||
elif [ "$nrscheduled" = "0" ] && [ "$nrsucceeded" != "0" ] && [ "$nrsucceeded" = "$nrtotal" ]; then
|
|
||||||
build_status="succeeded"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo "Build in progress. Waiting..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 120 # Wait for 2 minutes before checking again
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$build_status" = "unknown" ]; then
|
|
||||||
echo "Timeout reached. Considering build as failed."
|
|
||||||
build_status="failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "BUILD_SUCCESS=$([ "$build_status" = "succeeded" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
|
|
||||||
if [ "$build_status" = "succeeded" ]; then
|
|
||||||
echo "Build succeeded!"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Build failed or timed out."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Disable Hydra jobset
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X PUT -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-d '{
|
|
||||||
"enabled": 0,
|
|
||||||
"visible": false,
|
|
||||||
"keepnr": 3,
|
|
||||||
"schedulingshares": 100,
|
|
||||||
"checkinterval": 60,
|
|
||||||
"description": "PR #${{ github.event.pull_request.number }} - Auto-update flake dependencies (Disabled)",
|
|
||||||
"flake": "github:${{ github.repository }}/${{ env.BRANCH_NAME }}",
|
|
||||||
"type": 1
|
|
||||||
}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}"
|
|
||||||
|
|
||||||
- name: Merge PR if build succeeds
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
gh pr merge ${{ steps.create-pr.outputs.pr_number }} --merge
|
|
||||||
|
|
||||||
- name: Exit if build fails
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true'
|
|
||||||
run: exit 1
|
|
||||||
|
|
||||||
retry-update:
|
|
||||||
needs: check-existing-pr
|
|
||||||
if: needs.check-existing-pr.outputs.pr_exists == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: cachix/install-nix-action@v30
|
|
||||||
|
|
||||||
- name: Checkout PR branch
|
|
||||||
run: |
|
|
||||||
pr_number="${{ needs.check-existing-pr.outputs.pr_number }}"
|
|
||||||
branch_name=$(gh pr view $pr_number --json headRefName -q .headRefName)
|
|
||||||
git checkout $branch_name
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Update flake dependencies
|
|
||||||
id: update-flake
|
|
||||||
run: |
|
|
||||||
git config user.name github-actions
|
|
||||||
git config user.email github-actions@github.com
|
|
||||||
nix flake update --accept-flake-config
|
|
||||||
git diff
|
|
||||||
if [[ -n $(git status -s) ]]; then
|
|
||||||
echo "CHANGED=true" >> $GITHUB_OUTPUT
|
|
||||||
git add .
|
|
||||||
git commit -m "Auto-update flake dependencies (retry)"
|
|
||||||
git push origin HEAD
|
|
||||||
else
|
|
||||||
echo "CHANGED=false" >> $GITHUB_OUTPUT
|
|
||||||
echo "No changes detected."
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Get Hydra session token
|
|
||||||
id: hydra-session
|
|
||||||
run: |
|
|
||||||
response=$(curl -X POST -i \
|
|
||||||
'${{ env.HYDRA_INSTANCE }}/login' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H 'Origin: ${{ env.HYDRA_INSTANCE }}' \
|
|
||||||
-d '{
|
|
||||||
"username": "${{ secrets.HYDRA_USERNAME }}",
|
|
||||||
"password": "${{ secrets.HYDRA_PASSWORD }}"
|
|
||||||
}')
|
|
||||||
session_cookie=$(echo "$response" | grep -i 'set-cookie' | sed -n 's/.*hydra_session=\([^;]*\).*/\1/p')
|
|
||||||
echo "SESSION_COOKIE=$session_cookie" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create Hydra jobset
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X PUT -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-d '{
|
|
||||||
"enabled": 1,
|
|
||||||
"visible": false,
|
|
||||||
"keepnr": 3,
|
|
||||||
"schedulingshares": 100,
|
|
||||||
"checkinterval": 60,
|
|
||||||
"description": "PR #${{ github.event.pull_request.number }} - Auto-update flake dependencies",
|
|
||||||
"flake": "github:${{ github.repository }}/${{ env.BRANCH_NAME }}",
|
|
||||||
"type": 1
|
|
||||||
}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}"
|
|
||||||
|
|
||||||
- name: Trigger Hydra build
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-H "Origin: ${{ env.HYDRA_INSTANCE }}" \
|
|
||||||
-d '{"jobsets": ["${{ env.HYDRA_PROJECT }}:${{ env.HYDRA_JOBSET }}"]}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/api/push"
|
|
||||||
|
|
||||||
- name: Wait for Hydra build
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true'
|
|
||||||
id: wait-for-build
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
max_attempts=60 # 30 minutes (30 * 2 minutes)
|
|
||||||
attempt=0
|
|
||||||
build_status="unknown"
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status
|
|
||||||
while [ $attempt -lt $max_attempts ]; do
|
|
||||||
echo "Attempt $((attempt + 1))/$max_attempts"
|
|
||||||
response=$(curl -s -H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/api/jobsets?project=${{ env.HYDRA_PROJECT }}")
|
|
||||||
jobset=$(echo "$response" | jq -r '.[] | select(.name == "${{ env.HYDRA_JOBSET }}")')
|
|
||||||
|
|
||||||
if [ -z "$jobset" ]; then
|
|
||||||
echo "Jobset ${{ env.HYDRA_JOBSET }} not found. Waiting..."
|
|
||||||
sleep 120
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
nrscheduled=$(echo "$jobset" | jq -r '.nrscheduled')
|
|
||||||
nrfailed=$(echo "$jobset" | jq -r '.nrfailed')
|
|
||||||
nrsucceeded=$(echo "$jobset" | jq -r '.nrsucceeded')
|
|
||||||
nrtotal=$(echo "$jobset" | jq -r '.nrtotal')
|
|
||||||
|
|
||||||
echo "Status: nrscheduled=$nrscheduled, nrfailed=$nrfailed, nrsucceeded=$nrsucceeded, nrtotal=$nrtotal"
|
|
||||||
|
|
||||||
if [ "$nrtotal" = "0" ]; then
|
|
||||||
echo "Build not started yet. Waiting..."
|
|
||||||
elif [ "$nrfailed" != "0" ]; then
|
|
||||||
build_status="failed"
|
|
||||||
break
|
|
||||||
elif [ "$nrsucceeded" = "$nrtotal" ] && [ "$nrtotal" != "0" ]; then
|
|
||||||
build_status="succeeded"
|
|
||||||
break
|
|
||||||
elif [ "$nrscheduled" = "0" ] && [ "$nrsucceeded" != "0" ] && [ "$nrsucceeded" = "$nrtotal" ]; then
|
|
||||||
build_status="succeeded"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo "Build in progress. Waiting..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 120 # Wait for 2 minutes before checking again
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$build_status" = "unknown" ]; then
|
|
||||||
echo "Timeout reached. Considering build as failed."
|
|
||||||
build_status="failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "BUILD_SUCCESS=$([ "$build_status" = "succeeded" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
|
|
||||||
if [ "$build_status" = "succeeded" ]; then
|
|
||||||
echo "Build succeeded!"
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Build failed or timed out."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Merge PR if build succeeds
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
gh pr merge ${{ needs.check-existing-pr.outputs.pr_number }} --merge
|
|
||||||
|
|
||||||
- name: Disable Hydra jobset
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS == 'true'
|
|
||||||
env:
|
|
||||||
SESSION_COOKIE: ${{ steps.hydra-session.outputs.SESSION_COOKIE }}
|
|
||||||
run: |
|
|
||||||
curl -X PUT -H "Content-Type: application/json" \
|
|
||||||
-H "Cookie: hydra_session=$SESSION_COOKIE" \
|
|
||||||
-d '{
|
|
||||||
"enabled": 0,
|
|
||||||
"visible": false,
|
|
||||||
"keepnr": 3,
|
|
||||||
"schedulingshares": 100,
|
|
||||||
"checkinterval": 60,
|
|
||||||
"description": "PR #${{ github.event.pull_request.number }} - Auto-update flake dependencies (Disabled)",
|
|
||||||
"flake": "github:${{ github.repository }}/${{ env.BRANCH_NAME }}",
|
|
||||||
"type": 1
|
|
||||||
}' \
|
|
||||||
"${{ env.HYDRA_INSTANCE }}/jobset/${{ env.HYDRA_PROJECT }}/${{ env.HYDRA_JOBSET }}"
|
|
||||||
|
|
||||||
- name: Exit if build fails
|
|
||||||
if: steps.update-flake.outputs.CHANGED == 'true' && steps.wait-for-build.outputs.BUILD_SUCCESS != 'true'
|
|
||||||
run: exit 1
|
|
||||||
|
|
@ -22,7 +22,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
bold_font ${fonts.mono} Bold Italic
|
bold_font ${fonts.mono} Bold
|
||||||
italic_font ${fonts.mono} Italic
|
italic_font ${fonts.mono} Italic
|
||||||
bold_italic_font ${fonts.mono} Bold Italic
|
bold_italic_font ${fonts.mono} Bold Italic
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
276
modules/home/apps/tools/neovim/config/lua/plugins/lualine.lua
Normal file
276
modules/home/apps/tools/neovim/config/lua/plugins/lualine.lua
Normal file
|
|
@ -0,0 +1,276 @@
|
||||||
|
return {
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
config = function()
|
||||||
|
-- Eviline config for lualine
|
||||||
|
-- Author: shadmansaleh
|
||||||
|
-- Credit: glepnir
|
||||||
|
local lualine = require("lualine")
|
||||||
|
local ctp = require("catppuccin.palettes").get_palette("mocha")
|
||||||
|
|
||||||
|
local conditions = {
|
||||||
|
buffer_not_empty = function()
|
||||||
|
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||||
|
end,
|
||||||
|
hide_in_width = function()
|
||||||
|
return vim.fn.winwidth(0) > 80
|
||||||
|
end,
|
||||||
|
check_git_workspace = function()
|
||||||
|
local filepath = vim.fn.expand("%:p:h")
|
||||||
|
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
||||||
|
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Config
|
||||||
|
local config = {
|
||||||
|
options = {
|
||||||
|
-- Disable sections and component separators
|
||||||
|
component_separators = "",
|
||||||
|
section_separators = "",
|
||||||
|
theme = {
|
||||||
|
-- We are going to use lualine_c an lualine_x as left and
|
||||||
|
-- right section. Both are highlighted by c theme . So we
|
||||||
|
-- are just setting default looks o statusline
|
||||||
|
normal = { c = { fg = ctp.text, bg = ctp.base } },
|
||||||
|
inactive = { c = { fg = ctp.overlay0, bg = ctp.base } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
-- these are to remove the defaults
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {},
|
||||||
|
-- These will be filled later
|
||||||
|
lualine_c = {},
|
||||||
|
lualine_x = {},
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
-- these are to remove the defaults
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {},
|
||||||
|
lualine_c = {},
|
||||||
|
lualine_x = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Function to get abbreviated mode indicators for status line
|
||||||
|
-- Returns a single character representing the current mode
|
||||||
|
-- Usage example: local mode = get_mode_abbr()
|
||||||
|
local function get_mode_abbr()
|
||||||
|
local mode_map = {
|
||||||
|
["n"] = "N", -- Normal
|
||||||
|
["no"] = "N", -- Operator-pending
|
||||||
|
["nov"] = "N", -- Operator-pending (forced charwise)
|
||||||
|
["noV"] = "N", -- Operator-pending (forced linewise)
|
||||||
|
["no\22"] = "N", -- Operator-pending (forced blockwise)
|
||||||
|
["niI"] = "N", -- Normal using i_CTRL-O in Insert-mode
|
||||||
|
["niR"] = "N", -- Normal using i_CTRL-O in Replace-mode
|
||||||
|
["niV"] = "N", -- Normal using i_CTRL-O in Virtual-Replace-mode
|
||||||
|
["nt"] = "N", -- Normal in terminal-emulator
|
||||||
|
["v"] = "V", -- Visual
|
||||||
|
["vs"] = "V", -- Visual using i_CTRL-O in Select-mode
|
||||||
|
["V"] = "VL", -- Visual Line
|
||||||
|
["Vs"] = "VL", -- Visual Line using i_CTRL-O in Select-mode
|
||||||
|
["\22"] = "VB", -- Visual Block
|
||||||
|
["\22s"] = "VB", -- Visual Block using i_CTRL-O in Select-mode
|
||||||
|
["s"] = "S", -- Select
|
||||||
|
["S"] = "SL", -- Select Line
|
||||||
|
["\19"] = "SB", -- Select Block
|
||||||
|
["i"] = "I", -- Insert
|
||||||
|
["ic"] = "I", -- Insert mode completion
|
||||||
|
["ix"] = "I", -- Insert mode i_CTRL-X
|
||||||
|
["R"] = "R", -- Replace
|
||||||
|
["Rc"] = "R", -- Replace mode completion
|
||||||
|
["Rx"] = "R", -- Replace mode i_CTRL-X
|
||||||
|
["Rv"] = "VR", -- Virtual Replace
|
||||||
|
["Rvc"] = "VR", -- Virtual Replace mode completion
|
||||||
|
["Rvx"] = "VR", -- Virtual Replace mode i_CTRL-X
|
||||||
|
["c"] = "C", -- Command-line
|
||||||
|
["cv"] = "EX", -- Vim Ex mode
|
||||||
|
["ce"] = "EX", -- Normal Ex mode
|
||||||
|
["r"] = "P", -- Prompt
|
||||||
|
["rm"] = "M", -- More prompt
|
||||||
|
["r?"] = "C", -- Confirm
|
||||||
|
["!"] = "S", -- Shell
|
||||||
|
["t"] = "T", -- Terminal
|
||||||
|
}
|
||||||
|
|
||||||
|
local current_mode = vim.api.nvim_get_mode().mode
|
||||||
|
return mode_map[current_mode] or current_mode
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Function to get Catppuccin color for the current mode
|
||||||
|
-- Returns the appropriate color from the ctp palette based on current mode
|
||||||
|
-- Assumes that a local 'ctp' variable has already been defined
|
||||||
|
-- Usage example: local mode_color = get_mode_color()
|
||||||
|
local function get_mode_color()
|
||||||
|
local mode_colors = {
|
||||||
|
-- Normal mode - Blue
|
||||||
|
["n"] = ctp.blue,
|
||||||
|
["no"] = ctp.blue,
|
||||||
|
["nov"] = ctp.blue,
|
||||||
|
["noV"] = ctp.blue,
|
||||||
|
["no\22"] = ctp.blue,
|
||||||
|
["niI"] = ctp.green,
|
||||||
|
["niR"] = ctp.green,
|
||||||
|
["niV"] = ctp.green,
|
||||||
|
["nt"] = ctp.blue,
|
||||||
|
|
||||||
|
-- Visual modes - Mauve (purple)
|
||||||
|
["v"] = ctp.mauve,
|
||||||
|
["vs"] = ctp.mauve,
|
||||||
|
["V"] = ctp.mauve,
|
||||||
|
["Vs"] = ctp.mauve,
|
||||||
|
["\22"] = ctp.mauve,
|
||||||
|
["\22s"] = ctp.mauve,
|
||||||
|
|
||||||
|
-- Select modes - Peach
|
||||||
|
["s"] = ctp.peach,
|
||||||
|
["S"] = ctp.peach,
|
||||||
|
["\19"] = ctp.peach,
|
||||||
|
|
||||||
|
-- Insert mode - Green
|
||||||
|
["i"] = ctp.green,
|
||||||
|
["ic"] = ctp.green,
|
||||||
|
["ix"] = ctp.green,
|
||||||
|
|
||||||
|
-- Replace modes - Red
|
||||||
|
["R"] = ctp.red,
|
||||||
|
["Rc"] = ctp.red,
|
||||||
|
["Rx"] = ctp.red,
|
||||||
|
["Rv"] = ctp.red,
|
||||||
|
["Rvc"] = ctp.red,
|
||||||
|
["Rvx"] = ctp.red,
|
||||||
|
|
||||||
|
-- Command/Prompt modes - Yellow
|
||||||
|
["c"] = ctp.yellow,
|
||||||
|
["cv"] = ctp.yellow,
|
||||||
|
["ce"] = ctp.yellow,
|
||||||
|
["r"] = ctp.yellow,
|
||||||
|
["rm"] = ctp.yellow,
|
||||||
|
["r?"] = ctp.yellow,
|
||||||
|
|
||||||
|
-- Terminal mode - Teal
|
||||||
|
["t"] = ctp.teal,
|
||||||
|
|
||||||
|
-- Shell mode - Sapphire
|
||||||
|
["!"] = ctp.sapphire,
|
||||||
|
}
|
||||||
|
|
||||||
|
local current_mode = vim.api.nvim_get_mode().mode
|
||||||
|
return mode_colors[current_mode] or ctp.subtext0 -- Default to a neutral color if mode not found
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Inserts a component in lualine_c at left section
|
||||||
|
local function ins_left(component)
|
||||||
|
table.insert(config.sections.lualine_c, component)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Inserts a component in lualine_x at right section
|
||||||
|
local function ins_right(component)
|
||||||
|
table.insert(config.sections.lualine_x, component)
|
||||||
|
end
|
||||||
|
|
||||||
|
ins_left({
|
||||||
|
function()
|
||||||
|
return get_mode_abbr()
|
||||||
|
end,
|
||||||
|
color = function()
|
||||||
|
local color = get_mode_color()
|
||||||
|
return { fg = ctp.base, bg = color, gui = "bold" }
|
||||||
|
end, -- Sets highlighting of component
|
||||||
|
padding = { left = 1, right = 1 }, -- We don't need space before this
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_left({
|
||||||
|
"filename",
|
||||||
|
cond = conditions.buffer_not_empty,
|
||||||
|
color = { fg = ctp.sapphire },
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_left({
|
||||||
|
-- filesize component
|
||||||
|
"filesize",
|
||||||
|
cond = conditions.buffer_not_empty,
|
||||||
|
color = { fg = ctp.subtext0 },
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_left({ "location", color = { fg = ctp.subtext0 } })
|
||||||
|
|
||||||
|
ins_left({
|
||||||
|
"diagnostics",
|
||||||
|
sources = { "nvim_diagnostic" },
|
||||||
|
symbols = { error = " ", warn = " ", info = " " },
|
||||||
|
diagnostics_color = {
|
||||||
|
error = { fg = ctp.red },
|
||||||
|
warn = { fg = ctp.yellow },
|
||||||
|
info = { fg = ctp.teal },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Insert mid section. You can make any number of sections in neovim :)
|
||||||
|
-- for lualine it's any number greater then 2
|
||||||
|
ins_left({
|
||||||
|
function()
|
||||||
|
return "%="
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_right({
|
||||||
|
-- Lsp server name .
|
||||||
|
function()
|
||||||
|
local msg = "none"
|
||||||
|
local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 })
|
||||||
|
local clients = vim.lsp.get_clients()
|
||||||
|
if next(clients) == nil then
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
for _, client in ipairs(clients) do
|
||||||
|
local filetypes = client.config.filetypes
|
||||||
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||||
|
return client.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return msg
|
||||||
|
end,
|
||||||
|
icon = "",
|
||||||
|
color = { fg = ctp.overlay1, gui = "bold" },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Add components to right sections
|
||||||
|
ins_right({
|
||||||
|
"branch",
|
||||||
|
icon = "",
|
||||||
|
color = { fg = ctp.mauve, gui = "bold" },
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_right({
|
||||||
|
"diff",
|
||||||
|
-- Is it me or the symbol for modified us really weird
|
||||||
|
symbols = { added = " ", modified = " ", removed = " " },
|
||||||
|
diff_color = {
|
||||||
|
added = { fg = ctp.green },
|
||||||
|
modified = { fg = ctp.peach },
|
||||||
|
removed = { fg = ctp.red },
|
||||||
|
},
|
||||||
|
cond = conditions.hide_in_width,
|
||||||
|
})
|
||||||
|
|
||||||
|
ins_right({
|
||||||
|
function()
|
||||||
|
return "▊"
|
||||||
|
end,
|
||||||
|
color = function()
|
||||||
|
local color = get_mode_color()
|
||||||
|
return { fg = color }
|
||||||
|
end, -- Sets highlighting of component
|
||||||
|
padding = { left = 1 },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Now don't forget to initialize lualine
|
||||||
|
lualine.setup(config)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.greetd = {
|
services.greetd = {
|
||||||
enable = false;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
default_session = {
|
default_session = {
|
||||||
command = "niri-session";
|
command = "niri-session";
|
||||||
|
|
@ -25,7 +25,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.xserver.displayManager.gdm.enable = true;
|
services.xserver.displayManager.gdm.enable = false;
|
||||||
services.xserver.displayManager.gdm.wayland = true;
|
services.xserver.displayManager.gdm.wayland = true;
|
||||||
|
|
||||||
# services.displayManager.sddm.enable = true;
|
# services.displayManager.sddm.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -34,98 +34,25 @@ in {
|
||||||
{
|
{
|
||||||
set = "Custom";
|
set = "Custom";
|
||||||
privateBuildPlan = ''
|
privateBuildPlan = ''
|
||||||
# [buildPlans.IosevkaCustom]
|
|
||||||
# family = "Iosevka"
|
|
||||||
# spacing = "fontconfig-mono"
|
|
||||||
# serifs = "sans"
|
|
||||||
# noCvSs = true
|
|
||||||
# exportGlyphNames = true
|
|
||||||
#
|
|
||||||
# [buildPlans.IosevkaCustom.variants]
|
|
||||||
# inherits = "ss08"
|
|
||||||
#
|
|
||||||
# [buildPlans.IosevkaCustom.widths.Normal]
|
|
||||||
# shape = 500
|
|
||||||
# menu = 5
|
|
||||||
# css = "normal"
|
|
||||||
#
|
|
||||||
# [buildPlans.IosevkaCustom.widths.Extended]
|
|
||||||
# shape = 600
|
|
||||||
# menu = 7
|
|
||||||
# css = "expanded"
|
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom]
|
[buildPlans.IosevkaCustom]
|
||||||
family = "Iosevka"
|
family = "Iosevka"
|
||||||
spacing = "normal"
|
spacing = "fontconfig-mono"
|
||||||
serifs = "sans"
|
serifs = "sans"
|
||||||
noCvSs = true
|
noCvSs = true
|
||||||
exportGlyphNames = true
|
exportGlyphNames = true
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom.variants.design]
|
[buildPlans.IosevkaCustom.variants]
|
||||||
one = "base-flat-top-serif"
|
inherits = "ss08"
|
||||||
two = "straight-neck-serifless"
|
|
||||||
four = "closed-serifless"
|
|
||||||
five = "oblique-arched-serifless"
|
|
||||||
six = "closed-contour"
|
|
||||||
seven = "bend-serifless"
|
|
||||||
eight = "crossing-asymmetric"
|
|
||||||
nine = "closed-contour"
|
|
||||||
zero = "oval-dotted"
|
|
||||||
capital-d = "more-rounded-serifless"
|
|
||||||
capital-g = "toothless-corner-serifless-hooked"
|
|
||||||
a = "double-storey-serifless"
|
|
||||||
g = "double-storey"
|
|
||||||
i = "hooky"
|
|
||||||
l = "serifed-semi-tailed"
|
|
||||||
r = "hookless-serifless"
|
|
||||||
t = "bent-hook-short-neck"
|
|
||||||
w = "straight-flat-top-serifless"
|
|
||||||
y = "straight-turn-serifless"
|
|
||||||
capital-eszet = "rounded-serifless"
|
|
||||||
long-s = "bent-hook-middle-serifed"
|
|
||||||
eszet = "longs-s-lig-serifless"
|
|
||||||
lower-lambda = "straight-turn"
|
|
||||||
lower-tau = "short-tailed"
|
|
||||||
lower-phi = "straight"
|
|
||||||
partial-derivative = "closed-contour"
|
|
||||||
cyrl-capital-u = "straight-turn-serifless"
|
|
||||||
cyrl-u = "straight-turn-serifless"
|
|
||||||
cyrl-ef = "split-serifless"
|
|
||||||
asterisk = "penta-low"
|
|
||||||
caret = "high"
|
|
||||||
guillemet = "straight"
|
|
||||||
number-sign = "slanted"
|
|
||||||
dollar = "open"
|
|
||||||
cent = "through-cap"
|
|
||||||
bar = "force-upright"
|
|
||||||
micro-sign = "tailed-serifless"
|
|
||||||
lig-ltgteq = "slanted"
|
|
||||||
lig-neq = "more-slanted-dotted"
|
|
||||||
lig-equal-chain = "without-notch"
|
|
||||||
lig-hyphen-chain = "without-notch"
|
|
||||||
lig-plus-chain = "with-notch"
|
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom.weights.Regular]
|
[buildPlans.IosevkaCustom.widths.Normal]
|
||||||
shape = 400
|
shape = 500
|
||||||
menu = 400
|
menu = 5
|
||||||
css = 400
|
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom.weights.Bold]
|
|
||||||
shape = 700
|
|
||||||
menu = 700
|
|
||||||
css = 700
|
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom.slopes.Upright]
|
|
||||||
angle = 0
|
|
||||||
shape = "upright"
|
|
||||||
menu = "upright"
|
|
||||||
css = "normal"
|
css = "normal"
|
||||||
|
|
||||||
[buildPlans.IosevkaCustom.slopes.Italic]
|
[buildPlans.IosevkaCustom.widths.Extended]
|
||||||
angle = 9.4
|
shape = 600
|
||||||
shape = "italic"
|
menu = 7
|
||||||
menu = "italic"
|
css = "expanded"
|
||||||
css = "italic"
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
noto-fonts
|
noto-fonts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue