-
Notifications
You must be signed in to change notification settings - Fork 147
/
flake.nix
95 lines (87 loc) · 3.08 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
{
description = "EvaP";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
uv2nix = {
url = "github:adisbladis/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake.url = "github:juspay/services-flake";
};
outputs = { self, nixpkgs, ... }@inputs:
let
lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems = lib.genAttrs systems;
pkgsFor = lib.genAttrs systems (system: import nixpkgs { inherit system; });
in
{
devShells = forAllSystems (system:
let
pkgs = pkgsFor.${system};
dependency-groups = if pkgs.stdenv.isDarwin then [ "psycopg-c" ] else [ "psycopg-binary" ];
in
rec {
evap = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) python3;
inherit (inputs) pyproject-nix uv2nix pyproject-build-systems;
inherit dependency-groups;
workspaceRoot = ./.;
};
evap-dev = evap.override (prev: { dependency-groups = (prev.dependency-groups or [ ]) ++ [ "dev" ]; });
default = evap-dev;
impure = pkgs.mkShell {
packages = with pkgs; [
(self.packages.${system}.python3)
uv
postgresql
];
shellHook = ''
unset PYTHONPATH
'';
};
});
packages = forAllSystems (system:
let
pkgs = pkgsFor.${system};
make-process-compose = only-databases: (import inputs.process-compose-flake.lib { inherit pkgs; }).makeProcessCompose {
modules = [
inputs.services-flake.processComposeModules.default
(import
./nix/services.nix
{
inherit pkgs only-databases;
inherit (inputs) services-flake;
inherit (self.devShells.${system}.evap.passthru) venv;
})
];
};
in
rec {
python3 = pkgs.python310;
services = make-process-compose true;
services-full = make-process-compose false;
wait-for-pc = pkgs.writeShellApplication {
name = "wait-for-pc";
runtimeInputs = [ pkgs.jq ];
text = ''
while [ "$(${lib.getExe services} process list -o json 2>/dev/null | jq '.[] |= .is_ready == "Ready" or .status == "Completed" or .status == "Disabled" | all')" != "true" ]; do
sleep 1
done
'';
};
});
};
}