Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Nix build system #63

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/actions/build_nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build/Cache Nix
description: Builds default devShell for a platform, caching the results (if applicable)
inputs:
cachix_cache:
description: "The name of the Cachix cache to download to and/or upload from"
required: true
default: "openlane"
cachix_token:
description: "An authentication token for Cachix"
required: false
default: ""
shell:
description: "Shell to use"
required: true
default: "bash"
nix_system:
description: "The nix platform string to build for"
required: true
default: "x86_64-linux"
local_cache_key:
description: Key to use for the cache
required: false
default: ""
run_tests:
description: Whether to run unit tests and the smoke test
required: false
default: "false"
runs:
using: "composite"
steps:
- id: cache
name: Cache Derivation
uses: actions/cache@v3
with:
key: ${{ inputs.local_cache_key }}-${{ inputs.nix_system }}
path: /tmp/${{ inputs.local_cache_key }}
- id: Build
name: Build
shell: ${{ inputs.shell }}
run: |
substituters='https://${{ inputs.cachix_cache }}.cachix.org https://cache.nixos.org'
if [ '${{ inputs.local_cache_key }}' = '' ]; then
substituters="file:///tmp/${{ inputs.local_cache_key }} $substituters"
fi
echo "#################################################################"
outPath=$(nix build\
--print-out-paths\
--no-link\
--accept-flake-config\
--option system ${{ inputs.nix_system }}\
--extra-platforms ${{ inputs.nix_system }}\
--option substituters "$substituters"\
.#devShells.${{ inputs.nix_system }}.default)
echo "out-path=$outPath" >> $GITHUB_OUTPUT
sudo du -hs /nix/store/* | sort -h | tail -n 20
- name: Unit/Step Tests
shell: ${{ inputs.shell }}
if: inputs.run_tests == 'true'
run: echo TODO
- name: Smoke Test
shell: ${{ inputs.shell }}
if: inputs.run_tests == 'true'
run: |
echo "#################################################################"
nix run\
--option system ${{ inputs.nix_system }}\
--extra-platforms ${{ inputs.nix_system }}\
--accept-flake-config\
.#packages.${{ inputs.nix_system }}.cace -- --help
- name: Push to local cache
shell: ${{ inputs.shell }}
if: inputs.local_cache_key != '' && steps.cache.outputs.cache-hit != 'true'
run: |
nix copy\
--to 'file:///tmp/${{ inputs.local_cache_key }}?compression=zstd&parallel-compression=true'\
${{ steps.build.outputs.out-path }}
- name: Install + Push to Cachix
shell: ${{ inputs.shell }}
if: ${{ inputs.cachix_token != '' }}
run: |
echo "#################################################################"
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix authtoken ${{ inputs.cachix_token }}
cachix push ${{ inputs.cachix_cache }} ${{ steps.build.outputs.out-path }}
22 changes: 22 additions & 0 deletions .github/actions/check_space/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check Space
description: Reusable step that prints disk usage information
runs:
using: "composite"
steps:
- name: Check Space
shell: bash
run: |
if test -d /nix/store; then
sudo du -hs /nix/store/* | sort -h | tail -n 10
fi
echo ===============
df -h
echo ===============
du -hs ~/* | sort -h
echo ===============
du -hs * | sort -h
echo ===============
du -hs /home/runner/runners/* | sort -h
echo ===============
du -hs /home/runner/work/* | sort -h
echo ===============
28 changes: 28 additions & 0 deletions .github/actions/setup_env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Set up environment
description: Sets up a number of environment variables that are useful for publishing
runs:
using: "composite"
steps:
- name: Export Repo URL
shell: bash
run: echo "REPO_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV

- name: Export Branch Name
shell: bash
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Set default for env.NEW_TAG
shell: bash
run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV

- name: Check for new version
if: ${{ github.event_name == 'push' && env.BRANCH_NAME == 'main' }}
shell: bash
run: |
python3 ./.github/scripts/generate_tag.py

- name: Publish
if: ${{ github.event_name == 'push' && env.BRANCH_NAME == 'main' && env.NEW_TAG != 'NO_NEW_TAG' }}
shell: bash
run: |
echo "PUBLISH=1" >> $GITHUB_ENV
Loading
Loading