A collection of utilities for the Daggerheart SRD
katari.fyi
daggerheart
ttrpg
gleam
api
1{
2 inputs = {
3 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4 };
5
6 outputs = {nixpkgs, ...} @ inputs: let
7 lib = nixpkgs.lib;
8 supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
9 forEachSupportedSystem = f:
10 lib.genAttrs supportedSystems (system:
11 f {
12 pkgs = import nixpkgs {inherit system;};
13 });
14 in {
15 devShells = forEachSupportedSystem ({pkgs}: {
16 default = pkgs.mkShell {
17 packages = with pkgs; [
18 gleam
19 erlang_28
20 beam28Packages.rebar3
21 jq
22 ];
23 };
24 });
25 apps = forEachSupportedSystem ({pkgs}: let
26 cdInto = service: ''
27 rootDir=$(jj --ignore-working-copy root || git rev-parse --show-toplevel) || (echo "error: can't find repo root?"; exit 1)
28 cd "$rootDir/${service}"
29 '';
30 # TODO: dedup depencency decl.
31 runtimeInputs = with pkgs; [
32 gleam
33 erlang_28
34 beam28Packages.rebar3
35 ];
36 in {
37 # TODO: Check if env vars are already set
38 # TODO: provide watch-{api,web} for easier dev
39 api = {
40 type = "app";
41 program = "${(pkgs.writeShellApplication {
42 inherit runtimeInputs;
43 name = "run-api";
44 text = ''
45 ${cdInto "api"}
46 export KATARI_SRD_PATH="$rootDir/srd"
47 ${pkgs.gleam}/bin/gleam run
48 '';
49 })}/bin/run-api";
50 };
51 web = {
52 type = "app";
53 program = "${(pkgs.writeShellApplication {
54 inherit runtimeInputs;
55 name = "run-web";
56 text = ''
57 ${cdInto "web"}
58 export KATARI_SRD_PATH="$rootDir/srd"
59 export KATARI_API_DOCS=true
60 ${pkgs.gleam}/bin/gleam run
61 '';
62 })}/bin/run-web";
63 };
64 test-api = {
65 type = "app";
66 program = "${(pkgs.writeShellApplication {
67 inherit runtimeInputs;
68 name = "test-api";
69 text = ''
70 ${cdInto "api"}
71 export KATARI_SRD_PATH="$rootDir/srd"
72 ${pkgs.gleam}/bin/gleam test
73 '';
74 })}/bin/test-api";
75 };
76 test-web = {
77 type = "app";
78 program = "${(pkgs.writeShellApplication {
79 inherit runtimeInputs;
80 name = "test-web";
81 text = ''
82 ${cdInto "web"}
83 export KATARI_SRD_PATH="$rootDir/srd"
84 export KATARI_API_DOCS=true
85 ${pkgs.gleam}/bin/gleam test
86 '';
87 })}/bin/test-web";
88 };
89 });
90 };
91}