-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathflake.nix
49 lines (47 loc) · 1.49 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
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
outputs = {
self,
nixpkgs,
}: let
sys = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${sys};
buildNpmPackage = pkgs.callPackage ./build-npm-package.nix {};
mkApp = exe: {
type = "app";
program = toString exe;
};
apiAddr = "127.0.0.1:8000";
apiHost = "http://${apiAddr}";
in {
formatter.${sys} = pkgs.alejandra;
packages.${sys} = {
python = pkgs.python3.withPackages (p: with p; [django django-cors-headers pillow schema]);
website = buildNpmPackage {
src = ./frontend/website;
extraEnv.VITE_SNOW_API_SERVER = "${apiHost}/api";
};
};
apps.${sys} = let
inherit (self.packages.${sys}) python;
api = pkgs.writeShellScript "snow-api" ''
export SNOW_API_HOST="${apiHost}"
export SNOW_API_WORKDIR=$PWD
${python}/bin/python ${self}/manage.py migrate
${python}/bin/python ${self}/manage.py runserver "${apiAddr}"
'';
backend-test = pkgs.writeShellScript "snow-test" ''
export SNOW_API_HOST="${apiHost}"
export SNOW_API_WORKDIR=$PWD
${python}/bin/python ${self}/manage.py test "$@"
'';
website = pkgs.writeShellScript "snow-website" ''
${python}/bin/python -m http.server --directory ${self.packages.${sys}.website} -b 127.0.0.1 5173
'';
in {
api = mkApp api;
website = mkApp website;
backend-test = mkApp backend-test;
};
};
}