Tar entire build environment

This commit is contained in:
Tom Foster 2024-04-22 23:06:31 +01:00 committed by GitHub
parent f90136c9a3
commit b649ed3727
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,20 +61,15 @@ jobs:
- name: Populate `/nix/store` - name: Populate `/nix/store`
run: nix develop --command true run: nix develop --command true
- name: Package `/nix/store` for Artifact - name: Package build environment for Artifact
run: | run: |
tar -czf nix-store.tar.gz /nix/store sudo tar -czf environment.tar.gz /nix/store ~/.cargo /etc/nix/nix.conf $HOME/.direnvrc
# Store the build environment in an artifact - name: Store build environment
- name: Cache build environment
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: build-environment name: build-environment
path: | path: environment.tar.gz
nix-store.tar.gz
~/.cargo
$HOME/.direnvrc
/etc/nix/nix.conf
build_and_package: build_and_package:
needs: setup needs: setup
@ -92,31 +87,20 @@ jobs:
] ]
steps: steps:
- name: Download Build Environment - name: Download build environment
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: build-environment name: build-environment
- name: Extract Nix Store Archive - name: Extract build environment
run: | run: |
mkdir -p ${{ github.workspace }}/nix-store tar -xzf nix-store.tar.gz -C /
tar -xzf nix-store.tar.gz -C ${{ github.workspace }}/nix-store
- name: Move Nix Store to Proper Location
run: |
sudo rsync -a ${{ github.workspace }}/nix-store/ /nix/store/
sudo chown -R root:root /nix/store
sudo restorecon -Rv /nix/store # If SELinux is enforcing
- name: Sync repository - name: Sync repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Reuse Build Environment - name: Reuse build environment
run: | run: |
# Ensure the nix configuration is correct
sudo cp -R /etc/nix/nix.conf /etc/nix/nix.conf.bak
sudo cp -R nix.conf /etc/nix/nix.conf
# Source direnv
source $HOME/.direnvrc source $HOME/.direnvrc
direnv allow direnv allow