Introduction to devenv
devenv.sh is a versatile tool designed to provide developers with fast, declarative, reproducible, and composable environments. Built on the foundation of Nix, it aims to streamline the process of setting up and maintaining development environments.
Key Features
Fast and Declarative
devenv offers a declarative approach to managing developer environments, where configurations are defined in files rather than executed via scripts. This design ensures that developers can quickly set up and enter their environments with consistent settings every time.
Reproducible Environments
One of devenv's standout features is its ability to guarantee reproducibility. By defining environments in devenv.nix
, developers can be assured that their environments can be recreated on any machine, eliminating the infamous "it works on my machine" problem.
Composable Architecture
devenv encourages modularity and composition. Developers can build environments by combining different packages, scripts, and services, allowing for highly customized setups tailored to project requirements.
Getting Started
Running the command devenv init
generates a default devenv.nix
configuration file. Here's a brief overview of what this file can include:
- Environment Variables: Define custom environment variables, such as
env.GREET
, which sets a greeting message. - Packages: Specify packages to be included in the environment, for example, adding
pkgs.git
for Git integration. - Shell Commands: Utilize
enterShell
to automate shell commands upon entering the environment. - Testing: Configure tests with
enterTest
, automating verification processes like checking Git version. - Languages & Services: Enable and configure languages like Nix or services like PostgreSQL with ease.
- Pre-commit Hooks: Enhance code quality with hooks such as
shellcheck
. - Processes: Launch background processes (e.g.,
ping localhost
) upon environment activation.
By running devenv shell
, the environment defined in devenv.nix
is activated, ready for development tasks.
Handy Commands
devenv provides a suite of commands to simplify environment management:
- init: Set up scaffold files such as
devenv.yaml
and.envrc
. - shell: Activate the development environment.
- update: Refresh lock files based on
devenv.yaml
. - search: Find packages and options within nixpkgs.
- info: Display details about the current developer environment.
- up & processes: Start or manage processes effectively.
- test: Execute predefined test scripts.
- container: Manage containers by building, copying, or running them.
- build: Compile attributes in
devenv.nix
.
Various options like verbosity, job limits, and CPU core usage allow further customization for advanced users.
Documentation and Community
There's a robust set of resources available for devenv users:
- Getting Started: Comprehensive guides to kickstart usage.
- Basics & Roadmap: Foundational knowledge and future plans for devenv.
- Blog: News, updates, and insights about the evolving ecosystem.
- Community: Contributions and community discussions that help refine and expand devenv's functionality.
For more details or to get involved in the community, developers can access the complete documentation on devenv's official site.