Code Monkey home page Code Monkey logo

vhs's Introduction

VHS ❤ Nix

Nix Flakes Ready Built With Snowfall Powered By VHS

  

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 set sandbox = relaxed in your nix.conf file.

Usage

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

Library

vhs.lib.mkRecorder

Create a VHS recorder.

Type: Attrs -> Attrs

Usage:

mkRecorder pkgs

Result:

{ record = attrs: {/* ... */}; }

Recorder.record

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

vhs's People

Contributors

jakehamilton avatar

Stargazers

Settuba avatar Terje Larsen avatar vi|vi|vi avatar  avatar Joe Fredette avatar Sufyan Dahalan avatar Sandro avatar Javed Khan avatar Brian McGee avatar Steven Kalt avatar Christian Rocha avatar Toby Padilla avatar  avatar

Watchers

 avatar  avatar

Forkers

fvkd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.