Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/devshell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Dev Shell

on:
push:
branches: [main]
paths:
- 'templates/**'
- '.github/workflows/devshell.yaml'
pull_request:
branches: [main]
paths:
- 'templates/**'
- '.github/workflows/devshell.yaml'

jobs:
discover:
name: Discover templates
runs-on: ubuntu-24.04
outputs:
templates: ${{ steps.list.outputs.templates }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: List templates
id: list
run: |
templates=$(ls -1 templates/ | jq -Rc '[.,inputs]')
echo "templates=$templates" >> "$GITHUB_OUTPUT"

devshell-build:
name: Build devShell (${{ matrix.template }})
needs: discover
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
template: ${{ fromJson(needs.discover.outputs.templates) }}

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- uses: cachix/install-nix-action@616559265b40713947b9c190a8ff4b507b5df49b # v31

- uses: cachix/cachix-action@1eb2ef646ac0255473d23a5907ad7b04ce94065c # v17
with:
name: rito528-dotfiles
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build devShell
run: nix build ./templates/${{ matrix.template }}#devShells.x86_64-linux.default
31 changes: 9 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dotfiles/
│ ├── lint.yaml # shellcheck・nixfmt Lint
│ ├── integration-test.yaml # Cachix を使った home-manager ビルド検証
│ ├── nix.yaml # Nix flake check
│ ├── devshell.yaml # templates/ 配下の devShell ビルド検証
│ ├── nix-update-pr.yaml # Renovate 時のハッシュ自動更新
│ ├── update-flake-lock.yaml # 週次 flake.lock 更新
│ ├── e2e-setup-test.yaml # セットアップ E2E テスト
Expand Down Expand Up @@ -137,41 +138,27 @@ home-manager generations

## 開発環境テンプレート

プロジェクトごとに独立した Nix 開発環境を提供するテンプレートを管理しています。

- `rust`
- `scala`
- `typescript`
プロジェクトごとに独立した Nix 開発環境を提供するテンプレートを管理しています(`templates/` 参照)。

### 自分のプロジェクトで使う場合

```bash
# プロジェクトディレクトリで初期化
nix flake init -t github:rito528/dotfiles#rust
nix flake init -t github:rito528/dotfiles#scala
nix flake init -t github:rito528/dotfiles#typescript
```

### OSS プロジェクト等で dotfiles の devShell を直接参照する場合

```bash
# Rust 環境に入る
nix develop 'github:rito528/dotfiles#rust'

# Scala 環境に入る
nix develop 'github:rito528/dotfiles#scala'

# TypeScript 環境に入る
nix develop 'github:rito528/dotfiles#typescript'
# プロジェクトディレクトリで初期化(例)
nix flake init -t github:rito528/dotfiles#seichi-infra
```

### direnv との連携

プロジェクトディレクトリに `.envrc` を作成することで、ディレクトリに入ると自動的に開発環境が有効になります:

```bash
# テンプレートで初期化したプロジェクトの場合
echo "use flake" > .envrc
direnv allow

# dotfiles のテンプレートを直接参照する場合
echo "use flake 'github:rito528/dotfiles?dir=templates/rust'" > .envrc
direnv allow
```

> `.envrc` はプロジェクト固有の設定のため、global gitignore に追加することを推奨します。
87 changes: 0 additions & 87 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
{
nixpkgs,
home-manager,
rust-overlay,
...
}:
let
Expand All @@ -31,10 +26,6 @@
"github-copilot-cli"
];
};
pkgsWithRust = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
mkHomeConfig =
username: homeDirectory: personal:
home-manager.lib.homeManagerConfiguration {
Expand Down Expand Up @@ -62,7 +53,6 @@
);
npmPackages = loadPackagesDir ./modules/npm/packages;
extraPackages = loadPackagesDir ./modules/packages;
mkShellWithZsh = mkPkgs: args: mkPkgs.mkShell ({ SHELL = "${pkgs.zsh}/bin/zsh"; } // args);
in
{
packages.${system} = npmPackages // extraPackages;
Expand All @@ -79,18 +69,6 @@
};
};
templates = {
rust = {
path = ./templates/rust;
description = "Rust development environment";
};
scala = {
path = ./templates/scala;
description = "Scala development environment";
};
typescript = {
path = ./templates/typescript;
description = "TypeScript (pnpm) development environment";
};
seichi-assist = {
path = ./templates/seichi-assist;
description = "SeichiAssist development environment";
Expand All @@ -108,70 +86,5 @@
description = "seichi-portal-frontend development environment";
};
};
devShells.${system} = {
rust = mkShellWithZsh pkgsWithRust {
buildInputs = [
pkgsWithRust.rust-bin.stable.latest.default
pkgsWithRust.pkg-config
pkgsWithRust.openssl
];
};
scala = mkShellWithZsh pkgs {
buildInputs = [
pkgs.jdk17
pkgs.sbt
pkgs.metals
pkgs.scalafmt
pkgs.stdenv.cc.cc.lib
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
'';
};
typescript = mkShellWithZsh pkgs {
buildInputs = [
pkgs.nodejs_22
pkgs.pnpm
pkgs.typescript
pkgs.typescript-language-server
pkgs.vscode-langservers-extracted
];
};
seichi-assist = mkShellWithZsh pkgs {
buildInputs = [
pkgs.jdk17
pkgs.sbt
pkgs.metals
pkgs.scalafmt
pkgs.stdenv.cc.cc.lib
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
'';
};
seichi-infra = mkShellWithZsh pkgs {
buildInputs = [
pkgs.terraform
pkgs.tflint
pkgs.kubectl
pkgs.kubernetes-helm
];
};
seichi-portal-backend = mkShellWithZsh pkgsWithRust {
buildInputs = [
pkgsWithRust.rust-bin.stable.latest.default
pkgsWithRust.pkg-config
pkgsWithRust.openssl
pkgsWithRust.cargo-make
pkgsWithRust.sqlx-cli
];
};
seichi-portal-frontend = mkShellWithZsh pkgs {
buildInputs = [
pkgs.nodejs_22
pkgs.pnpm
];
};
};
};
}
1 change: 0 additions & 1 deletion templates/rust/.envrc

This file was deleted.

30 changes: 0 additions & 30 deletions templates/rust/flake.nix

This file was deleted.

1 change: 0 additions & 1 deletion templates/scala/.envrc

This file was deleted.

23 changes: 0 additions & 23 deletions templates/scala/flake.nix

This file was deleted.

5 changes: 4 additions & 1 deletion templates/seichi-infra/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
pkgs = import nixpkgs {
inherit system;
config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "terraform" ];
};
in
{
devShells.${system}.default = pkgs.mkShell {
Expand Down
1 change: 0 additions & 1 deletion templates/typescript/.envrc

This file was deleted.

23 changes: 0 additions & 23 deletions templates/typescript/flake.nix

This file was deleted.