Merge pull request #3 from FinnPL/quickshell #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Test NixOS Configuration" | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| basic-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v25 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare /usr/share/wallpaper and update flake.lock hash/timestamp | |
| run: | | |
| sudo mkdir -p /usr/share/wallpaper | |
| echo "dummy" | sudo tee /usr/share/wallpaper/dummy.jpg | |
| HASH=$(nix hash path /usr/share/wallpaper) | |
| NOW=$(stat -c %Y /usr/share/wallpaper) | |
| echo "Updating wallpapers block: lastModified=$NOW, narHash=$HASH" | |
| # Extract wallpapers block | |
| sed -n '/"wallpapers": {/,/^ },$/p' flake.lock > wallpapers_block.tmp | |
| # Update hash and timestamp | |
| sed -i '0,/"lastModified": [0-9]\+,/{s|"lastModified": [0-9]\+,|"lastModified": '"$NOW"',|}' wallpapers_block.tmp | |
| sed -i 's|"narHash": "[^"]*"|"narHash": "'"$HASH"'"|' wallpapers_block.tmp | |
| # Replace the block in flake.lock | |
| START=$(grep -n '"wallpapers": {' flake.lock | cut -d: -f1) | |
| END=$(awk -v start="$START" 'NR > start && /^ },/ {print NR; exit}' flake.lock) | |
| head -n $((START-1)) flake.lock > flake.lock.new | |
| cat wallpapers_block.tmp >> flake.lock.new | |
| tail -n +$((END+1)) flake.lock >> flake.lock.new | |
| mv flake.lock.new flake.lock | |
| rm wallpapers_block.tmp | |
| - name: Check flake syntax | |
| run: nix flake check --verbose | |
| - name: Evaluate NixOS configuration | |
| run: | | |
| nix eval .#nixosConfigurations.centaur.config.system.build.toplevel.drvPath \ | |
| --verbose | |
| - name: Check for common issues | |
| run: | | |
| echo "Checking for common configuration issues..." | |
| # Check if all imports exist | |
| echo "Verifying all imports are accessible..." | |
| nix eval .#nixosConfigurations.centaur.options --apply 'x: "imports-ok"' || echo "Import check failed" | |
| # Check if home-manager is properly configured | |
| echo "Checking home-manager integration..." | |
| nix eval .#nixosConfigurations.centaur.config.home-manager --apply 'x: "hm-ok"' || echo "Home-manager not configured" | |
| echo "Basic checks completed!" | |
| dry-build: | |
| runs-on: ubuntu-latest | |
| needs: basic-check | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v25 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare /usr/share/wallpaper and update flake.lock hash/timestamp | |
| run: | | |
| sudo mkdir -p /usr/share/wallpaper | |
| echo "dummy" | sudo tee /usr/share/wallpaper/dummy.jpg | |
| HASH=$(nix hash path /usr/share/wallpaper) | |
| NOW=$(stat -c %Y /usr/share/wallpaper) | |
| echo "Updating wallpapers block: lastModified=$NOW, narHash=$HASH" | |
| # Extract wallpapers block | |
| sed -n '/"wallpapers": {/,/^ },$/p' flake.lock > wallpapers_block.tmp | |
| # Update hash and timestamp | |
| sed -i '0,/"lastModified": [0-9]\+,/{s|"lastModified": [0-9]\+,|"lastModified": '"$NOW"',|}' wallpapers_block.tmp | |
| sed -i 's|"narHash": "[^"]*"|"narHash": "'"$HASH"'"|' wallpapers_block.tmp | |
| # Replace the block in flake.lock | |
| START=$(grep -n '"wallpapers": {' flake.lock | cut -d: -f1) | |
| END=$(awk -v start="$START" 'NR > start && /^ },/ {print NR; exit}' flake.lock) | |
| head -n $((START-1)) flake.lock > flake.lock.new | |
| cat wallpapers_block.tmp >> flake.lock.new | |
| tail -n +$((END+1)) flake.lock >> flake.lock.new | |
| mv flake.lock.new flake.lock | |
| rm wallpapers_block.tmp | |
| - name: Dry build NixOS configuration | |
| run: | | |
| nix build .#nixosConfigurations.centaur.config.system.build.toplevel \ | |
| --dry-run \ | |
| --verbose |