Run any command you like in a deterministic Nix shell on Linux and macOS.
Create .github/workflows/test.yml
in your repo with the following contents:
name: "Test"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v10
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: workflow/nix-shell-action@v1
with:
packages: hello,docker
script: |
hello
docker --help
You can also pass in environment variables:
- uses: workflow/nix-shell-action@v1
env:
TRANSFORMER: bumblecat
with:
packages: hello,docker
script: |
hello $TRANSFORMER
docker --help
For now, this action implicitly depends on having Nix installed and set up correctly, such as through the install-nix-action demonstrated in the examples above.
See also cachix-action for a simple binary cache setup to speed up your builds and share binaries with developers.
-
interpreter
: Interpreter to use in the nix shell shebang, defaults tobash
. (This is passed tonix run -c
, used to be-i
in a nix shell shebang) -
packages
: Comma-separated list of packages to pre-install in your shell. Defaults to justbash
-
script
: The actual script to execute in your shell. Will be passed to theinterpreter
, which defaults tobash