Convert Figma logo to code with AI

cachix logodevenv

Fast, Declarative, Reproducible, and Composable Developer Environments

4,034
302
4,034
320

Top Related Projects

A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]

Per project developer environments

12,081

Nix, the purely functional package manager

Quick Overview

Devenv is a powerful, declarative developer environment manager. It allows developers to create reproducible, project-specific development environments using Nix, without requiring deep knowledge of Nix itself. Devenv aims to simplify the process of setting up and managing development environments across different projects and team members.

Pros

  • Reproducible environments across different machines and team members
  • Declarative configuration using a simple YAML-like syntax
  • Integrates well with existing tools and workflows
  • Supports a wide range of languages and frameworks out of the box

Cons

  • Requires Nix to be installed on the system
  • Learning curve for those unfamiliar with declarative environment management
  • May have performance overhead compared to native system installations
  • Limited documentation for advanced use cases

Code Examples

  1. Basic Python environment:
{ pkgs, ... }:

{
  packages = [ pkgs.python3 pkgs.poetry ];

  enterShell = ''
    echo "Welcome to the Python development environment!"
  '';
}
  1. Node.js environment with specific version:
{ pkgs, ... }:

{
  packages = [
    pkgs.nodejs-16_x
    pkgs.yarn
  ];

  env.NODE_ENV = "development";
}
  1. Multi-language environment with PostgreSQL:
{ pkgs, ... }:

{
  packages = [
    pkgs.go
    pkgs.ruby
    pkgs.postgresql
  ];

  services.postgres.enable = true;

  env.DATABASE_URL = "postgresql://postgres@localhost:5432/myapp";
}

Getting Started

  1. Install Nix and enable flakes:

    sh <(curl -L https://nixos.org/nix/install) --daemon
    echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
    
  2. Install devenv:

    nix-env -if https://github.com/cachix/devenv/tarball/latest
    
  3. Create a devenv.nix file in your project root with your desired configuration.

  4. Run devenv init to generate a .envrc file for direnv integration.

  5. Enter the development environment:

    devenv shell
    

Competitor Comparisons

A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]

Pros of nix-direnv

  • Lightweight and focused on integrating Nix with direnv
  • Seamless integration with existing direnv workflows
  • Supports caching of Nix-shell environments for faster loading

Cons of nix-direnv

  • Limited to direnv functionality, less comprehensive development environment setup
  • Requires manual configuration of Nix expressions for project dependencies
  • Less user-friendly for those unfamiliar with Nix syntax

Code Comparison

nix-direnv:

use nix

devenv:

{ pkgs, ... }:
{
  packages = [ pkgs.hello ];
  enterShell = ''
    hello
  '';
}

Key Differences

  1. Scope: nix-direnv focuses on integrating Nix with direnv, while devenv provides a more comprehensive development environment solution.

  2. Configuration: nix-direnv requires manual Nix expression configuration, whereas devenv offers a higher-level abstraction for environment setup.

  3. Learning Curve: nix-direnv may be easier for users already familiar with direnv and Nix, while devenv aims to simplify the process for newcomers.

  4. Features: devenv includes additional features like process management and service integration, which are not present in nix-direnv.

  5. Flexibility: nix-direnv provides more flexibility in terms of Nix usage, while devenv offers a more opinionated and structured approach to development environments.

Per project developer environments

Pros of devshell

  • Lighter weight and more focused on shell environments
  • Easier to integrate with existing Nix projects
  • More flexible for customizing shell prompts and environment variables

Cons of devshell

  • Less comprehensive development environment management
  • Fewer built-in features for managing project dependencies
  • Limited support for non-Nix workflows

Code Comparison

devshell:

{ pkgs ? import <nixpkgs> {} }:
pkgs.devshell.mkShell {
  imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
}

devenv:

{ pkgs, ... }:
{
  packages = [ pkgs.hello ];
  languages.python.enable = true;
  processes.web.exec = "python -m http.server";
}

devshell focuses on creating customized shell environments, while devenv provides a more comprehensive development environment setup. devshell is better suited for projects already using Nix, offering flexibility in shell customization. devenv, on the other hand, offers a broader range of features for managing development environments, including language-specific tools and process management, making it more accessible for users less familiar with Nix.

