https://github.com/snowfallorg/vhs
Render VHS tapes with Nix.
https://github.com/snowfallorg/vhs
Last synced: about 1 year ago
JSON representation
Render VHS tapes with Nix.
- Host: GitHub
- URL: https://github.com/snowfallorg/vhs
- Owner: snowfallorg
- License: other
- Created: 2022-11-29T16:47:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-25T03:21:31.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T12:11:11.524Z (over 1 year ago)
- Language: Nix
- Size: 17.6 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# VHS ❤ Nix
This flake provides a helper utility to render [VHS](https://github.com/charmbracelet/vhs)
tapes with Nix.
> **Warning**
>
> Rendering VHS tapes in Nix requires a relaxed or disabled sandbox. Either run `nix build`
> with the flag `--no-sandbox` or set `sandbox = relaxed` in your `nix.conf` file.
## Usage
First, include this flake as an input in your flake.
```nix
{
description = "My awesome flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# Snowfall Lib is not required, but will make configuration easier for you.
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
vhs = {
url = "github:snowfallorg/vhs";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}
```
Next, write a VHS tape.
```tape
Output sample.mp4
Output sample.gif
Type "# Hello World" Enter Enter
Sleep 1
Type "# This is built in Nix!"
Sleep 2
```
Then, use this flake's library to render your VHS tape.
```nix
{
description = "My awesome flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# Snowfall Lib is not required, but will make configuration easier for you.
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
vhs = {
url = "github:snowfallorg/vhs";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
inputs.snowfall-lib.mkFlake {
inherit inputs;
src = ./.;
outputs-builder = channels:
let
recorder = inputs.vhs.lib.mkRecorder channels.nixpkgs;
in {
packages.default = recorder.record {
tape = ./example.tape;
};
};
};
}
```
Finally, run the build!
```bash
# If you have a relaxed sandbox set in your nix.conf file.
nix build .#
# Otherwise you can build this package without a sandbox.
nix build .# --no-sandbox
```
## Library
### `vhs.lib.mkRecorder`
Create a VHS recorder.
Type: `Attrs -> Attrs`
Usage:
```nix
mkRecorder pkgs
```
Result:
```
{ record = attrs: {/* ... */}; }
```
#### `Recorder.record`
Create a recording from a tape.
Type: `{ tape, buildInputs, files } -> Derivation`
Usage:
```nix
recorder.record {
# You can use a tape file
# tape = ./example.tape;
#
# Or you can supply its contents as a string!
tape = ''
Output sample.mp4
Output sample.gif
Type "hello" Enter
Sleep 2
Type "cat ./example.txt" Enter
Sleep 2
'';
# Add packages to use in your recording.
buildInputs = [ pkgs.hello ];
# Recordings are done in a temporary directory, so any files
# you want to use in your recording must be specified here.
files = [
./example.txt
];
# Configuration for the Bash shell.
bashrc = ''
export GUM_INPUT_PROMPT="What's up?"
'';
}
```
Result:
```
Derivation
```