Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
devenvに入門した
Search
Tomohiko Himura
September 13, 2023
Technology
0
86
devenvに入門した
devenvというnixをベースした開発環境と本番用のコンテナイメージを作れるツールを紹介しました。
https://devenv.sh/
Tomohiko Himura
September 13, 2023
Tweet
Share
More Decks by Tomohiko Himura
See All by Tomohiko Himura
バイナリ読むのにElixirしてみた
eiel
0
49
アジャイルはさておきMake People Awesomeしたい
eiel
0
150
レビューは最優先にするようにしている
eiel
0
270
再考 Fourkeys メトリクス
eiel
2
650
Test mockをSnapshot testする
eiel
0
110
関数プログラミングの考え方
eiel
1
290
逆コンウェイ作戦はフィードバックループを作るために 逆向きの流れをつくること (5分版)
eiel
0
380
組織のパフォーマンスを高めるために 第1話 学習と文化
eiel
0
220
チームとチームのチーム
eiel
2
2.1k
Other Decks in Technology
See All in Technology
本部長の代わりに提案書レビュー! KDDI営業が毎日使うAIエージェント「A-BOSS」開発秘話
minorun365
PRO
13
1.6k
RubyOnRailsOnDevin+α / DevinMeetupJapan#2
ginkouno
0
290
技術職じゃない私がVibe Codingで感じた、AGIが身近になる未来
blueb
0
120
今からでも間に合う! 生成AI「RAG」再入門 / Re-introduction to RAG in Generative AI
hideakiaoyagi
1
160
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
280
基調講演: 生成AIを活用したアプリケーションの開発手法とは?
asei
1
120
"SaaS is Dead" は本当か!? 生成AI時代の医療 Vertical SaaS のリアル
kakehashi
PRO
3
190
自分を理解するAI時代の準備 〜マイプロフィールMCPの実装〜
edo_m18
0
100
Snowflake Intelligenceで実現できるノーコードAI活用
takumimukaiyama
1
210
エンジニア採用から始まる技術広報と組織づくり/202506lt
nishiuma
8
1.6k
AIコーディング新時代を生き残るための試行錯誤 / AI Coding Survival Guide
tomohisa
9
12k
産業機械をElixirで制御する
kikuyuta
0
160
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
462
33k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
43
2.4k
Faster Mobile Websites
deanohume
307
31k
How STYLIGHT went responsive
nonsquared
100
5.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
A Tale of Four Properties
chriscoyier
159
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
devenvに入門した 2023/08/17 ひむら ともひこ
自己紹介 ひむら ともひこ 最近趣味で遊んでるもの • Nix • GNU Emacs
devenvに入門した
None
こういうことありませんか?
リポジトリをクローンしてきたけど ビルドや実行するまでに いろいろインストールしなきゃいけない
開発するのに VagrantやDockerなど起動しないといけない
つらい
そこでdevenvですよ
devenvとは何か
devenv知ってる人 1人
devenv使ってる人 0人
開発環境構築ツール デプロイ用コンテナイメージ作成ツール
https://devenv.sh/
devenvが導入されてる環境で使ってみる
devenvの設定ファイルがあるプロジェクトで $ devenv up # 開発サーバーやデータベースサーバーなどが起動する $ devenv shell #
開発するのに必要なコマンドがそろった環境に入る
実例
devenv.nix { pkgs, ... }: { env.GREET = "devenv"; packages
= [ pkgs.git ]; scripts.hello.exec = "echo hello from $GREET"; enterShell = '' hello git --version ''; languages.javascript.enable = true; languages.javascript.package = pkgs.nodejs_20; processes.watch.exec = "npm run watch:build"; processes.test.exec = "npm run test --watch"; processes.storybook.exec = "npm run storybook"; }
devenv.yaml inputs: nixpkgs: url: github:NixOS/nixpkgs/nixpkgs-unstable
設定ファイル • devenv.nix ◦ nix言語を用いて設定やインストールするパッケージのカスタマ イズができる • devenv.yaml ◦ パッケージマネージャ自体の設定をする
◦ 外部のdevenvの設定を読み込みする
devenvのinstall方法
ここでは説明したくない
nixがインストールされていれば $ nix-env -if https://install.devenv.sh/latest
もうちょっと詳しく
devenvの環境はシステムとは別途隔離されている • プロジェクトルートの .devenv/profileに環境が作られる $ find .devenv/profile/ | head -n
20 .devenv/profile/ .devenv/profile//bin .devenv/profile//bin/git-jump .devenv/profile//bin/git-receive-pack .devenv/profile//bin/git-credential-netrc .devenv/profile//bin/git-upload-archive .devenv/profile//bin/.honcho-wrapped .devenv/profile//bin/honcho .devenv/profile//bin/git-credential-osxkeychain .devenv/profile//bin/git-cvsserver .devenv/profile//bin/hello .devenv/profile//bin/git-shell .devenv/profile//bin/node .devenv/profile//bin/corepack .devenv/profile//bin/git-upload-pack .devenv/profile//bin/scalar .devenv/profile//bin/npx .devenv/profile//bin/git-http-backend .devenv/profile//bin/npm .devenv/profile//bin/git
正確にはシンボリックリンクでnixで包括的に管理される $ ls -l .devenv/profile .devenv/profile -> /nix/store/qsvm027f4kv1qzldzm40bzrjpzgfmdi0-devenv-profile
devenv upで起動するのはprocess-manager • 有名なものでいうとforeman(ruby) • デフォルトで使われるのはhoncho(python) ◦ 出力に色もつかない • 他に選択できるもの
◦ hivemind(go) ▪ 環境によってはうまくうごかないことがある(おそらくdevenvで使ってる人が少ない) ◦ overmind(go + tmux) ▪ tmuxを使えるならいろいろ便利 ◦ process-compose(go) ◦ ▪ TUI付きでリッチ
いくつか備え付けのpre-commit hookがあるよ • https://github.com/cachix/pre-commit-hooks.nix • PHP ◦ php-cs-fixer, phpcbf, phpcs
• JavaScript/TypeScript ◦ deno fmt, deno lint, eslint, rome • Golang ◦ go fmt, go test, govet, revive, staticcheck • Rust ◦ rustfmt, clippy, cargo check
editorとの連携は…つらいかもしれない • おそらくdirenv を連携してなんとかすることになる • .envrc に以下を書いとけばきっと… source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6d ee421cfd0f51481d17f77586997/direnvrc"
"sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" use devenv
まとめ
devenvまとめ • 仮想化技術を使わずとも ◦ VagrantやDockerをつかった開発環境に近いものを作れる ▪ 同じくらいcleanに使える (ただしnixが必要) ◦ ansibleやdockerfile不要
(近いものをnixが内蔵) • 設定されているリポジトリならお手軽に使える ◦ 使うには nix が必要 ◦ 設定するには nix力が必要