Build nur packages #134
This file contains 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: "Build nur packages" | |
on: | |
workflow_dispatch: | |
inputs: | |
groups: | |
description: Check groups to build | |
required: false | |
type: string | |
packages: | |
description: Packages to build | |
required: false | |
type: string | |
is_push: | |
description: Whether to Push cache | |
required: true | |
default: true | |
type: boolean | |
is_update_source: | |
description: Whether to update sources | |
required: true | |
default: true | |
type: boolean | |
workflow_call: | |
inputs: | |
groups: | |
description: Check groups to build | |
required: false | |
type: string | |
packages: | |
description: Packages to build | |
required: false | |
type: string | |
is_push: | |
description: Whether to Push cache | |
default: true | |
type: boolean | |
is_update_source: | |
description: Whether to update sources | |
default: false | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
NIXPKGS_ALLOW_UNFREE: 1 | |
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }} | |
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} | |
ATTIC_ACCESS_TOKEN: ${{ secrets.ATTIC_ACCESS_TOKEN }} | |
steps: | |
- name: 0-1. Maximize space | |
# https://github.com/Ninlives/emerge/blob/master/.github/workflows/os.yml#L15 | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/ghc | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
echo "Available space:" | |
df -h | |
- name: 0-2. Checkout repository | |
uses: actions/checkout@v3 | |
- name: 0-3. Install nix | |
uses: cachix/install-nix-action@v22 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
extra_nix_config: | | |
experimental-features = nix-command flakes repl-flake | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- name: 0-4. Setup Attic | |
run: | | |
# curl -LO https://raw.githubusercontent.com/zhaofengli/attic/main/.github/install-attic-ci.sh | |
curl -LO https://raw.githubusercontent.com/icewind1991/attic-action/master/dist/main/install-attic-ci.sh | |
bash install-attic-ci.sh | |
# https://github.com/zhaofengli/attic/blob/main/.github/workflows/build.yml#L30 | |
export PATH=$HOME/.nix-profile/bin:$PATH | |
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_ACCESS_TOKEN" | |
attic use "$ATTIC_CACHE" | |
- name: 1-1. Update package sources | |
if: ${{ inputs.is_update_source == true }} | |
run: nix run .#update --impure | |
- name: 1-2. Show flake metadata | |
if: ${{ always() }} | |
run: nix flake metadata --impure | |
- name: 1-3. Show flake information | |
if: ${{ always() }} | |
run: nix flake show --impure | |
- name: 1-4. Check evaluation | |
if: ${{ always() }} | |
run: nix flake check --no-build --no-allow-import-from-derivation --impure | |
- name: 2-1. Build nix packages | |
if: ${{ inputs.packages != 0 }} | |
env: | |
PACKAGE_NAMES: ${{ inputs.packages }} | |
run: | | |
PKGS=($PACKAGE_NAMES) | |
for pkg in ${PKGS[*]}; do | |
echo -e " \e[32m== Package ==>> $pkg\e[0m" | |
nix build .#$pkg --impure -v | |
[[ $? == 0 ]] && echo -en " \e[32m" || echo -en " \e[31m" | |
echo -e "<<== Package ==\e[0m" | |
done | |
- name: 2-2. Build nix check groups | |
if: ${{ inputs.groups != 0 }} | |
env: | |
GROUP_NAMES: ${{ inputs.groups }} | |
run: | | |
bash ./.github/build_bundle.sh | |
- name: 2-3. Build entire nurpkgs | |
if: ${{ inputs.groups == 0 && inputs.packages == 0 }} | |
run: nix flake check --no-allow-import-from-derivation --impure -v | |
- name: 3-1. Upload package sources | |
if: ${{ inputs.is_update_source == true }} | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Update: sources" | |
file_pattern: "pkgs/_sources" | |
- name: 3-2. Push cache to Attic | |
if: ${{ inputs.is_push == true }} | |
env: | |
CI_MODE: 1 | |
run: | | |
bash ./.github/push_cache.sh -g ${{ inputs.groups }} -p ${{ inputs.packages }} |