-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
104 lines (99 loc) · 3.11 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
systems.url = "github:nix-systems/default";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
project-root = {
url = "file+file:///dev/null";
flake = false;
};
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux"];
imports = [
inputs.treefmt-nix.flakeModule
inputs.process-compose-flake.flakeModule
inputs.devshell.flakeModule
];
perSystem = {
config,
pkgs,
...
}: let
root = builtins.readFile inputs.project-root.outPath;
psql = pkgs.postgresql_16;
nodejs = pkgs.nodejs_22;
frontend = import ./frontend/frontend.nix {inherit inputs pkgs;};
backend = import ./backend/backend.nix {inherit inputs pkgs;};
backend-run = "${pkgs.deno}/bin/deno run --unstable-sloppy-imports --unstable-byonm -A";
in {
treefmt.config = {
projectRootFile = "flake.nix";
package = pkgs.treefmt;
programs = {
alejandra.enable = true;
deadnix.enable = true;
biome = {
enable = true;
settings.javascript.formatter = {
indentStyle = "space";
};
settings.json.formatter = {
indentStyle = "space";
};
};
};
};
devshells.default = {
packages = [
psql
nodejs
pkgs.bun
pkgs.deno
];
commands = [
{
name = "backend";
command = ''
cd ${root}/backend
${backend-run} src/index.ts
'';
}
{
name = "dev";
command = ''
cd ${root}
nix run
'';
help = "Start everything needed for fullstack development";
}
];
};
packages.frontend = frontend.packages.default {lastModified = builtins.toString inputs.self.lastModified;};
packages.backend = backend.packages.default;
packages.docker = backend.packages.docker;
process-compose.default.settings = {
environment = {
POSTGRESQL_URL = "postgresql://localhost/songbook";
};
processes = {
postgres.command = "${pkgs.nodejs}/bin/node backend/postgresql.mjs run";
backend = {
command = "${backend-run} --watch src/index.ts";
working_dir = "backend";
};
frontend = {
command = "${nodejs}/bin/npm run dev";
working_dir = "frontend";
};
};
};
};
};
}