Skip to content

Run any command you like in a deterministic Nix shell on Linux and macOS.

License

Notifications You must be signed in to change notification settings

ZenithalHourlyRate/nix-shell-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Repository files navigation

nix-shell-action

nix-shell-action status

Run any command you like in a deterministic Nix shell on Linux and macOS.

Usage

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.

Options with: ...

  • interpreter: Interpreter to use in the nix shell shebang, defaults to bash. (This is passed to nix-shell -i)

  • file: nix-shell file, Defaults to shell.nix.

  • script: The actual script to execute in your shell. Will be passed to the interpreter.


Hacking

See https://github.com/actions/typescript-action

About

Run any command you like in a deterministic Nix shell on Linux and macOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 71.8%
  • Nix 15.1%
  • JavaScript 13.1%