Run any command you like in a deterministic Nix shell on Linux and macOS.
Create shell.nix
in your repo, for example
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
nativeBuildInputs = with pkgs; [ which nodejs python39 perl ];
}
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@v14.1
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: ZenithalHourlyRate/nix-shell-action@v4
with:
script: |
which node
- uses: ZenithalHourlyRate/nix-shell-action@v4
with:
interpreter: python3
script: |
print("hello world from python")
- uses: ZenithalHourlyRate/nix-shell-action@v4
with:
interpreter: perl
file: shell.nix
script: |
use warnings;
print("Hello, World! from perl\n");
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-shell -i
) -
file
: nix-shell file, Defaults toshell.nix
. -
script
: The actual script to execute in your shell. Will be passed to theinterpreter
.
See https://github.com/actions/typescript-action