This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
70 lines (63 loc) · 2.32 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
{
description = "API for lunarbox";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-22.11";
flake-utils.url = "github:numtide/flake-utils";
extra-container.url = "github:erikarvstedt/extra-container";
extra-container.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, extra-container }:
flake-utils.lib.eachSystem extra-container.lib.supportedSystems
(system: {
devShell =
let pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
yarn
];
};
packages.default = extra-container.lib.buildContainers {
inherit system;
config.containers.api-dev = {
extra.addressPrefix = "10.250.0";
config = { pkgs, ... }: {
networking.firewall.allowedTCPPorts = [ 8090 ];
# Taken from
# - [the wiki](https://nixos.wiki/wiki/PostgreSQL)
# - [my old config](https://github.com/Mateiadrielrafael/everything-nix/blob/v2.0.0/modules/applications/postgres.nix)
services.postgresql = {
enable = true;
package = pkgs.postgresql_15;
enableTCPIP = true;
authentication = pkgs.lib.mkOverride 10 ''
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
initialScript = pkgs.writeText "backend-initScript" ''
CREATE ROLE adrielus WITH
LOGIN
SUPERUSER
INHERIT
CREATEDB
CREATEROLE
REPLICATION;
CREATE DATABASE lunarbox;
GRANT ALL PRIVILEGES ON DATABASE lunarbox TO adrielus;
'';
};
environment.systemPackages = with pkgs; [ yarn nodejs ];
systemd.services.lunarbox-api-dev = {
wantedBy = [ "multi-user.target" ];
script = ''
yarn install --frozen-lockfile
yarn dev
'';
};
};
};
};
});
}