### Example initial SQL script for server-wide setup Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Use initialScript for server-wide setup like creating roles or configuring global settings. This script is executed after initialDatabases setup. ```nix CREATE ROLE postgres SUPERUSER; CREATE ROLE bar; ``` -------------------------------- ### Configure Poetry Installation Options Source: https://github.com/cachix/devenv/blob/main/docs/src/languages/python.md Example configuration for enabling automatic installation and specifying dependency groups during initialization. ```nix languages.python.poetry.install = { enable = true; allExtras = true; groups = [ "dev" "test" ]; }; ``` -------------------------------- ### Enable Zig with Automatic Version and ZLS Setup Source: https://github.com/cachix/devenv/blob/main/docs/src/individual-docs/languages/zig.md Use the 'version' attribute to automatically configure the Zig compiler and ZLS based on the specified Zig version from zig-overlay. This is the simplest way to get started. ```nix languages.zig = { enable = true; version = "0.15.1"; }; ``` -------------------------------- ### Example Apple SDK Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify a particular Apple SDK version. ```nix pkgs.apple-sdk_15 ``` -------------------------------- ### Example of Initial Databases with Schemas Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to define initial databases, including specifying SQL schema files for their creation. ```nix [ { name = "foodatabase"; schema = ./foodatabase.sql; } { name = "bardatabase"; } ] ``` -------------------------------- ### Example Opencode Settings Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example configuration for Opencode settings, specifying the editor, theme, and enabled features. ```nix { editor = "nvim"; theme = "dark"; features = { autocomplete = true; git_integration = true; }; } ``` -------------------------------- ### Linux Capabilities Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md This example shows how to configure Linux capabilities for a process, such as 'cap_net_admin' and 'cap_sys_admin'. Requires devenv 2.0+. ```nix [ "cap_net_admin" "cap_sys_admin" ] ``` -------------------------------- ### Example Rust Toolchain File Path Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify the path to a Rust toolchain file. ```nix ./rust-toolchain.toml ``` -------------------------------- ### Example inputsFrom configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Specify a list of derivations whose build inputs will be merged into the shell environment. This example includes the 'hello' package and a Python 3 environment with numpy and pandas. ```nix [ pkgs.hello (pkgs.python3.withPackages (ps: [ ps.numpy ps.pandas ])) ] ``` -------------------------------- ### Task Dependency Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of using the 'after' attribute to define task dependencies. It shows how to specify that a task should run after 'pnpm:install' has completed, even if it fails. ```nix after = [ "pnpm:install@completed" ]; ``` -------------------------------- ### Prepare GitHub Actions environment Source: https://github.com/cachix/devenv/blob/main/docs/src/integrations/github-actions.md Initial steps to check out the repository, install Nix, configure the Cachix cache, and install devenv. ```yaml steps: - uses: actions/checkout@v5 - uses: cachix/install-nix-action@v31 - uses: cachix/cachix-action@v16 with: name: devenv - name: Install devenv.sh run: nix profile add nixpkgs#devenv ``` -------------------------------- ### Define Process and Before Task Source: https://github.com/cachix/devenv/blob/main/docs/src/tasks.md Defines a web server process and a setup task that runs before the web server starts. Use this to ensure prerequisites are met before a process is executed. ```nix { pkgs, ... }: { # Define a process processes.web-server = { exec = "python -m http.server 8080"; }; # Define a task that runs before the process tasks."app:setup-data" = { exec = "echo 'Setting up data...'" ; before = [ "devenv:processes:web-server" ]; }; } ``` -------------------------------- ### Example Temporal Namespaces Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to specify custom namespaces to be pre-created for the Temporal service. ```nix [ "my-namespace" "my-other-namespace" ] ``` -------------------------------- ### Example JDK Package Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of specifying a specific JDK version, such as JDK 8. ```nix pkgs.jdk8 ``` -------------------------------- ### Testing with Processes in Nix using devenv Source: https://github.com/cachix/devenv/blob/main/docs/src/tests.md This example shows how to test an environment that includes running services. It configures an Nginx service and then writes an `enterTest` script to wait for the service port, fetch content, and verify it. The `devenv test` command handles starting and stopping the processes automatically. ```nix { pkgs, ... }: { services.nginx = { enable = true; httpConfig = '' server { listen 8080; location / { return 200 "Hello, world!"; } } ''; }; enterTest = '' wait_for_port 8080 curl -s localhost:8080 | grep "Hello, world!" ''; } ``` ```shell-session $ devenv test ✓ Building tests in 2.5s. ✓ Building processes in 15.7s. • Starting processes ...• PID is 113105 • See logs: $ tail -f /run/user/1000/nix-shell.upTad4/.tmpv25BxA/processes.log • Stop: $ devenv processes stop ✓ Starting processes in 0.0s. • Running tests ... Setting up shell environment... Running test... ncdu 2.2 ✓ Running tests in 4.7s. • Stopping process with PID 113105 ✓ Tests passed. in 0.0s. ``` -------------------------------- ### Example Pre-commit Package Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of specifying an alternative package for pre-commit hooks. ```nix pkgs.prek ``` -------------------------------- ### Execute Setup Tasks Before Process Start in Nix Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/devenv-devlog-processes-are-now-tasks.md This Nix code snippet demonstrates how to define a process and a task that runs before it. The 'db:migrate' task is configured to execute before the 'devenv:processes:backend' process starts, ensuring database migrations are completed prior to the backend service launching. ```nix { processes.backend = { exec = "cargo run --release"; }; tasks."db:migrate" = { exec = "diesel migration run"; before = [ "devenv:processes:backend" ]; }; } ``` -------------------------------- ### Start Processes Source: https://github.com/cachix/devenv/blob/main/docs/src/processes.md Use the `devenv up` command to start all defined processes. This command manages the lifecycle of your defined processes. ```shell $ devenv up ``` -------------------------------- ### CouchDB Configuration Settings Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to configure CouchDB settings, including database directory, single node mode, URI file, admin credentials, and bind address/port. ```nix { couchdb = { database_dir = baseDir; single_node = true; view_index_dir = baseDir; uri_file = "${config.services.couchdb.baseDir}/couchdb.uri"; }; admins = { "admin_username" = "pass"; }; chttpd = { bind_address = "127.0.0.1"; port = 5984; }; } ``` -------------------------------- ### Example Opencode Skills Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of configuring Opencode skills, showing inline content, a path to a markdown file, and a path to a directory. ```nix { "debug-helper" = '' # Debug Helper Skill Helps diagnose and fix bugs systematically. ''; "api-generator" = ./skills/api-generator.md; "full-stack-skill" = ./skills/full-stack; } ``` -------------------------------- ### Detekt Configuration File Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of setting the `configFile` option for Detekt. This option specifies the path to a custom Detekt configuration file. ```nix "./detekt-config.yml" ``` -------------------------------- ### RabbitMQ Configuration Items Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to configure RabbitMQ using the `configItems` option, which uses a key-value format for settings like authentication backends. This format is suitable for simple configurations. ```nix { "auth_backends.1.authn" = "rabbit_auth_backend_ldap"; "auth_backends.1.authz" = "rabbit_auth_backend_internal"; } ``` -------------------------------- ### Example Excludes List Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify paths to exclude, such as the 'node_modules' directory. ```nix [ "node_modules/*" ] ``` -------------------------------- ### Example processes..listen Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides examples of configuring TCP and Unix stream sockets for process listening. TCP sockets require an address, while Unix stream sockets can specify a path and mode. ```nix [ { address = "127.0.0.1:8080"; kind = "tcp"; name = "http"; } { kind = "unix_stream"; mode = 384; name = "admin"; path = "$DEVENV_STATE/admin.sock"; } ] ``` -------------------------------- ### Example Biome Binary Path Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify a custom path for the biome binary, such as one located in node_modules. ```nix "./node_modules/.bin/biome" ``` -------------------------------- ### Install Devenv for Newcomers Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Installs the Devenv CLI using nix-env, suitable for users new to Nix. It installs the 'devenv' attribute from the unstable channel of nixpkgs. ```shell nix-env --install --attr devenv -f https://github.com/NixOS/nixpkgs/tarball/nixpkgs-unstable ``` -------------------------------- ### Install Nix on Linux Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Use this command to install Nix on Linux systems. It downloads and executes the Nix installer script with daemon support. ```shell sh <(curl -L https://nixos.org/nix/install) --daemon ``` -------------------------------- ### Project Name Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of setting the project name. This is used to identify the Devenv shell environment. ```nix "devenv-shell" ``` -------------------------------- ### Example for black.settings.flags Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to set flags for the black hook, such as skipping magic trailing commas. ```nix "--skip-magic-trailing-comma" ``` -------------------------------- ### Example for uv-export.settings.format Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Sets the output format for the project's lockfile when using the uv-export hook. Example shows 'requirements.txt'. ```nix "requirements.txt" ``` -------------------------------- ### Example Configuration for vale hook Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md This example shows how to provide multiline string configuration for the `vale` hook, specifying `MinAlertLevel` and `BasedOnStyles`. ```nix '' MinAlertLevel = suggestion [*] BasedOnStyles = Vale '' ``` -------------------------------- ### rumdl configuration example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of configuring the rumdl hook with specific linting rules. ```nix { configuration = { MD013 = { line-length = 100; }; }; } ``` -------------------------------- ### Example Watchdog Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of configuring the systemd watchdog for a process, specifying a 30-second interval and requiring a READY notification. ```nix { usec = 30000000; # 30 seconds require_ready = true; } ``` -------------------------------- ### Example rust-toolchain.toml Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/languages/rust.md An example rust-toolchain.toml file specifying the stable channel, components, and a minimal profile. ```toml [toolchain] channel = "stable" components = ["rustfmt", "clippy"] profile = "minimal" ``` -------------------------------- ### Example threads for Alejandra hook Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example setting the number of formatting threads to 8 for the Alejandra hook. ```nix 8 ``` -------------------------------- ### Example mdformat Plugins Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to configure mdformat with specific plugins like mdformat-footnote and mdformat-gfm. Ensure these packages are available in your environment. ```nix ps: [ ps.mdformat-footnote ps.mdformat-gfm ]; ``` -------------------------------- ### NixOS Configuration Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of NixOS configuration for a machine. This is used to define system-level settings, bootloader, and services for NixOS environments. ```nix { fileSystems."/".device = "/dev/sda1"; boot.loader.systemd-boot.enable = true; services.openssh.enable = true; } ``` -------------------------------- ### Example MCP Server Configurations Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides examples of how to configure different types of MCP servers (stdio and http) for Claude Code integration. This includes setting commands, arguments, environment variables, URLs, and headers. ```nix { "mcp.devenv.sh" = { type = "http"; url = "https://mcp.devenv.sh"; }; } ``` ```nix { awslabs-iam-mcp-server = { type = "stdio"; command = lib.getExe pkgs.awslabs-iam-mcp-server; args = [ ]; env = { }; }; github = { type = "http"; url = "https://api.githubcopilot.com/mcp/"; headers = { Authorization = "Bearer GITHUB_PAT"; }; }; linear = { type = "http"; url = "https://mcp.linear.app/mcp"; }; devenv = { type = "stdio"; command = "devenv"; args = [ "mcp" ]; env = { DEVENV_ROOT = config.devenv.root; }; }; } ``` -------------------------------- ### Example of Ruby devenv.nix configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/devenv-v0.5.md This example demonstrates how to configure a Ruby development environment using devenv.nix, including setting environment variables for Ruby gems. ```nix { packages = { ruby = "3.1.2"; }; shellHook = '' export GEM_HOME=$PWD/.gem export GEM_PATH=$PWD/.gem ''; } ``` -------------------------------- ### Container Startup Command Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Illustrates how to specify a startup command for a container. It can be a string, package, or a list of strings for arguments. Use a list for commands expecting separate arguments. ```nix null ``` ```nix " -f " /var/lib/haproxy/haproxy.cfg " ]; " ``` -------------------------------- ### Example Kafka JVM Options Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides a list of extra command-line options for the Java Virtual Machine (JVM) running Kafka. This example includes options for preferring IPv4 stack and enabling JMX remote monitoring. ```nix [ "-Djava.net.preferIPv4Stack=true" "-Dcom.sun.management.jmxremote" "-Dcom.sun.management.jmxremote.local.only=true" ] ``` -------------------------------- ### Profile Priority Example (Nix) Source: https://github.com/cachix/devenv/blob/main/docs/src/profiles.md This Nix example demonstrates how profile priorities affect option overrides. It shows a scenario where a database service is enabled by a hostname profile, disabled by a user profile, and then re-enabled by a manual QA profile, illustrating deterministic conflict resolution. ```nix { config, ... }: { myteam.services.database.enable = false; profiles = { hostname."dev-server".module = { myteam.services.database.enable = true; }; user."alice".module = { myteam.services.database.enable = false; }; qa.module = { myteam.services.database.enable = true; }; }; } ``` -------------------------------- ### Example Opencode Rules Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of custom development rules for Opencode, specifying testing, commit conventions, and API documentation. ```nix # Custom Development Rules - Always write tests - Use conventional commits - Document public APIs ``` -------------------------------- ### Example Branch Pattern Restriction Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of a RegEx pattern to disallow commits to branches starting with 'ma'. This is a list of strings. ```nix [ "ma.*" ] ``` -------------------------------- ### Customize Poetry Installation Options Source: https://github.com/cachix/devenv/blob/main/docs/src/individual-docs/languages/python.md Demonstrates advanced configuration for Poetry, such as installing the root package, specifying dependency groups, and suppressing output. ```nix { languages.python = { enable = true; poetry = { enable = true; install = { enable = true; installRootPackage = true; groups = [ "dev" "test" ]; quiet = true; }; activate.enable = true; }; }; } ``` -------------------------------- ### Prettier Custom Binary Path Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example demonstrating how to specify a custom path for the Prettier binary, such as one located in node_modules. This is useful to avoid tracking the binary in Nix flake projects. ```nix "./node_modules/.bin/prettier" ``` -------------------------------- ### Start Services with devenv Source: https://github.com/cachix/devenv/blob/main/docs/src/services/index.md This command shows how to start all configured services and processes within a devenv environment. It is the primary command for bringing up the development environment. ```shell-session $ devenv up Starting processes ... ``` -------------------------------- ### Example Profiles Configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Demonstrates defining various profiles, including manual, automatic hostname-based, and automatic user-based profiles, with inheritance using 'extends'. ```nix { # Manual profiles (activated via --profile) "base" = { module = { languages.nix.enable = true; packages = [ pkgs.git ]; }; }; "python-3.14" = { extends = [ "base" ]; module = { languages.python.version = "3.14"; }; }; "backend" = { extends = [ "base" ]; module = { services.postgres.enable = true; services.redis.enable = true; }; }; "fullstack" = { extends = [ "backend" "python-3.14" ]; module = { env.FULL_STACK = "true"; }; }; # Automatic hostname-based profiles hostname."work-laptop" = { extends = [ "backend" ]; module = { env.WORK_ENV = "true"; }; }; # Automatic user-based profiles user."alice" = { extends = [ "python-3.14" ]; module = { env.USER_ROLE = "developer"; }; }; } ``` -------------------------------- ### Execute Commands After MinIO Start Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provide bash commands to run after MinIO has started. These commands are concatenated with newlines. An example shows setting up anonymous download access for a bucket. ```nix '' mc anonymous set download local/mybucket '' ``` -------------------------------- ### Execute Code After MinIO Start Source: https://github.com/cachix/devenv/blob/main/docs/src/services/minio.md Allows execution of bash commands after the MinIO service has successfully started. Useful for initial bucket setup or configuration. Defaults to an empty string. ```nix services.minio.afterStart = '' mc anonymous set download local/mybucket ''; ``` -------------------------------- ### POST /devenv/up Source: https://github.com/cachix/devenv/blob/main/docs/src/services/index.md Starts the configured services and processes defined in the devenv.nix file. ```APIDOC ## POST /devenv/up ### Description Starts all processes and services defined in the project configuration. Services run in the foreground by default. ### Method POST ### Endpoint /devenv/up ### Parameters #### Query Parameters - **-d** (flag) - Optional - If provided, starts services in the background. ### Request Example $ devenv up -d ### Response #### Success Response (200) - **status** (string) - Indicates that the processes have been started successfully. #### Response Example Starting processes ... ``` -------------------------------- ### Following Inputs in devenv.yaml Source: https://github.com/cachix/devenv/blob/main/docs/src/inputs.md Shows how to make one input 'follow' another, enabling inheritance or overriding. The first example demonstrates inheriting `nixpkgs` from a `base-project` input. The second example shows how `git-hooks` can follow the top-level `nixpkgs` input to reduce duplication. ```yaml inputs: base-project: url: github:owner/repo nixpkgs: follows: base-project/nixpkgs ``` ```yaml inputs: nixpkgs: url: github:cachix/devenv-nixpkgs/rolling git-hooks: url: github:cachix/git-hooks.nix inputs: nixpkgs: follows: nixpkgs ``` -------------------------------- ### Test Configuration Example Source: https://github.com/cachix/devenv/blob/main/CLAUDE.md Optional test configuration file (`.test-config.yml`) for integration tests. Allows customization of test environment setup. ```yaml use_shell: false git_init: false supported_systems: [] broken_systems: [] ``` -------------------------------- ### Caddy Virtual Host Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of configuring a virtual host with server aliases and custom configuration lines. This is useful for defining specific domain configurations. ```nix { "hydra.example.com" = { serverAliases = [ "www.hydra.example.com" ]; extraConfig = '''' encode gzip log root /srv/http ''''; }; } ``` -------------------------------- ### Configure RustFS Service Options Source: https://github.com/cachix/devenv/blob/main/docs/src/services/rustfs.md Examples showing how to enable the RustFS service and pass custom environment variables to the process. ```nix services.rustfs.enable = true; services.rustfs.extraEnvironment = { RUSTFS_OBJECT_CACHE_ENABLE = "true"; RUSTFS_OBS_LOGGER_LEVEL = "debug"; }; ``` -------------------------------- ### Example integrations.gitnr configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Configure declarative generation of ignore files using gitnr templates. This example enables default templates for Go and Node.js, and adds custom content to the ignore file. ```nix { ".gitignore" = { enableDefaultTemplates = true; templates = [ "tt:go" "tt:node" ]; content = [ "*.env" ]; }; } ``` -------------------------------- ### File Watching Configuration Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of file watching configuration for automatic process restarts. It specifies paths to watch, file extensions to consider, and directories to ignore. ```nix { paths = [ ./src ]; extensions = [ "rs" "toml" ]; ignore = [ "target" ]; } ``` -------------------------------- ### Define Process Dependencies Source: https://github.com/cachix/devenv/blob/main/docs/src/processes.md Configure process dependencies using the `after` attribute to ensure one process starts only after another is ready. This example shows the `api` process waiting for the `database` process. ```nix { processes = { database.exec = "postgres"; api = { exec = "myapi"; after = [ "devenv:processes:database" ]; # wait for database to be ready }; }; } ``` -------------------------------- ### Enable Basic Rust Support Source: https://github.com/cachix/devenv/blob/main/docs/src/individual-docs/languages/rust.md Enables a complete Rust development environment including rustc, cargo, clippy, rustfmt, and rust-analyzer. This is the simplest way to get started with Rust in Devenv. ```nix { languages.rust.enable = true; } ``` -------------------------------- ### Complete workflow example Source: https://github.com/cachix/devenv/blob/main/docs/src/integrations/github-actions.md A full GitHub Actions workflow file demonstrating various devenv integration methods. ```yaml name: "Test" on: pull_request: push: jobs: tests: strategy: matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5 - uses: cachix/install-nix-action@v31 - uses: cachix/cachix-action@v16 with: name: devenv - name: Install devenv.sh run: nix profile add nixpkgs#devenv - name: Build the devenv shell and run any pre-commit hooks run: devenv test - name: Run a single command in the devenv shell run: devenv shell hello - name: Run a multi-line command in the devenv shell shell: devenv shell bash -- -e {0} run: | hello say-bye ``` -------------------------------- ### Example Configuration for Typos Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of how to configure the typos checker, including settings for binary files, ignoring dot files, and extending glob patterns for Python files. ```nix { default = { binary = false; }; files = { ignore-dot = true; }; type = { py = { extend-glob = [ ]; }; }; } ``` -------------------------------- ### Future Devenv Container Integration Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/devenv-v1.0-rewrite-in-rust.md Examples of proposed commands for running Devenv environments within a container. This feature aims to provide greater isolation and convenience for complex or resource-intensive development setups. ```bash devenv shell --in-container ``` ```bash devenv test --in-container ``` -------------------------------- ### Example Profile Extension List Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Illustrates how to specify a list of profile names to extend. ```nix [ "base" "backend" ] ``` -------------------------------- ### Compose Environments with Imports Source: https://github.com/cachix/devenv/blob/main/docs/src/overrides/home.html Import other environments to create a unified development setup, supporting both monorepo and polyrepo structures. This example imports local frontend and backend configurations along with a shared remote environment. ```yaml inputs: myorg-devenv: url: github:myorg/myorg-devenv imports: - ./frontend - ./backend - myorg-devenv/shared-service ``` -------------------------------- ### Define Parent Proxies for Traffic Server Cache Hierarchy Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Specify parent proxies for a cache hierarchy. This configuration is used when Traffic Server needs to identify upstream caches in a distributed setup. Supports methods like 'get' and load balancing strategies like 'round_robin'. ```nix '' dest_domain=. method=get parent="p1.example:8080; p2.example:8080" round_robin=true '' ``` -------------------------------- ### Activate devenv Profiles via Shell Command Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/devenv-v1.9-scaling-nix-projects-using-modules-and-profiles.md These shell commands demonstrate how to activate specific devenv profiles for different development tasks. Examples include launching a shell with the 'backend' profile, starting services with 'backend', and using the 'frontend' or 'fullstack' profiles for respective development needs. ```shell $ devenv --profile backend shell ``` ```shell $ devenv --profile backend up ``` ```shell $ devenv --profile frontend shell ``` ```shell $ devenv --profile fullstack shell ``` -------------------------------- ### Configure PostgreSQL Service Source: https://github.com/cachix/devenv/blob/main/docs/src/overrides/home.html Enable PostgreSQL, specify the package, set up initial databases, extensions, and pre-load libraries. ```nix { pkgs, ... }: { services.postgres = { enable = true; package = pkgs.postgresql_15; initialDatabases = [{ name = "mydb"; }]; extensions = extensions: [ extensions.postgis extensions.timescaledb ]; settings.shared_preload_libraries = "timescaledb"; initialScript = "CREATE EXTENSION IF NOT EXISTS timescaledb;"; }; } ``` -------------------------------- ### Install Nix Classic Installer on macOS Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Alternative method to install Nix on macOS using the classic installer script. Use this if you prefer not to use the recommended installer. ```shell sh <(curl -L https://nixos.org/nix/install) ``` -------------------------------- ### Android Extras to Install Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md A list of Android extras to install. By default, the Google Cloud Messaging (GCM) extra is installed. ```nix [ "extras;google;gcm" ] ``` -------------------------------- ### Configure Poetry Install Options Source: https://github.com/cachix/devenv/blob/main/docs/src/languages/python.md Fine-tune Poetry's installation process by enabling specific options such as installing the root package, specifying dependency groups, or suppressing output. This allows for more granular control over how project dependencies are installed. ```nix { languages.python = { enable = true; poetry = { enable = true; install = { enable = true; installRootPackage = true; # Install your project itself groups = [ "dev" "test" ]; # Specific dependency groups # ignoredGroups = [ "docs" ]; # Groups to skip # allExtras = true; # All extras quiet = true; # Suppress output }; activate.enable = true; }; }; } ``` -------------------------------- ### Caddyfile Configuration Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Use this snippet to provide a verbatim Caddyfile configuration. It supports global options and site blocks for defining server behavior. ```nix '' # Global options block { debug } # Site block example.com { encode gzip log root /srv/http } '' ``` -------------------------------- ### Create Executable Script Source: https://github.com/cachix/devenv/blob/main/docs/src/creating-files.md Creates an executable shell script named `setup.sh` using the `text` attribute and setting `executable = true`. This is useful for automating setup tasks. ```nix { files."setup.sh" = { text = '' #!/bin/bash echo "Running setup..." npm install ''; executable = true; }; } ``` -------------------------------- ### Install Nix on macOS Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Installs Nix on macOS using the recommended installer script. This method supports OS upgrades and Apple silicon. ```shell curl -sSfL https://artifacts.nixos.org/nix-installer | sh -s -- install ``` -------------------------------- ### Sample devenv configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/integrations/github-actions.md A basic devenv.nix file defining a package and a custom script. ```nix { pkgs, ... }: { packages = [ pkgs.hello ]; scripts.say-bye.exec = '' echo bye ''; } ``` -------------------------------- ### Install SecretSpec CLI Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/secretspec-0.7-declarative-secret-generation.md Command to install the SecretSpec CLI tool. ```bash curl -sSL https://install.secretspec.dev | sh ``` -------------------------------- ### Configure Local Hosts and Certificates with Caddy Source: https://github.com/cachix/devenv/blob/main/docs/src/blog/posts/devenv-v0.6-generating-containers-and-instant-shell-activation.md This Nix configuration snippet demonstrates how to declaratively set up local hostnames and SSL certificates for development. It configures Caddy to serve content for 'example.com' using locally generated certificates, enabling HTTPS for local development. ```nix { pkgs, config, ... }: { certificates = [ "example.com" ]; hosts."example.com" = "127.0.0.1"; services.caddy.enable = true; services.caddy.virtualHosts."example.com" = { extraConfig = '' tls ${config.env.DEVENV_STATE}/mkcert/example.com.pem ${config.env.DEVENV_STATE}/mkcert/example.com-key.pem respond "Hello, world!" ''; }; } ``` -------------------------------- ### Initialize Devenv Project Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Scaffolds a new Devenv project by creating essential configuration files: devenv.nix, devenv.yaml, and .gitignore. ```shell $ devenv init • Creating devenv.nix • Creating devenv.yaml • Creating .gitignore ``` -------------------------------- ### Enable and Configure MongoDB Service in Devenv Source: https://github.com/cachix/devenv/blob/main/docs/src/services/mongodb.md Demonstrates how to enable the MongoDB service, define custom arguments, and set up an initial root user with credentials. ```nix services.mongodb.enable = true; services.mongodb.additionalArgs = [ "--port" "27017" "--noauth" ]; services.mongodb.initDatabaseUsername = "mongoadmin"; services.mongodb.initDatabasePassword = "secret"; ``` -------------------------------- ### Basic Setup with Latest Stable Rust Source: https://github.com/cachix/devenv/blob/main/docs/src/languages/rust.md Set up the latest stable Rust toolchain. This is a common configuration for projects preferring stability. ```nix { languages.rust = { enable = true; channel = "stable"; }; } ``` -------------------------------- ### Configure Memcached Startup Arguments Source: https://github.com/cachix/devenv/blob/main/docs/src/services/memcached.md Provides additional arguments for Memcached startup. Defaults to an empty list. ```nix services.memcached.startArgs = [ "--memory-limit=100M" ]; ``` -------------------------------- ### Example Branch Restriction Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify multiple branches to disallow commits to. This is a list of strings. ```nix [ "main" "master" ] ``` -------------------------------- ### Example hosts configuration Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Configure host entries with IP addresses for domain names. This can be a single IP address or a list of IP addresses. ```nix { "another-example.com" = [ "::1" "127.0.0.1" ]; "example.com" = "127.0.0.1"; } ``` -------------------------------- ### Configure Django with Poetry and PostgreSQL in Devenv Source: https://github.com/cachix/devenv/blob/main/docs/src/languages/python.md A complete example showing how to set up a Python environment with Poetry, define environment variables for a PostgreSQL database, and configure a background process to run the Django server. ```nix { config, pkgs, ... }: let db_user = "postgres"; db_name = "myapp"; in { languages.python = { enable = true; version = "3.11"; poetry = { enable = true; install.enable = true; activate.enable = true; }; }; env = { DATABASE_URL = "postgres://${db_user}@/${db_name}?host=${config.env.PGHOST}"; SECRET_KEY = "dev-only-secret"; }; services.postgres = { enable = true; initialDatabases = [{ name = db_name; user = db_user; }]; }; processes.runserver = { exec = "exec python manage.py runserver"; after = [ "devenv:processes:postgres" ]; }; } ``` -------------------------------- ### Install Packages Ad-hoc Source: https://github.com/cachix/devenv/blob/main/docs/src/ad-hoc-developer-environments.md Uses the :pkgs type to install multiple packages into a temporary environment shell. ```shell devenv --option packages:pkgs "ncdu git ripgrep" shell ``` -------------------------------- ### Additional influxd startup arguments Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of additional arguments to pass to `influxd` during startup, such as enabling flux logging. ```nix [ "--flux-log-enabled" ] ``` -------------------------------- ### Flake8 Extend Ignore Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example demonstrating how to add 'E501' to the list of ignored flake8 error codes. ```nix [ "E501" ] ``` -------------------------------- ### Configure Varnish Service Options Source: https://github.com/cachix/devenv/blob/main/docs/src/services/varnish.md Examples of configuring the Varnish service in a Nix-based devenv environment. These snippets demonstrate how to enable the service, define additional modules, and provide custom VCL configuration. ```nix services.varnish.enable = true; services.varnish.listen = "127.0.0.1:6081"; services.varnish.memorySize = "64M"; services.varnish.extraModules = [ pkgs.varnish73Packages.modules ]; services.varnish.vcl = '' vcl 4.0; backend default { .host = "127.0.0.1"; .port = "80"; } ''; ``` -------------------------------- ### Enable and Configure Caddy Service Source: https://github.com/cachix/devenv/blob/main/docs/src/services/caddy.md Demonstrates how to enable the Caddy service and provide a custom Caddyfile configuration using Nix syntax. ```nix services.caddy.enable = true; services.caddy.config = '' # Global options block { debug } # Site block example.com { encode gzip log root /srv/http } ''; ``` -------------------------------- ### Example exclude list for Alejandra hook Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify files or directories to exclude from formatting by the Alejandra hook. ```nix [ "flake.nix" "./templates" ] ``` -------------------------------- ### Basic Devenv Configuration (Nix) Source: https://github.com/cachix/devenv/blob/main/docs/src/cloud.md Sets up basic project languages (Python, Node.js) and packages (git, curl, jq). It also enables and configures a local PostgreSQL service with an initial database. ```nix { pkgs, ... }: { languages = { python.enable = true; nodejs.enable = true; }; packages = with pkgs; [ git curl jq ]; services.postgres = { enable = true; initialDatabases = [{ name = "myapp"; }]; }; } ``` -------------------------------- ### Initialize a new project with devenv Flake template Source: https://github.com/cachix/devenv/blob/main/docs/src/guides/using-with-flakes.md Use this command to set up a new project with Nix flakes and a basic devenv configuration. ```bash nix flake init --template github:cachix/devenv ``` -------------------------------- ### System Architecture Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of specifying the system architecture for a machine. This ensures compatibility with the target operating system and hardware. ```nix "x86_64-linux" ``` -------------------------------- ### Example verbosity for Alejandra hook Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example setting the verbosity level to 'quiet' for the Alejandra hook, hiding informational messages. ```nix "quiet" ``` -------------------------------- ### Define Initial Databases Source: https://github.com/cachix/devenv/blob/main/docs/src/services/postgres.md Specifies a list of databases to be created on the first startup, optionally including an initial SQL schema file. ```nix services.postgres.initialDatabases = [ { name = "foodatabase"; schema = ./foodatabase.sql; } { name = "bardatabase"; } ]; ``` -------------------------------- ### Install PostgreSQL Extensions Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Use this option to specify additional PostgreSQL extensions to be installed. The extensions are provided as a list of package identifiers. ```nix extensions: [ extensions.pg_cron extensions.postgis extensions.timescaledb ]; ``` -------------------------------- ### Install Devenv with Nix Profiles Source: https://github.com/cachix/devenv/blob/main/docs/src/getting-started.md Installs the Devenv CLI using Nix profiles. This method requires experimental flags to be enabled. ```shell nix profile install nixpkgs#devenv ``` -------------------------------- ### Initialize Databases for MySQL (Nix) Source: https://github.com/cachix/devenv/blob/main/docs/src/services/mysql.md Defines a list of databases and their initial schemas to be created on the first MySQL server startup. An empty database is created if no schema is specified. ```nix services.mysql.initialDatabases = [ { name = "foodatabase"; schema = ./foodatabase.sql; } { name = "bardatabase"; } ]; ``` -------------------------------- ### Enable Predefined Git Hook Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of how to enable a predefined git hook, specifically 'nixpkgs-fmt'. ```nix hooks.nixpkgs-fmt.enable = true; ``` -------------------------------- ### Nix-darwin Configuration Example Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Example of Nix-darwin configuration for a machine. This is used to set up system packages and services specific to macOS environments. ```nix { pkgs, ... }: { environment.systemPackages = [ pkgs.vim ]; services.nix-daemon.enable = true; } ``` -------------------------------- ### Example Cargo Dependencies Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md An example of how to specify Cargo dependencies using pkgs.rustPlatform.importCargoLock. This is used to provide the necessary dependencies for running checks. ```nix "pkgs.rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }" ``` -------------------------------- ### Run a Container with Built Artifacts Source: https://github.com/cachix/devenv/blob/main/docs/src/containers.md Start a container that includes built artifacts, executing a specified startup command. ```shell $ devenv container run prod ... ``` -------------------------------- ### Create Files in Subdirectories Source: https://github.com/cachix/devenv/blob/main/docs/src/creating-files.md Demonstrates creating files in nested directories, including a JSON configuration file in `.config/app/` and an executable script in `scripts/`. Parent directories are created automatically. ```nix { files = { ".config/app/settings.json".json = { theme = "dark"; }; "scripts/build.sh" = { text = "#!/bin/bash\nnpm run build"; executable = true; }; }; } ``` -------------------------------- ### Example regal flags Source: https://github.com/cachix/devenv/blob/main/docs/src/reference/options.md Provides an example of flags that can be passed to the regal linter. Use this to configure specific linting rules or behaviors. ```nix "--disable-category style" ```