devenv
Fast, Declarative, Reproducible, and Composable Developer Environments - devenv
Maintain local development environment by Nix.
direnv とセットで使うのが便利
Guide
Getting started - devenv
devenv can be used with flakes
Using with Flakes - devenv
通常であればdevenv.nix で定義する option を、devenv.shells.default で定義することになるみたい
通常の devShell から減らされている attributes がある
Options - devenv
code:shell
nix-env -iA devenv -f https://github.com/NixOS/nixpkgs/tarball/nixpkgs-unstable
apple_sdk's setup hook breaks /usr/bin/git in devshells · Issue #355486 · NixOS/nixpkgs
???
jetify-com/devbox: Instant, easy, and predictable development environments
Process compose を使うことができる
F1bonacc1/process-compose: Process Compose is a simple and flexible scheduler and orchestrator to manage non-containerized applications.
Caddy
Caddy - devenv
Caddy - NixOS Wiki
caddy module のソースコード
devenv/src/modules/services/caddy.nix at v1.5.1 · cachix/devenv
config と virtualHosts という option に別れているが、結合されて caddyfile にしている
virtualHosts 部分は、caddyfile の Site Block として展開される
Caddyfile Concepts — Caddy Documentation
virtualHosts option attribute は caddy での site name になる
Caddyfile Concepts — Caddy Documentation
紛らわしいログあり、、、
TLS connection policies · Issue #6049 · caddyserver/caddy
server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS
Certificates
devenv 0.6: Generating containers and instant shell activation - devenv
devenv/src/modules/integrations/mkcert.nix at b7a4b2037ac15773c44a4674586103db738b9819 · cachix/devenv
.envrc のテンプレート
https://github.com/cachix/devenv/blob/c7f2256ee4a4a4ee9cbf1e82a6e49b253c374995/templates/flake-parts/.envrc
PostgreSQL
Postgres - devenv
schme の使い方
devenv.nix がプロジェクトルートにあり、同じ階層に devenv.sql がある場合
code:devenv.nix
services.postgres.initialDatabases = [
{
name = "app";
user = "app";
pass = "secret";
schema = ./devenv.sql;
}
];
superuser 権限が欲しい
おそらく PC ユーザー名の User が作られているが、パスワードが不明
initialScript でロールを作成すれば、任意の権限のロールを使うことができる
serices が起動した後に実行するスクリプトなどは process-compose で管理できる
https://github.com/cachix/devenv/blob/v1.7/examples/process-compose/devenv.nix
devenv 設定の変更を反映するにはどうしたら良い?
devenv up が起動しない
原因不明な場合がある
direnv allow をやり直したら起動できたことがある