flake parts

This commit is contained in:
2026-02-14 13:12:52 -06:00
parent f9f311c82b
commit 874de65dba
75 changed files with 495 additions and 341 deletions

View File

@@ -1,36 +1,5 @@
{ inputs, pkgs, ... }: {
MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = ./.;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
src/example_apps/MinimalApp/MinimalApp.cpp \
-I include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
TriangleEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
@@ -75,54 +44,6 @@
};
ImguiEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = ./.;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
nlohmann_json
curl
];
buildPhase = ''
clang++ \
src/example_apps/ImguiEmbed/*.cpp \
modules/MainGUI/*.cpp \
modules/WindowModule/*.cpp \
modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER_OPENGL=1 \
-DWINDOW_GLFW=1 \
-I include -I $imgui -I . \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
TerminalEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";

6
dev/overlays.nix Normal file
View File

@@ -0,0 +1,6 @@
{ inputs, ... }: {
flake.overlays.glfw-old = (final: prev: let
pkgs-old = import inputs.nixpkgs-old { system = prev.stdenv.hostPlatform.system; };
in { glfw = pkgs-old.glfw; });
}

29
dev/shells.nix Normal file
View File

@@ -0,0 +1,29 @@
{ ... }: {
perSystem = { config, system, pkgs, self', inputs', ... }: {
devShells.default = pkgs.mkShellNoCC {
packages = with pkgs; [
clang
glfw
glew
sdl3
curl
glm
nlohmann_json
stb
gamenetworkingsockets
];
shellHook = ''
'';
};
};
}

6
dev/systems.nix Normal file
View File

@@ -0,0 +1,6 @@
{ ... }: {
systems = [
"x86_64-linux"
];
}

62
flake.lock generated
View File

@@ -16,14 +16,32 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1769996383,
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"imgui": {
"flake": false,
"locked": {
"lastModified": 1769795052,
"narHash": "sha256-JRA4E/aFcEEoB9FYHcLcEs4tgcX41ix2VjMV61PVQeA=",
"lastModified": 1770923283,
"narHash": "sha256-EOhlmnhoJRNjU7o7aCXnRrOw7JM0nq0VWDVnUJ6A6Xo=",
"owner": "ocornut",
"repo": "imgui",
"rev": "913a3c60561bb07e8fd410ec7d4a8f6f485defd6",
"rev": "3fb22b836ba968c62d280d9de079ec5ed7fcd1b5",
"type": "github"
},
"original": {
@@ -33,13 +51,28 @@
"type": "github"
}
},
"import-tree": {
"locked": {
"lastModified": 1771045967,
"narHash": "sha256-oYO4poyw0Sb/db2PigqugMlDwsvwLg6CSpFrMUWxA3Q=",
"owner": "vic",
"repo": "import-tree",
"rev": "c968d3b54d12cf5d9c13f16f7c545a06c9d1fde6",
"type": "github"
},
"original": {
"owner": "vic",
"repo": "import-tree",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1770136044,
"narHash": "sha256-tlFqNG/uzz2++aAmn4v8J0vAkV3z7XngeIIB3rM3650=",
"lastModified": 1770770419,
"narHash": "sha256-iKZMkr6Cm9JzWlRYW/VPoL0A9jVKtZYiU4zSrVeetIs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e576e3c9cf9bad747afcddd9e34f51d18c855b4e",
"rev": "6c5e707c6b5339359a9a9e215c5e66d6d802fd7a",
"type": "github"
},
"original": {
@@ -49,6 +82,21 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1769909678,
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "72716169fe93074c333e8d0173151350670b824c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-old": {
"locked": {
"lastModified": 1720535198,
@@ -68,7 +116,9 @@
"root": {
"inputs": {
"clay": "clay",
"flake-parts": "flake-parts",
"imgui": "imgui",
"import-tree": "import-tree",
"nixpkgs": "nixpkgs",
"nixpkgs-old": "nixpkgs-old"
}

487
flake.nix
View File

@@ -12,286 +12,261 @@
url = "github:nicbarker/clay";
flake = false;
};
flake-parts.url = "github:hercules-ci/flake-parts";
import-tree.url = "github:vic/import-tree";
};
outputs = { self, nixpkgs, imgui, clay, ... }@inputs: let
system = "x86_64-linux";
pkgs-old = import inputs.nixpkgs-old { inherit system; };
viewport-overlay = final: prev: { glfw = pkgs-old.glfw; };
pkgs = import nixpkgs { inherit system; overlays = [ viewport-overlay ]; };
in {
Archimedes = {
examples = import ./ExampleApps.nix { inherit inputs pkgs; };
};
Modules = {
examples = import ./ExampleModules.nix { inherit inputs pkgs; };
ServerModule = pkgs.stdenvNoCC.mkDerivation {
name = "ServerModule";
outputs = { self, flake-parts, import-tree, ... } @ inputs:
flake-parts.lib.mkFlake {
inputs = inputs // {
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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
'';
};
};
} (import-tree [ ./modules ./src ./dev ]);
MainGUI = pkgs.stdenvNoCC.mkDerivation {
/*
Modules = {
examples = import ./ExampleModules.nix { inherit inputs pkgs; };
name = "MainGUI";
ServerModule = pkgs.stdenvNoCC.mkDerivation {
src = ./.;
name = "ServerModule";
inherit imgui;
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
};
ClientModule = pkgs.stdenvNoCC.mkDerivation {
packages.${system}.default = self.Archimedes.examples.MinimalApp;
name = "ClientModule";
apps.${system}.default = {
type = "app";
program = "${self.Archimedes.examples.MinimalApp}/bin/Archimedes";
};
src = ./.;
devShells.${system} = {
default = pkgs.mkShellNoCC {
nativeBuildInputs = with pkgs; [
clang
];
packages = with pkgs; [
clang
buildInputs = with pkgs; [
gamenetworkingsockets
];
glfw
glew
buildPhase = ''
clang++ \
modules/ClientModule/*.cpp \
-fpic -shared \
-I include \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-lGameNetworkingSockets \
-DCLIENTMODULE_DYNAMIC \
-Wall \
-o $name
'';
sdl3
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
curl
glm
nlohmann_json
stb
};
gamenetworkingsockets
WindowModule = pkgs.stdenvNoCC.mkDerivation {
];
name = "WindowModule";
shellHook = ''
'';
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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 -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
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";
};
*/
}

