-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathflake.nix
125 lines (115 loc) · 4.46 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
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;
our-packages = self.packages.${system};
workspaceRoot = ./.;
};
evap-dev = evap.override (prev: { dependency-groups = (prev.dependency-groups or [ ]) ++ [ "dev" ]; });
evap-frontend-dev = evap-dev.overrideAttrs (prev: { nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ (with pkgs; [ firefox geckodriver ]); });
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
'';
};
build-dist = pkgs.writeShellApplication {
name = "build-dist";
runtimeInputs = with pkgs; [ nodejs gettext git ];
text =
let
python-dev = self.devShells.${system}.evap-dev.passthru.venv;
python-build = self.packages.${system}.python3.withPackages (ps: [ ps.build ]);
in
''
set -x
npm ci
${python-dev}/bin/python ./manage.py compilemessages
${python-dev}/bin/python ./manage.py scss --production
${python-dev}/bin/python ./manage.py ts compile --fresh
${python-build}/bin/python -m build
'';
};
clean-setup = pkgs.writeShellApplication {
name = "clean-setup";
runtimeInputs = with pkgs; [ git ];
text = ''
read -r -p "Delete node_modules/, data/, generated CSS and JS files in evap/static/, and evap/localsettings.py? [y/N] "
[[ "$REPLY" =~ ^[Yy]$ ]] || exit 1
git clean -f -X evap/static/ node_modules/ data/ evap/localsettings.py
'';
};
});
};
}