-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
87 lines (75 loc) · 2.91 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
{
description = "A smart redirecting gateway for various frontend services";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, naersk, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
naersk' = pkgs.callPackage naersk { };
# This needed to remove dependency on services.json file and avoid useless rebuilds
constructed-source = pkgs.runCommand "constructed-source" { } ''
mkdir -p $out
cp -r ${./fastside} $out/fastside
cp -r ${./fastside-actualizer} $out/fastside-actualizer
cp -r ${./fastside-shared} $out/fastside-shared
cp ${./Cargo.toml} $out/Cargo.toml
cp ${./Cargo.lock} $out/Cargo.lock
'';
fastside = naersk'.buildPackage {
name = "fastside-0.2.0";
src = constructed-source;
nativeBuildInputs = with pkgs; [ mold ];
NIX_CFLAGS_LINK = " -fuse-ld=mold";
};
fastside-baked-services = pkgs.writeShellScriptBin "fastside-baked-services" ''
export FS__SERVICES_PATH=${./services.json}
${fastside}/bin/fastside $@
'';
fastside-docker = pkgs.dockerTools.buildLayeredImage {
name = "fastside";
tag = "latest";
contents = [ fastside ];
config = { Cmd = [ "/bin/fastside" "serve" "-l" "0.0.0.0:8080" ]; };
};
fastside-docker-baked-services = pkgs.dockerTools.buildLayeredImage {
name = "fastside";
tag = "latest";
contents = [ fastside fastside-baked-services ];
config = { Cmd = [ "/bin/fastside-baked-services" "serve" "-l" "0.0.0.0:8080" ]; };
};
services = pkgs.runCommand "generate-services" { } ''
cat '${./services.json}' > $out
'';
in rec {
packages = {
default = fastside;
fastside = fastside;
fastside-baked-services = fastside-baked-services;
fastside-docker = fastside-docker;
fastside-docker-baked-services = fastside-docker-baked-services;
services = services;
};
apps = rec {
default = fastside;
fastside = {
type = "app";
program = "${packages.fastside}/bin/fastside";
};
fastside-backed-services = {
type = "app";
program = "${packages.fastside-baked-services}/bin/fastside-baked-services";
};
actualizer = {
type = "app";
program = "${packages.fastside}/bin/fastside-actualizer";
};
fastside-actualizer = actualizer;
};
devShells.default = import ./shell.nix { inherit pkgs; };
});
}