Files
Archimedes/flake.nix
2025-05-12 16:35:42 -05:00

269 lines
7.2 KiB
Nix
Executable File

{
description = "Build Project Archimedes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
imgui = {
url = "github:ocornut/imgui?ref=docking";
flake = false;
};
clay = {
url = "github:nicbarker/clay";
flake = false;
};
};
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
Archimedes = {
examples = import ./ExampleApps.nix { inherit inputs; inherit pkgs; };
};
Modules = {
examples = import ./ExampleModules.nix { inherit inputs; inherit pkgs; };
ServerModule = pkgs.stdenvNoCC.mkDerivation {
name = "ServerModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/ServerModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DSERVERMODULE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ClientModule = pkgs.stdenvNoCC.mkDerivation {
name = "ClientModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/ClientModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
WindowModule = pkgs.stdenvNoCC.mkDerivation {
name = "WindowModule";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/WindowModule/*.cpp \
-fpic -shared \
-I include \
-DRENDERER=1 \
-DWINDOW=1 \
-DWINDOWMODULE_DYNAMIC \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ImguiModule = pkgs.stdenvNoCC.mkDerivation {
name = "ImguiModule";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DIMGUIMODULE_DYNAMIC \
-DCUSTOMFONT=${pkgs.fira-code}/share/fonts/truetype/FiraCode-VF.ttf \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
MainGUIsdl = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
sdl3
];
buildPhase = ''
clang++ \
modules/MainGUI/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_sdl3.cpp \
$imgui/backends/imgui_impl_sdlrenderer3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=2 \
-DWINDOW=2 \
-DMAINGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lSDL3 \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
MainGUI = pkgs.stdenvNoCC.mkDerivation {
name = "MainGUI";
src = ./.;
inherit imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildPhase = ''
clang++ \
modules/MainGUI/*.cpp \
modules/ImguiModule/*.cpp \
modules/WindowModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER=1 \
-DWINDOW=1 \
-DMAINGUI_DYNAMIC \
-fpic -shared \
-I include -I $imgui -I . \
-lGL -lglfw -lGLEW \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
packages.${system}.default = self.Archimedes.examples.MinimalApp;
apps.${system}.default = {
type = "app";
program = "${self.Archimedes.examples.MinimalApp}/bin/Archimedes";
};
};
}