View File

@@ -0,0 +1,53 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_ImguiEmbed = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
imgui = inputs.imgui;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
glfw
glew
glm
nlohmann_json
curl
];
buildPhase = ''
clang++ \
$src/src/example_apps/ImguiEmbed/*.cpp \
$src/modules/MainGUI/*.cpp \
$src/modules/WindowModule/*.cpp \
$src/modules/ImguiModule/*.cpp \
$imgui/backends/imgui_impl_glfw.cpp \
$imgui/backends/imgui_impl_opengl3.cpp \
$imgui/misc/cpp/*.cpp \
$imgui/*.cpp \
-DRENDERER_OPENGL=1 \
-DWINDOW_GLFW=1 \
-I $src/include -I $imgui -I $src \
-lEGL -lGL -lglfw -lGLEW \
$(curl-config --cflags) \
$(curl-config --libs) \
-Wall \
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
$src/src/example_apps/MinimalApp/MinimalApp.cpp \
-I $src/include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
$src/src/example_apps/MinimalApp/MinimalApp.cpp \
-I $src/include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
};
}

View File

@@ -0,0 +1,38 @@
{ inputs, ... }: {
perSystem = { system, pkgs, self', ... }: {
packages.exampleApps_MinimalApp = pkgs.stdenvNoCC.mkDerivation {
name = "Archimedes";
src = inputs.src;
outputs = [ "out" "dev" ];
nativeBuildInputs = with pkgs; [
clang
];
buildPhase = ''
clang++ \
$src/src/example_apps/MinimalApp/MinimalApp.cpp \
-I $src/include \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
mkdir -p $dev/include/modules
cp -r include/* $dev/include
cp -r modules $dev/include/modules
'';
};
};
}