-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
94 lines (90 loc) · 2.85 KB
/
flake.nix
File metadata and controls
94 lines (90 loc) · 2.85 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
87
88
89
90
91
92
93
94
{
description = "Peridot devenv";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
build-tools = pkgs.writeShellApplication {
name = "build-tools";
runtimeInputs = [
pkgs.rustup
# for buidling cdeps
pkgs.cmake
pkgs.ninja
];
text = ''pushd "$PROJECT_ROOT"/tools; cargo build; popd'';
};
deps = [
pkgs.rustup
# for building cdeps
pkgs.cmake
pkgs.ninja
pkgs.pkg-config
pkgs.clang
pkgs.llvmPackages.libclang
# required libs for building engine
pkgs.udev
pkgs.wayland
pkgs.pulseaudio
pkgs.pipewire
pkgs.vulkan-loader
# required for some asset processing
pkgs.shaderc
# required for workflow generator(also included in githooks)
pkgs.stack
# helper scripts
build-tools
# debugging
pkgs.vulkan-validation-layers
];
nativeDeps = [ pkgs.pkg-config ];
shellSetCommonEnvVars = ''
export PROJECT_ROOT=$(dirname $(realpath ./flake.nix))
# set library search paths for thirdparty
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PROJECT_ROOT/thirdparty/slang/source-repo/build/RelWithDebInfo/lib:$PROJECT_ROOT/thirdparty/ktx/source-repo/build
# peridot specific env vars for development
export PERIDOT_CLI_BUILTIN_ASSETS_PATH=$PROJECT_ROOT/builtin-assets
export PERIDOT_CLI_CRADLE_BASE=$PROJECT_ROOT/cradle
'';
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
in
{
devShells."${system}" = {
default = pkgs.mkShell {
buildInputs = deps;
nativeBuildInputs = nativeDeps;
shellHook = shellSetCommonEnvVars;
# このへんはないとエラーになる
inherit LIBCLANG_PATH;
};
fish =
let
fishPrehook = pkgs.writeScriptBin "startup" ''
# prepend devenv prompt
functions -c fish_prompt __peridot_fish_prompt_org
function fish_prompt
# preserve status code
set -l last_status $status
printf "[Peridot] "
echo "exit $last_status" | .
__peridot_fish_prompt_org
end
'';
in
pkgs.mkShell {
buildInputs = deps ++ [ pkgs.fish ];
nativeBuildInputs = nativeDeps;
shellHook = ''
${shellSetCommonEnvVars}
exec ${pkgs.fish.outPath}/bin/fish -C "source ${fishPrehook}/bin/startup"
'';
# このへんはないとエラーになる
inherit LIBCLANG_PATH;
};
};
};
}