1
0
Fork 0
mirror of https://git.madhouse-project.org/actions/nix.git synced 2024-11-23 20:19:16 +01:00

README: More docs!

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2023-09-22 23:36:12 +02:00
parent 9cdda9ed9f
commit 3cac748ae0

View file

@ -10,7 +10,17 @@ This repository provides a number of [Forgejo Actions][forgejo:action], all aime
[forgejo:action]: https://forgejo.org/docs/latest/user/actions/
## `actions/nix/install`
All of these actions assume that Nix is used with Flakes.
## actions/nix/install
The `actions/nix/install` action's job is to install Nix on the host it is running on. It needs to be running as root.
The reason why it exists, and why I am not using Cachix's [install-nix-action][gh:cachix/install-nix-action] is because that requires `sudo`, even when running as root, and my base images do not have sudo - they run as root. At least for now.
[gh:cachix/install-nix-action]: https://github.com/cachix/install-nix-action
Once I tweak my images to not run as root, I still don't want to set them up with sudo, but with `doas` - but for `install-nix-action`, that won't matter, because I can just add an `alias sudo=doas`, and it will work fine. At that point, this action will likely become obsolete.
### Usage
@ -21,7 +31,9 @@ This repository provides a number of [Forgejo Actions][forgejo:action], all aime
install-url: "https://nixos.org/nix/install"
```
## `actions/nix/build`
## 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
@ -34,7 +46,13 @@ This repository provides a number of [Forgejo Actions][forgejo:action], all aime
logs: false
```
## `actions/nix/develop`
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
@ -48,9 +66,11 @@ This repository provides a number of [Forgejo Actions][forgejo:action], all aime
# 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`.
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`
## 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