12,081

Nix, the purely functional package manager

Pros of nix

  • More mature and established project with a larger community
  • Offers a complete package management and system configuration solution
  • Provides reproducible builds across different environments

Cons of nix

  • Steeper learning curve due to its unique approach and custom language
  • Can be complex to set up and configure for newcomers
  • Less focused on development environments specifically

Code Comparison

nix:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = [ pkgs.nodejs pkgs.yarn ];
}

devenv:

{ pkgs, ... }:
{
  packages = [ pkgs.nodejs pkgs.yarn ];
}

Key Differences

  • devenv focuses specifically on development environments, while nix is a more comprehensive system
  • devenv aims to simplify the configuration process compared to nix
  • nix offers more flexibility and power, but devenv provides a more streamlined experience for development setups

Use Cases

  • Choose nix for complete system management and complex build configurations
  • Opt for devenv when setting up isolated development environments quickly and easily

Community and Support

  • nix has a larger, more established community with extensive documentation
  • devenv is newer but growing, with a focus on user-friendly documentation and examples

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

devenv logo

devenv.sh - Fast, Declarative, Reproducible, and Composable Developer Environments

Built with Nix Discord channel License: Apache 2.0 Version CI

Running devenv init generates devenv.nix:

{ pkgs, ... }:

{
  # https://devenv.sh/basics/
  env.GREET = "devenv";

  # https://devenv.sh/packages/
  packages = [ pkgs.git ];

  enterShell = ''
    hello
  '';

  # https://devenv.sh/tests/
  enterTest = ''
    echo "Running tests"
    git --version | grep --color=auto "${pkgs.git.version}"
  '';

  # https://devenv.sh/languages/
  languages.nix.enable = true;

  # https://devenv.sh/scripts/
  scripts.hello.exec = "echo hello from $GREET";

  # https://devenv.sh/services/
  services.postgres.enable = true;

  # https://devenv.sh/pre-commit-hooks/
  pre-commit.hooks.shellcheck.enable = true;

  # https://devenv.sh/processes/
  processes.ping.exec = "ping localhost";
}

And devenv shell activates the environment.

Commands

$ devenv
https://devenv.sh 1.0.1: Fast, Declarative, Reproducible, and Composable Developer Environments

Usage: devenv [OPTIONS] <COMMAND>

Commands:
  init       Scaffold devenv.yaml, devenv.nix, .gitignore and .envrc.
  shell      Activate the developer environment. https://devenv.sh/basics/
  update     Update devenv.lock from devenv.yaml inputs. http://devenv.sh/inputs/
  search     Search for packages and options in nixpkgs. https://devenv.sh/packages/#searching-for-a-file
  info       Print information about this developer environment.
  up         Start processes in the foreground. https://devenv.sh/processes/
  processes  Start or stop processes.
  test       Run tests. http://devenv.sh/tests/
  container  Build, copy, or run a container. https://devenv.sh/containers/
  inputs     Add an input to devenv.yaml. https://devenv.sh/inputs/
  gc         Deletes previous shell generations. See http://devenv.sh/garbage-collection
  build      Build any attribute in devenv.nix.
  version    Print the version of devenv.
  help       Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose
          Enable debug log level.
  -j, --max-jobs <MAX_JOBS>
          Maximum number of Nix builds at any time. [default: 8]
  -j, --cores <CORES>
          Maximum number CPU cores being used by a single build.. [default: 2]
  -s, --system <SYSTEM>
          [default: x86_64-linux]
  -i, --impure
          Relax the hermeticity of the environment.
  -c, --clean [<CLEAN>...]
          Ignore existing environment variables when entering the shell. Pass a list of comma-separated environment variables to let through.
  -d, --nix-debugger
          Enter Nix debugger on failure.
  -n, --nix-option <NIX_OPTION> <NIX_OPTION>
          Pass additional options to nix commands, see `man nix.conf` for full list.
  -o, --override-input <OVERRIDE_INPUT> <OVERRIDE_INPUT>
          Override inputs in devenv.yaml.
  -h, --help
          Print help

Documentation