-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
152 lines (137 loc) · 4.25 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
{
description = "Build config-lsp";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
gomod2nix = {
url = "github:tweag/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "utils";
};
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, gomod2nix }:
utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
"x86_64-windows"
"aarch64-windows"
] (system:
let
version = "0.1.2"; # CI:CD-VERSION
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
go = prev.go_1_22;
buildGoModule = prev.buildGo122Module;
})
gomod2nix.overlays.default
];
};
inputs = [
pkgs.go_1_22
];
serverUncompressed = pkgs.buildGoModule {
nativeBuildInputs = inputs;
pname = "github.com/Myzel394/config-lsp";
version = version;
src = ./server;
vendorHash = "sha256-eO1eY+2XuOCd/dKwgFtu05+bnn/Cv8ZbUIwRjCwJF+U=";
ldflags = [ "-s" "-w" ];
checkPhase = ''
go test -v $(pwd)/...
'';
};
server = pkgs.stdenv.mkDerivation {
name = "config-lsp-${version}";
src = serverUncompressed;
buildInputs = [
pkgs.upx
];
buildPhase = ''
mkdir -p $out/bin
cp $src/bin/config-lsp $out/bin/
chmod +rw $out/bin/config-lsp
# upx is currently not supported for darwin
if [ "${system}" != "x86_64-darwin" ] && [ "${system}" != "aarch64-darwin" ]; then
upx --ultra-brute $out/bin/config-lsp
fi
'';
};
in {
packages = {
default = server;
"vs-code-extension-bare" = let
name = "config-lsp";
node-modules = pkgs.mkYarnPackage {
src = ./vs-code-extension;
name = name;
packageJSON = ./vs-code-extension/package.json;
yarnLock = ./vs-code-extension/yarn.lock;
yarnNix = ./vs-code-extension/yarn.nix;
buildPhase = ''
yarn --offline run compile:prod
'';
installPhase = ''
mkdir -p extension
# No idea why this is being created
rm deps/${name}/config-lsp
cp -rL deps/${name}/. extension
mkdir -p $out
cp -r extension/. $out
'';
distPhase = "true";
buildInputs = [
pkgs.vsce
];
};
in node-modules;
"vs-code-extension" = let
name = "config-lsp";
node-modules = pkgs.mkYarnPackage {
src = ./vs-code-extension;
name = name;
packageJSON = ./vs-code-extension/package.json;
yarnLock = ./vs-code-extension/yarn.lock;
yarnNix = ./vs-code-extension/yarn.nix;
buildPhase = ''
yarn --offline run compile:prod
'';
installPhase = ''
mkdir -p extension
# No idea why this is being created
rm deps/${name}/config-lsp
cp -rL deps/${name}/. extension
cp ${server}/bin/config-lsp extension/out/config-lsp
cd extension && ${pkgs.vsce}/bin/vsce package
mkdir -p $out
cp *.vsix $out
'';
distPhase = "true";
buildInputs = [
pkgs.vsce
];
};
in node-modules;
};
devShells.default = pkgs.mkShell {
buildInputs = inputs ++ (with pkgs; [
mailutils
wireguard-tools
antlr
]) ++ (if pkgs.stdenv.isLinux then with pkgs; [
postfix
] else []);
};
devShells."vs-code-extension" = pkgs.mkShell {
buildInputs = [
pkgs.nodejs
pkgs.vsce
pkgs.yarn2nix
];
};
}
);
}