This flake provides a helper utility to render 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 setsandbox = relaxed
in yournix.conf
file.
First, include this flake as an input in your flake.
{
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.
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.
{
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!
# 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
Create a VHS recorder.
Type: Attrs -> Attrs
Usage:
mkRecorder pkgs
Result:
{ record = attrs: {/* ... */}; }
Create a recording from a tape.
Type: { tape, buildInputs, files } -> Derivation
Usage:
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