-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
173 lines (162 loc) · 5.82 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
description = "Camunda RCC Executor";
nixConfig = {
extra-trusted-public-keys =
"vasara-bpm.cachix.org-1:T18iQZQvYDy/6VdGmttnkkq7rYi3JP0S1RjjdnXNu/4=";
extra-substituters = "https://vasara-bpm.cachix.org";
};
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
npmlock2nix = {
url = "github:nix-community/npmlock2nix";
flake = false;
};
vasara-bpm = {
url = "gitlab:vasara-bpm/pkgs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, ... }@inputs:
inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs-unstable = import inputs.nixpkgs { inherit system; };
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(final: prev: {
nodejs-16_x = final.nodejs; # for npmlock2nix.v2
npmlock2nix =
pkgs.callPackage inputs.npmlock2nix { inherit pkgs; };
})
];
};
gitignoreSource = inputs.gitignore.lib.gitignoreSource;
packagesSource = builtins.filterSource (path: type:
(baseNameOf path) == "package.json" || (baseNameOf path)
== "package-lock.json") ./.;
package-name =
(builtins.fromJSON (builtins.readFile ./package.json)).name;
call-name = "carrot-rcc";
in {
apps.default = {
type = "app";
program = self.packages.${system}.default + "/bin/${call-name}";
};
packages.node_modules_dev =
pkgs.npmlock2nix.v2.node_modules { src = packagesSource; };
packages.node_modules = pkgs.npmlock2nix.v2.node_modules {
src = packagesSource;
postBuild = ''
npm prune --omit=dev
'';
};
packages.default = pkgs.stdenv.mkDerivation rec {
name = call-name;
# For now, we whitelist source files to prevent vagrant updates causing rebuild
src = builtins.filterSource (path: type:
(baseNameOf path) == "carrot_rcc.ts" || (baseNameOf path)
== "carrot_rcc_lib.ts" || (baseNameOf path) == "Camunda.ts"
|| (baseNameOf path) == "rollup.config.js" || (baseNameOf path)
== "node-run-packages.nix" || (baseNameOf path) == "package.json"
|| (baseNameOf path) == "package-lock.json") ./.;
buildPhase = ''
source $stdenv/setup;
cp -a ${
self.packages.${system}.node_modules_dev
}/node_modules node_modules
node_modules/.bin/rollup -c rollup.config.js
'';
installPhase = ''
source $stdenv/setup;
mkdir -p $out/bin
install ${call-name} $out/bin/${call-name}
'';
postFixup = ''
wrapProgram $out/bin/carrot-rcc \
--prefix PATH : ${pkgs.lib.makeBinPath propagatedBuildInputs}
'';
buildInputs = [ pkgs.makeWrapper ];
propagatedBuildInputs = [ pkgs.nodejs ];
};
packages.image = pkgs.dockerTools.streamLayeredImage {
name = "vasara-bpm/carrot-rcc/${call-name}";
tag = "latest";
created = "now";
maxLayers = 120;
contents = [
(pkgs.buildEnv {
name = "image-contents";
paths = [
pkgs.bashInteractive
pkgs.coreutils
pkgs.curl
pkgs.dejavu_fonts
pkgs.dockerTools.caCertificates
pkgs.dockerTools.fakeNss
pkgs.findutils
pkgs.micromamba
pkgs.tini
(pkgs.stdenv.mkDerivation {
name = "fonts.conf";
src = (pkgs.makeFontsConf {
fontDirectories = [ pkgs.dejavu_fonts ];
});
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/etc/fonts
cp -a $src $out/etc/fonts/fonts.conf
'';
})
inputs.vasara-bpm.packages.${system}.rcc
self.packages.${system}.default
# extra paths to bloat image, but seen required in LD_LIBRARY_PATH
pkgs.alsaLib
pkgs.dbus-glib
pkgs.libGL
];
pathsToLink = [ "/etc" "/sbin" "/bin" ];
})
];
extraCommands = ''
mkdir -p usr/bin && ln -s /sbin/env usr/bin/env
mkdir -p tmp && chmod a+rxwt tmp
mkdir -p lib64 && ln -s ${pkgs.glibc}/lib/ld-linux-x86-64.so.2 lib64
'';
config = {
Entrypoint = [
"${pkgs.tini}/bin/tini"
"--"
"${self.packages.${system}.default}/bin/${call-name}"
];
Env = [
"TMPDIR=/tmp"
"HOME=/tmp"
"LD_LIBRARY_PATH=${pkgs.dbus-glib}/lib:${pkgs.libGL}/lib:${pkgs.alsaLib}/lib"
];
Labels = { };
User = "nobody";
};
};
devShells.default = pkgs.mkShell {
buildInputs =
[ pkgs-unstable.cachix pkgs.entr pkgs.openssl pkgs.nodejs pkgs.jq ];
};
devShells.with-podman =
inputs.vasara-bpm.devShells.${system}.podman.overrideAttrs (old: {
buildInputs = old.buildInputs
++ self.devShells.${system}.default.buildInputs;
});
formatter = pkgs.nixfmt;
});
}