2024-09-25 23:03:56 -04:00
|
|
|
{
|
|
|
|
description = "C/C++ environment";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
treefmt-nix,
|
|
|
|
utils,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
utils.lib.eachDefaultSystem (
|
|
|
|
system: let
|
2024-09-30 19:49:44 -04:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2024-10-06 01:26:41 -04:00
|
|
|
config = {
|
|
|
|
allowUnfree = true;
|
|
|
|
allowUnsupportedSystem = true;
|
|
|
|
};
|
2024-09-30 19:49:44 -04:00
|
|
|
};
|
2024-09-25 23:03:56 -04:00
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
stdenv = with pkgs;
|
|
|
|
if hostPlatform.isLinux
|
|
|
|
then stdenvAdapters.useMoldLinker llvmPackages_18.libcxxStdenv
|
|
|
|
else llvmPackages_18.libcxxStdenv;
|
2024-09-25 23:03:56 -04:00
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
sources = import ./_sources/generated.nix {inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;};
|
2024-09-25 23:03:56 -04:00
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
mkPkg = name: pkgs.${name}.overrideAttrs {inherit (sources.${name}) pname version src;};
|
2024-09-25 23:03:56 -04:00
|
|
|
|
|
|
|
fmt = mkPkg "fmt";
|
|
|
|
|
2024-09-28 13:00:48 -04:00
|
|
|
deps = with pkgs; [
|
|
|
|
fmt
|
|
|
|
glfw
|
|
|
|
glm
|
2024-10-01 18:30:31 -04:00
|
|
|
shaderc
|
2024-09-28 13:00:48 -04:00
|
|
|
vulkan-extension-layer
|
|
|
|
vulkan-memory-allocator
|
|
|
|
vulkan-utility-libraries
|
|
|
|
vulkan-loader
|
|
|
|
vulkan-tools
|
|
|
|
];
|
2024-10-08 23:56:24 -04:00
|
|
|
in rec {
|
|
|
|
packages = rec {
|
|
|
|
graphics-test = stdenv.mkDerivation {
|
|
|
|
name = "graphics-test";
|
|
|
|
version = "0.1.0";
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = deps;
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
meson setup build
|
|
|
|
'';
|
2024-09-25 23:03:56 -04:00
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
buildPhase = ''
|
|
|
|
meson compile -C build
|
|
|
|
'';
|
2024-09-25 23:03:56 -04:00
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
mv build/graphics-test $out/bin/graphics-test
|
|
|
|
'';
|
2024-09-25 23:03:56 -04:00
|
|
|
};
|
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
default = graphics-test;
|
|
|
|
};
|
|
|
|
|
|
|
|
formatter = with pkgs;
|
|
|
|
treefmt-nix.lib.mkWrapper pkgs {
|
2024-09-25 23:03:56 -04:00
|
|
|
projectRootFile = "flake.nix";
|
|
|
|
programs = {
|
|
|
|
alejandra.enable = true;
|
|
|
|
|
|
|
|
clang-format = {
|
|
|
|
enable = true;
|
2024-10-08 23:56:24 -04:00
|
|
|
package = llvmPackages_18.clang-tools;
|
2024-09-25 23:03:56 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-08 23:56:24 -04:00
|
|
|
devShell = with pkgs;
|
|
|
|
mkShell.override {inherit stdenv;} {
|
2024-09-25 23:03:56 -04:00
|
|
|
packages =
|
|
|
|
[
|
|
|
|
alejandra
|
|
|
|
bear
|
2024-10-05 23:08:04 -04:00
|
|
|
(llvmPackages_18.clang-tools.override {enableLibcxx = true;})
|
2024-09-25 23:03:56 -04:00
|
|
|
lldb
|
|
|
|
meson
|
2024-10-05 23:08:04 -04:00
|
|
|
nil
|
2024-09-25 23:03:56 -04:00
|
|
|
ninja
|
|
|
|
nvfetcher
|
|
|
|
pkg-config
|
|
|
|
unzip
|
|
|
|
|
|
|
|
(writeScriptBin "build" "meson compile -C build")
|
|
|
|
(writeScriptBin "clean" "meson setup build --wipe")
|
|
|
|
(writeScriptBin "reconfigure" "meson setup build --reconfigure")
|
2024-09-26 17:18:45 -04:00
|
|
|
(writeScriptBin "run" "meson compile -C build && build/${packages.default.name}")
|
2024-09-25 23:03:56 -04:00
|
|
|
]
|
|
|
|
++ deps;
|
|
|
|
|
2024-09-28 14:54:39 -04:00
|
|
|
VULKAN_SDK = "${vulkan-headers}";
|
|
|
|
VK_LAYER_PATH = "${vulkan-validation-layers}/share/vulkan/explicit_layer.d";
|
2024-09-30 15:25:22 -04:00
|
|
|
VK_ICD_FILENAMES =
|
|
|
|
if stdenv.isDarwin
|
|
|
|
then "${darwin.moltenvk}/share/vulkan/icd.d/MoltenVK_icd.json"
|
2024-09-30 19:49:44 -04:00
|
|
|
else let
|
|
|
|
vulkanDir = "${mesa.drivers}/share/vulkan/icd.d";
|
|
|
|
vulkanFiles = builtins.filter (file: builtins.match ".*\\.json$" file != null) (builtins.attrNames (builtins.readDir vulkanDir));
|
|
|
|
vulkanPaths = lib.concatStringsSep ":" (map (file: "${vulkanDir}/${file}") vulkanFiles);
|
2024-10-06 18:34:42 -04:00
|
|
|
in "${linuxPackages_latest.nvidia_x11_vulkan_beta}/share/vulkan/icd.d/nvidia_icd.x86_64.json:${vulkanPaths}";
|
2024-09-28 14:54:39 -04:00
|
|
|
|
2024-09-28 13:00:48 -04:00
|
|
|
shellHook = ''
|
2024-10-05 23:08:04 -04:00
|
|
|
export PATH="${llvmPackages_18.clang-tools.override {enableLibcxx = true;}}/bin:$PATH"
|
2024-09-25 23:03:56 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
name = "C++";
|
|
|
|
};
|
2024-10-08 23:56:24 -04:00
|
|
|
}
|
2024-09-25 23:03:56 -04:00
|
|
|
);
|
|
|
|
}
|