Skip to content

Skeleton for a project using nix and direnv for dependency management.

License

Notifications You must be signed in to change notification settings

hearnden/nix-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nix-project

This repo is a skeleton layout for a project using:

  • Nix for dependency management, and
  • Direnv for provisioning a shell CLI environment.

Clone it, amend this README, and update the packages in shell.nix.

Notes

This skeleton does not yet use Flakes.

One of Nix's goals is to be a tool for reproducible environments. Every other reproducible-environment tool uses lock files (e.g., yarn.lock, maven_install.json, ...). Flakes are an upcoming feature, 20 years after Nix's initial release, to make Nix use lockfiles.

Once Flakes are ready, they will be the right way to use Nix.

Setup

This project requires nix to be globally installed.

It also requires direnv, to be globally installed, which can be done through Nix.

Once both are installed, direnv allow on this project directory will take care of everything else.

Nix

Install nix.

Platform Command
MacOS sh <(curl -L https://nixos.org/nix/install)
Linux sh <(curl -L https://nixos.org/nix/install) --daemon
Windows (WSL) sh <(curl -L https://nixos.org/nix/install) --no-daemon

direnv

Install direnv and nix-direnv.

nix-env -iA nixpkgs.direnv
nix-env -iA nixpkgs.nix-direnv

Hook direnv into your shell.

Shell Command
Bash echo 'if hash direnv; then eval "$(direnv hook bash)"; fi' >>~/.bash_profile
Zsh echo 'if hash direnv; then eval "$(direnv hook zsh)"; fi' >>~/.zshrc

Project

After checking out this project, run:

direnv allow

This will execute .envrc (which will activate the nix-shell) when you cd into this project. The first time you do this, the dev environment will be downloaded and installed by nix.

About

Skeleton for a project using nix and direnv for dependency management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages