This commit is contained in:
Shotaro Nakamura
2026-06-19 14:43:06 +09:00
parent 20434dcd11
commit c1e3d9d9a0
27 changed files with 4414 additions and 595 deletions
+126
View File
@@ -0,0 +1,126 @@
{
description = "cSBI development and runtime helpers";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ nixpkgs, ... }:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.mkShell {
packages = with pkgs; [
bun
docker
docker-compose
git
];
};
}
);
apps = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
composeUp = pkgs.writeShellApplication {
name = "csbi-compose-up";
runtimeInputs = [
pkgs.docker-compose
];
text = ''
exec docker-compose up "$@"
'';
};
in
{
default = {
type = "app";
program = "${composeUp}/bin/csbi-compose-up";
meta.description = "Run cSBI with docker-compose";
};
compose-up = {
type = "app";
program = "${composeUp}/bin/csbi-compose-up";
meta.description = "Run cSBI with docker-compose";
};
}
);
nixosModules.default =
{
config,
lib,
...
}:
let
cfg = config.services.csbie;
in
{
options.services.csbie = {
enable = lib.mkEnableOption "cSBI";
image = lib.mkOption {
type = lib.types.str;
default = "git.yutakobayashi.com/nakasyou/csbi:latest";
description = "Container image to run.";
};
envFile = lib.mkOption {
type = lib.types.path;
description = "Environment file passed to the container.";
};
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/csbie";
description = "Host directory mounted at /app/data.";
};
port = lib.mkOption {
type = lib.types.port;
default = 18787;
description = "Host port exposed for cSBI.";
};
};
config = lib.mkIf cfg.enable {
virtualisation.oci-containers.backend = lib.mkDefault "docker";
systemd.tmpfiles.rules = [
"d ${cfg.dataDir} 0750 root root -"
];
virtualisation.oci-containers.containers.csbie = {
image = cfg.image;
ports = [
"${toString cfg.port}:8787"
];
environmentFiles = [
cfg.envFile
];
volumes = [
"${cfg.dataDir}:/app/data"
];
};
};
};
};
}