common forgejo actions for nix
  • Shell 50.3%
  • Nix 49.7%
Find a file
Gergely Nagy 7217732a1e
Some checks failed
test nix/shell / nix/shell (push) Has been cancelled
Shellcheck / shellcheck (push) Has been cancelled
shell: Don't symlink, source
2026-06-16 11:23:11 +02:00
.forgejo/workflows Remove the nix/install action 2026-06-15 13:41:27 +02:00
build tests: Update the test flakes to NixOS 26.05 2026-06-15 13:38:26 +02:00
develop tests: Update the test flakes to NixOS 26.05 2026-06-15 13:38:26 +02:00
shell shell: Don't symlink, source 2026-06-16 11:23:11 +02:00
.gitignore Add a .gitignore file 2023-09-22 20:06:37 +02:00
COPYING.md Initial import 2023-09-22 19:37:47 +02:00
README.md Remove the nix/install action 2026-06-15 13:41:27 +02:00

actions/nix

Build status

This repository provides a number of Forgejo Actions, all aimed at making it more pleasant to work with both Nix (either by running under NixOS, or using the Nix package manager on its own). The provided actions are listed below. All examples show the default inputs, unless otherwise specified. If the defaults are fine, those inputs can be safely omitted.

All of these actions assume that Nix is used with Flakes.

actions/nix/build

A thin wrapper around nix build, to make it slightly easier to build flakes. While it pretty much just wraps a single nix build invocation, I felt it more appropriate to have it in an action, because the actions/nix/develop and actions/nix/shell actions below do a fair bit more. Having this in an action makes my workflows prettier.

Usage

- name: Build a Nix package
  uses: actions/nix/build@main
  with:
    flake: .
    package: # there's no default, Nix itself will fall back to "default"
    logs: false
    out-link: "result"

By default, it builds the default package in the flake at the root of the repository the action is used for, thus, if all you want to do is build the default package, and don't care about seeing full logs, you do not need to specify any parameters, the action will do the right thing out of the box.

actions/nix/develop

Something I found myself do often, is run commands within a Nix development environment. This action makes that a whole lot nicer, because I don't have to call nix develop -c bash -c "<imagine many lines of shell code here>", I can make it look almost like a regular run property in a workflow!

The script simply puts the contents of run into a shell script, and runs that in a Nix development environment.

Usage

- name: Run something in a development environment
  uses: actions/nix/develop@main
  with:
    flake: .
    package: # no default, see above
    run: |
      # No default here, either!

The commands specified in the run input will be written to a shell script, and the shell script will be executed with bash -eo pipefail. Everything that is in the development environment, will be available for the script.

actions/nix/shell

Exactly the same as actions/nix/develop above, except it runs a shell with the given package available in it, rather than a development environment. Otherwise its behaviour is the same.

Usage

- name: Run something in a Nix shell
  uses: actions/nix/shell@main
  with:
    flake: .
    package: # no default, see above
    run: |
      # No default here, either!

The commands specified in the run input will be written to a shell script, and the shell script will be executed with bash -eo pipefail.