forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
86 lines (83 loc) · 3.04 KB
/
Copy pathflake.nix
File metadata and controls
86 lines (83 loc) · 3.04 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
{
description = "The Slang Shading Language and Compiler";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
llvmPackages = pkgs.llvmPackages_21;
# We want to use Clang instead of GCC because it seems to behave better
# with LLDB, so we use `mkShell` with the LLVM stdenv
mkShell = pkgs.mkShell.override { stdenv = llvmPackages.stdenv; };
# We must use the clangd from `clang-tools` package so that it is
# wrapped properly. This is harder than it seems becase there is a
# clangd in clang-unwrapped, which would normally come first thanks to
# the cc-wrapper/setup-hook adding ${clang-unwrapped}/bin to PATH very
# early in `mkDerivation` setup. We work around this using a shell hook
# (below) as that executes very late in shell instantiation and can
# therefore override cc-wrapper.
#
# See https://github.com/NixOS/nixpkgs/issues/76486 for the upstream bug.
clangd-only = (
pkgs.linkFarm "clangd-only" [
{
name = "bin/clangd";
# New enough to support `HeaderInsertion: Never` in `.clangd`.
path = "${llvmPackages.clang-tools}/bin/clangd";
}
]
);
in
{
devShell = mkShell {
buildInputs = [
# Pull in only clang-format from clang-tools 17. This matches the
# version used in CI.
(pkgs.linkFarm "clang-format-17" [
{
name = "bin/clang-format";
path = "${pkgs.llvmPackages_17.clang-tools}/bin/clang-format";
}
])
pkgs.cmake
pkgs.gersemi
llvmPackages.lldb
pkgs.ninja
pkgs.nixfmt-rfc-style
pkgs.prettier
pkgs.python3
pkgs.shfmt
pkgs.vulkan-loader # Ensure this gets built to use in library path.
pkgs.xorg.libX11
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
# In addition to this, running the Vulkan tests on Linux distros
# other than NixOS may require the use of nixGL:
# https://github.com/nix-community/nixGL
pkgs.vulkan-loader
# Needed for the prebuilt LLVM
pkgs.libz
pkgs.zstd
# Despite requiring this packages (slang) to be built with Clang,
# the prebuilt libslang-llvm.so is actually linked against GCC's
# libstdc++.so.6
pkgs.stdenv.cc.cc.lib
];
# Use a shell hook to make sure the wrapped clangd is in the path
# before the unwrapped one included by llvmPackages.stdenv
shellHook = ''
PATH="${clangd-only}/bin:$PATH"
'';
};
}
);
}