-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
128 lines (116 loc) · 3.39 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
{
description = "A flake for Zig";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
# For upgrade use `nix flake update zig`
zig = {
url = "github:mitchellh/zig-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
# zls = {
# url = "github:zigtools/zls";
# inputs = {
# nixpkgs.follows = "nixpkgs";
# flake-utils.follows = "flake-utils";
# zig-overlay.follows = "zig";
# };
# };
zigscient-src = {
url = "github:llogick/zigscient";
flake = false;
};
};
outputs =
inputs@{ self
, nixpkgs
, flake-utils
, ...
}:
let
# zlsBinName = "zls";
zlsBinName = "zigscient";
overlays = [
(final: prev: rec {
zig = inputs.zig.packages.${prev.system}.master;
# zls = inputs.zls.packages.${prev.system}.zls;
zls = prev.stdenvNoCC.mkDerivation {
name = "zigscient";
version = "master";
src = "${inputs.zigscient-src}";
nativeBuildInputs = [ zig ];
dontConfigure = true;
dontInstall = true;
doCheck = true;
buildPhase = ''
mkdir -p .cache
zig build install --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache -Dcpu=baseline -Doptimize=ReleaseSafe --prefix $out
'';
checkPhase = ''
zig build test --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache -Dcpu=baseline
'';
};
})
];
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit overlays system; };
buildInputs = with pkgs; [
zig
zls
xmlstarlet
coreutils
# c to ast json
clang
# For wireshark build
bash
git
c-ares
bison
flex
ccache
cmake
glib
libgcrypt
libgpg-error
libpcap
pcre2
perl
pkg-config
python3
speexdsp
];
in
{
# run: `nix develop`
devShells = {
default = pkgs.mkShell {
inherit buildInputs;
};
# Update IDEA paths. Use only if nix installed in whole system.
# run: `nix develop \#idea`
idea = pkgs.mkShell {
inherit buildInputs;
shellHook = pkgs.lib.concatLines [
''
# Replace Go Lint path
if [[ -f .idea/zigbrains.xml ]]; then
xmlstarlet ed -L -u '//project/component[@name="ZLSSettings"]/option[@name="zlsPath"]/@value' -v '${pkgs.zls}/bin/${zlsBinName}' .idea/zigbrains.xml
xmlstarlet ed -L -u '//project/component[@name="ZigProjectSettings"]/option[@name="toolchainPath"]/@value' -v '${pkgs.zig}/bin' .idea/zigbrains.xml
xmlstarlet ed -L -u '//project/component[@name="ZigProjectSettings"]/option[@name="explicitPathToStd"]/@value' -v '${pkgs.zig}/lib' .idea/zigbrains.xml
fi
exit 0
''
];
};
};
# run: `nix fmt .`
formatter = pkgs.nixfmt-rfc-style;
}
);
}