draconisplusplus/flake.nix

162 lines
4.1 KiB
Nix
Raw Normal View History

2024-05-27 05:40:36 -04:00
{
description = "C/C++ environment";
inputs = {
2024-08-02 21:29:36 -04:00
nixvim.url = "github:pupbrained/nvim-config";
2024-07-30 19:50:45 -04:00
nixpkgs.url = "github:NixOS/nixpkgs";
2024-06-08 14:10:59 -04:00
treefmt-nix.url = "github:numtide/treefmt-nix";
2024-05-27 05:40:36 -04:00
utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
2024-06-08 14:10:59 -04:00
treefmt-nix,
2024-05-27 05:40:36 -04:00
utils,
2024-08-02 21:29:36 -04:00
nixvim,
2024-05-27 05:40:36 -04:00
...
}:
utils.lib.eachDefaultSystem (
system: let
2024-06-08 22:28:26 -04:00
pkgs = import nixpkgs {inherit system;};
2024-05-29 00:28:54 -04:00
2024-06-06 21:04:32 -04:00
stdenv =
if pkgs.hostPlatform.isLinux
2025-01-26 21:14:16 -05:00
then pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_19.stdenv
else pkgs.llvmPackages_19.stdenv;
2024-06-06 04:14:52 -04:00
2024-08-05 15:28:15 -04:00
sources = import ./_sources/generated.nix {
inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;
};
mkPkg = name:
pkgs.pkgsStatic.${name}.overrideAttrs {
inherit (sources.${name}) pname version src;
2024-06-20 13:29:33 -04:00
};
2024-08-05 15:28:15 -04:00
fmt = mkPkg "fmt";
yyjson = mkPkg "yyjson";
2025-01-26 21:14:16 -05:00
tomlplusplus = pkgs.pkgsStatic.tomlplusplus.overrideAttrs {
inherit (sources.tomlplusplus) pname version src;
doCheck = false;
};
2024-08-06 01:05:30 -04:00
sdbus-cpp = pkgs.sdbus-cpp.overrideAttrs {
inherit (sources.sdbus-cpp) pname version src;
};
2025-01-26 21:14:16 -05:00
reflect-cpp = stdenv.mkDerivation rec {
2024-08-05 15:28:15 -04:00
inherit (sources.reflect-cpp) pname version src;
2025-01-26 21:14:16 -05:00
buildInputs = [tomlplusplus yyjson];
nativeBuildInputs = buildInputs ++ (with pkgs; [cmake ninja pkg-config]);
2024-06-20 13:29:33 -04:00
cmakeFlags = [
"-DCMAKE_TOOLCHAIN_FILE=OFF"
"-DREFLECTCPP_TOML=ON"
2025-01-26 21:14:16 -05:00
"-DREFLECTCPP_JSON=ON"
2024-06-20 13:29:33 -04:00
];
};
2024-07-30 19:50:45 -04:00
deps = with pkgs.pkgsStatic;
2024-06-06 04:14:52 -04:00
[
2024-07-30 19:50:45 -04:00
curl
2024-08-05 15:28:15 -04:00
fmt
2024-07-30 19:50:45 -04:00
libiconv
2024-06-06 04:14:52 -04:00
tomlplusplus
2024-06-07 04:23:11 -04:00
yyjson
2024-06-20 13:29:33 -04:00
reflect-cpp
2025-01-27 17:43:00 -05:00
ftxui
2024-06-08 04:57:32 -04:00
]
++ linuxPkgs
++ darwinPkgs;
2024-06-06 21:04:32 -04:00
2024-07-31 00:07:40 -04:00
linuxPkgs = nixpkgs.lib.optionals stdenv.isLinux (with pkgs; [
pkgsStatic.glib
2024-06-07 04:23:11 -04:00
systemdLibs
2024-06-06 21:04:32 -04:00
sdbus-cpp
valgrind
]);
2024-07-30 19:50:45 -04:00
darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.pkgsStatic.darwin.apple_sdk.frameworks; [
2024-06-06 21:04:32 -04:00
Foundation
2024-06-07 13:45:59 -04:00
MediaPlayer
2024-07-30 19:50:45 -04:00
SystemConfiguration
2024-06-05 19:04:53 -04:00
]);
in
with pkgs; {
packages = rec {
2024-06-08 04:57:32 -04:00
draconisplusplus = stdenv.mkDerivation {
2024-05-27 05:40:36 -04:00
name = "draconis++";
version = "0.1.0";
2024-05-27 05:40:36 -04:00
src = self;
nativeBuildInputs = [
2025-01-27 17:43:00 -05:00
cmake
meson
2024-05-29 06:39:39 -04:00
ninja
2024-05-27 05:40:36 -04:00
pkg-config
];
2024-06-08 04:57:32 -04:00
buildInputs = deps;
configurePhase = ''
meson setup build
'';
2024-05-27 05:40:36 -04:00
buildPhase = ''
meson compile -C build
2024-05-27 05:40:36 -04:00
'';
installPhase = ''
mkdir -p $out/bin
mv build/draconis++ $out/bin/draconis++
2024-05-27 05:40:36 -04:00
'';
};
2024-06-08 04:57:32 -04:00
default = draconisplusplus;
};
2024-06-08 14:10:59 -04:00
formatter = treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
deadnix.enable = true;
clang-format = {
enable = true;
2025-01-26 21:14:16 -05:00
package = pkgs.clang-tools_19;
2024-06-08 14:10:59 -04:00
};
};
};
2024-05-27 05:40:36 -04:00
devShell = mkShell.override {inherit stdenv;} {
packages =
2024-05-29 00:28:54 -04:00
[
alejandra
bear
2025-01-26 21:14:16 -05:00
clang-tools_19
cmake
2024-06-06 04:14:52 -04:00
lldb
2025-01-27 23:11:03 -05:00
hyperfine
2024-06-08 04:57:32 -04:00
meson
2024-05-29 06:39:39 -04:00
ninja
2024-08-05 15:28:15 -04:00
nvfetcher
2024-05-29 00:28:54 -04:00
pkg-config
2024-06-06 04:14:52 -04:00
unzip
2024-08-02 21:29:36 -04:00
nixvim.packages.${system}.default
2025-01-26 21:14:16 -05:00
linuxKernel.packages.linux_zen.perf.out
2024-05-29 00:28:54 -04:00
2024-06-06 04:14:52 -04:00
(writeScriptBin "build" "meson compile -C build")
(writeScriptBin "clean" "meson setup build --wipe")
(writeScriptBin "run" "meson compile -C build && build/draconis++")
2024-06-05 19:04:53 -04:00
]
2024-06-08 04:57:32 -04:00
++ deps;
2024-05-27 05:40:36 -04:00
name = "C++";
};
}
2024-05-27 05:40:36 -04:00
);
}