-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
80 lines (63 loc) · 1.9 KB
/
flake.nix
File metadata and controls
80 lines (63 loc) · 1.9 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
{
description = "Flake Dependencies for my C/CPP template for building with Zig. Generated with AI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
};
outputs = {
self,
nixpkgs,
}: let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
zigCompileCommands = pkgs.fetchFromGitHub {
owner = "the-argus";
repo = "zig-compile-commands";
rev = "70fb439897e12cae896c071717d7c9c382918689";
sha256 = "dUtfifueNJkwBvbossc7Eohv6QbH+9vzCiMReghOgu8=";
};
dependencies = with pkgs; [
zig_0_15
rocmPackages.clang
];
developmentTools = with pkgs; [
lldb_20
gdb
];
in {
devShells.x86_64-linux.default = pkgs.mkShell {
name = "clang-zig-shell";
buildInputs = dependencies ++ developmentTools;
shellHook = ''
zig build cmds;
echo "🔧 CPP/C Template.Zig dev shell (Nixpkgs 25.05)";
'';
};
packages.x86_64-linux.default = pkgs.stdenv.mkDerivation {
pname = "cpp.zig";
version = "1.0";
src = ./.;
buildInputs = dependencies;
env = {
HOME = "$PWD";
ZIG_GLOBAL_CACHE_DIR = "$PWD/.cache";
ZIG_LOCAL_CACHE_DIR = "$PWD/.zig-cache";
};
preBuild = ''
'';
buildPhase = ''
mkdir -p $ZIG_GLOBAL_CACHE_DIR/p/zig_compile_commands-0.0.1-OZg5-ULBAABTh3NXO3WXoSUX1474ez0EouuoT2yDANhz
cp -r ${zigCompileCommands}/* $ZIG_GLOBAL_CACHE_DIR/p/zig_compile_commands-0.0.1-OZg5-ULBAABTh3NXO3WXoSUX1474ez0EouuoT2yDANhz/
zig build -Dbuild-static -Dbuild-dynamic;
'';
installPhase = ''
mkdir -p $out/bin
cp -r $PWD/zig-out/bin/zig-compiled $out/bin/cpp.zig
mkdir -p $out/lib
cp -r $PWD/zig-out/lib/* $out/lib/
'';
};
apps.x86_64-linux."cpp.zig" = {
type = "app";
program = "${self.packages.x86_64-linux.default}/bin/cpp.zig";
};
};
}