Skip to content

Commit

Permalink
[all] remove nix
Browse files Browse the repository at this point in the history
When this works, it's slow; when it doesn't work, I can't figure out how to fix it ;(
  • Loading branch information
shish committed Sep 28, 2023
1 parent 053b4e7 commit effc157
Show file tree
Hide file tree
Showing 39 changed files with 2 additions and 1,403 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

103 changes: 0 additions & 103 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,106 +106,3 @@ jobs:
- name: Benchmark Test
shell: bash
run: ./all.py bench ${{ inputs.workdir }} --default --frames 10

nix:
name: Nix
runs-on: ubuntu-22.04
if: ${{ !contains(github.event.head_commit.message, '[skip nix]') }}
outputs:
flake_status: ${{ steps.early.outputs.flake_status }}
shell_status: ${{ steps.early.outputs.shell_status }}
steps:
- name: Checkout
uses: actions/checkout@v3
- id: early
name: Check if nix files exist
shell: bash
working-directory: ${{ inputs.workdir }}
run: |
flake_status="skip"
if [ -f "derivation.nix" ]; then
flake_status="found"
fi
echo "flake_status=${flake_status}" >> "${GITHUB_OUTPUT}"
shell_status="skip"
if [ -f "shell.nix" ]; then
shell_status="found"
fi
echo "shell_status=${shell_status}" >> "${GITHUB_OUTPUT}"
nix-flake:
name: Nix Flake
runs-on: ubuntu-22.04
needs: nix
if: ${{ !contains(github.event.head_commit.message, '[skip nix flake]') && needs.nix.outputs.flake_status == 'found' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set Up Build Cache
uses: actions/cache@v3
id: nix-cache
with:
path: /tmp/nix-store.nar
key: ${{ runner.os }}-${{ inputs.workdir }}-nix-store.nar-${{ hashFiles('flake.nix', 'flake.lock', format('{0}/derivation.nix', inputs.workdir)) }}
restore-keys: ${{ runner.os }}-${{ inputs.workdir }}-nix-store.nar-
- name: Install Deps
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-22.11
# see: https://github.com/cachix/install-nix-action/issues/56#issuecomment-1300421537
- name: "Import Nix Store Cache"
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: "nix-store --import < /tmp/nix-store.nar"
- name: Flake Build
shell: bash
run: |
nix eval .#packages --impure --raw \
--apply '(import ./utils/get-builds-for-lang.nix { lang = "${{ inputs.workdir }}"; attr = "packages"; })' \
| xargs nix build -L
- name: Flake Run
shell: bash
run: |
nix eval .#packages --impure --raw \
--apply '(import ./utils/get-builds-for-lang.nix { lang = "${{ inputs.workdir }}"; prefix = ".#"; })' \
| xargs -I{} nix run {} -- --help
- name: Flake Shell
shell: bash
working-directory: ${{ inputs.workdir }}
run: nix develop ..#${{ inputs.workdir }} --command bash -c './build.sh && ./rosettaboy-release --help'
- name: Flake Checks
shell: bash
run: |
nix eval .#checks --impure --raw \
--apply '(import ./utils/get-builds-for-lang.nix { lang = "${{ inputs.workdir }}"; attr = "checks"; })' \
| xargs nix build -L
- name: "Export Nix Store Cache"
shell: bash
# we could add devShells here but it might fill the cache fast...
run: |
nix eval .#packages --impure --raw \
--apply '(import ./utils/get-builds-for-lang.nix { lang = "${{ inputs.workdir }}"; attr = "packages"; })' \
| xargs -I{} bash -c "nix eval --raw {}; echo" \
| xargs nix-store -qR \
| xargs nix-store --export > /tmp/nix-store.nar
nix-shell:
name: Nix Shell
runs-on: ubuntu-22.04
needs: nix
if: ${{ !contains(github.event.head_commit.message, '[skip nix flake]') && needs.nix.outputs.shell_status == 'found' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Nix
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-22.11
- name: Run Shell
shell: bash
working-directory: ${{ inputs.workdir }}
run: nix-shell --pure --run './build.sh && ./rosettaboy-release --help'
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ that the user has the standard language dev kits installed (eg we assume
anyone who wants to work on the Rust version will have Cargo installed;
anyone who wants to work on Python will have virtualenv + pip; etc)

If you have either Nix or Docker available, you can run `./utils/shell.sh` to create and run an environment with all necessary dev tools pre-installed. — `./build.sh && ./rosettaboy-release --headless --silent` should be able to pass tests for all languages.

If you prefer Docker, you can use `./utils/shell-docker.sh` instead.

If you prefer Nix, you can manually run `nix develop` or `nix-shell` instead. When run with an implementation as an argument, e.g. `nix develop .#py`, it will only provide what is needed for that language, and when run in the project root it will provide everything needed for all languages. Alternatively, there is also an integration with [nix-direnv](https://github.com/nix-community/nix-direnv).
If you have Docker available, you can run `./utils/shell.sh` to create and run an environment with all necessary dev tools pre-installed. — `./build.sh && ./rosettaboy-release --headless --silent` should be able to pass tests for all languages.


Benchmarks
Expand Down
1 change: 0 additions & 1 deletion c/.envrc

This file was deleted.

44 changes: 0 additions & 44 deletions c/derivation.nix

This file was deleted.

1 change: 0 additions & 1 deletion cpp/.envrc

This file was deleted.

41 changes: 0 additions & 41 deletions cpp/derivation.nix

This file was deleted.

10 changes: 0 additions & 10 deletions cpp/shell.nix

This file was deleted.

10 changes: 0 additions & 10 deletions default.nix

This file was deleted.

Loading

0 comments on commit effc157

Please sign in to comment.