forked from nikhiljohn10/telegram-bot-worker
-
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathflake.nix
More file actions
106 lines (100 loc) · 2.97 KB
/
flake.nix
File metadata and controls
106 lines (100 loc) · 2.97 KB
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Or your preferred channel
};
outputs =
inputs@{ self, nixpkgs, ... }:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(
system:
function (
import nixpkgs {
inherit system;
# overlays = [ ... ]; # You can add overlays here if needed
# config = { ... }; # Or pkgs configuration
}
)
);
in
rec {
devShell = forAllSystems (
pkgs:
pkgs.mkShell {
name = "my-dev-environment";
buildInputs = with pkgs; [
nodejs_latest
nodePackages_latest.typescript-language-server
nodePackages_latest.prettier
vscode-langservers-extracted
];
# You can add shell hooks or environment variables here too
# shellHook = ''
# echo "Welcome to the development shell!"
# export MY_VAR="hello"
# '';
}
);
devShells = devShell;
packages = forAllSystems (pkgs: {
dockerImage = pkgs.dockerTools.buildImage {
name = "cf-workers-telegram-bot";
tag = "latest";
fromImage = pkgs.dockerTools.pullImage {
imageName = "jacoblincool/workerd";
imageDigest = "sha256:9ef73cacee85040a3c742b22ca0b8ee527d20465af58d4408f024cec1caf347c";
sha256 = "sha256-7Ee5kG8qvGIzk3uyE/35fojl/qbsBvuBquJBWZGIqvA=";
};
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
(pkgs.stdenv.mkDerivation {
name = "docker-root";
buildCommand = ''
mkdir -p $out/worker
cp ${./worker.capnp} $out/worker/worker.capnp
cp -r ${self.packages.${pkgs.system}.default}/* $out/
'';
})
];
};
config = {
Cmd = [
"/workerd"
"serve"
"/worker/worker.capnp"
];
WorkingDir = "/";
};
};
default = pkgs.buildNpmPackage {
name = "cf-workers-telegram-bot";
src = ./.;
npmDepsHash = "sha256-tlxWjtGMnTTMS4or/hZuWEoe+DI6eZRHbOKLsXx/LIY=";
installPhase = ''
runHook preInstall
mkdir -p $out/worker
cp -r dist/* $out/worker
runHook postInstall
'';
};
});
apps = forAllSystems (pkgs: {
default = {
type = "app";
program = "${pkgs.writeScriptBin "run-worker" ''
#!/bin/sh
workerd serve ${self.packages.${pkgs.system}.default}/worker.mjs "$@"
''}/bin/run-worker";
};
});
};
}