-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix.tpl
102 lines (87 loc) · 3.51 KB
/
flake.nix.tpl
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
{
description = "KCL toolchain flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
getArch = system:
if system == "x86_64-linux" then "linux-amd64"
else if system == "aarch64-linux" then "linux-arm64"
else if system == "x86_64-darwin" then "darwin-amd64"
else if system == "aarch64-darwin" then "darwin-arm64"
else throw "Unsupported system: ${system}";
cli = pkgs.stdenv.mkDerivation rec {
pname = "kcl-cli";
version = "{{ cli_version }}";
src = pkgs.fetchurl {
url = "https://github.com/kcl-lang/cli/releases/download/v${version}/kcl-v${version}-${getArch system}.tar.gz";
sha256 = {
x86_64-linux = "{{ cli_hash_x86_64_linux }}";
aarch64-linux = "{{ cli_hash_aarch64_linux }}";
x86_64-darwin = "{{ cli_hash_x86_64_darwin }}";
aarch64-darwin = "{{ cli_hash_aarch64_darwin }}";
}.${system};
};
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin
tar -xzf $src -C $out/bin
# Ensure the file is named 'kcl'
if [ ! -f $out/bin/kcl ]; then
mv $out/bin/kcl-cli $out/bin/kcl || true
fi
chmod +x $out/bin/kcl
'';
};
language-server = pkgs.stdenv.mkDerivation rec {
pname = "kcl-language-server";
version = "{{ kcl_version }}";
src = pkgs.fetchurl {
url = "https://github.com/kcl-lang/kcl/releases/download/v${version}/kclvm-v${version}-${getArch system}.tar.gz";
sha256 = {
x86_64-linux = "{{ language_server_hash_x86_64_linux }}";
aarch64-linux = "{{ language_server_hash_aarch64_linux }}";
x86_64-darwin = "{{ language_server_hash_x86_64_darwin }}";
aarch64-darwin = "{{ language_server_hash_aarch64_darwin }}";
}.${system};
};
installPhase = ''
mkdir -p $out/bin
cp bin/kcl-language-server $out/bin/
'';
};
getArchKubectlKcl = system:
if system == "x86_64-linux" then "linux-amd64"
else if system == "aarch64-linux" then "linux-arm64"
else if system == "x86_64-darwin" then "macos-amd64"
else if system == "aarch64-darwin" then "macos-arm64"
else throw "Unsupported system: ${system}";
kubectl-kcl = pkgs.stdenv.mkDerivation rec {
pname = "kubectl-kcl";
version = "{{ kubectl_kcl_version }}";
src = pkgs.fetchurl {
url = "https://github.com/kcl-lang/kubectl-kcl/releases/download/v${version}/kubectl-kcl-${getArchKubectlKcl system}.tgz";
sha256 = {
x86_64-linux = "{{ kubectl_kcl_hash_x86_64_linux }}";
aarch64-linux = "{{ kubectl_kcl_hash_aarch64_linux }}";
x86_64-darwin = "{{ kubectl_kcl_hash_x86_64_darwin }}";
aarch64-darwin = "{{ kubectl_kcl_hash_aarch64_darwin }}";
}.${system};
};
installPhase = ''
mkdir -p $out/bin
cp bin/kubectl-kcl $out/bin/
'';
};
in
{
default = {
inherit cli language-server kubectl-kcl;
};
}
);
}