draconisplusplus/flake.nix

149 lines
3.7 KiB
Nix
Raw Normal View History

2024-05-27 05:40:36 -04:00
{
description = "C/C++ environment";
inputs = {
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,
...
}:
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
then pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.stdenv
else pkgs.llvmPackages_18.stdenv;
2024-06-06 04:14:52 -04:00
2024-07-31 00:07:40 -04:00
reflect-cpp = stdenv.mkDerivation rec {
2024-06-20 13:29:33 -04:00
name = "reflect-cpp";
2024-07-31 00:07:40 -04:00
version = "0.13.0";
2024-06-20 13:29:33 -04:00
src = pkgs.fetchFromGitHub {
owner = "getml";
repo = "reflect-cpp";
2024-07-31 00:07:40 -04:00
rev = "v${version}";
hash = "sha256-dEqdPk5ixnNILxTcdSAOhzP8fzeefMu6pqrL/WgnPlE=";
2024-06-20 13:29:33 -04:00
};
nativeBuildInputs = with pkgs; [cmake ninja pkg-config];
cmakeFlags = [
"-DCMAKE_TOOLCHAIN_FILE=OFF"
"-DCMAKE_BUILD_TYPE=Release"
"-DREFLECTCPP_TOML=ON"
];
};
2024-07-31 00:07:40 -04:00
sdbus-cpp = pkgs.sdbus-cpp.overrideAttrs rec {
version = "2.0.0";
src = pkgs.fetchFromGitHub {
owner = "kistler-group";
repo = "sdbus-cpp";
rev = "v${version}";
hash = "sha256-W8V5FRhV3jtERMFrZ4gf30OpIQLYoj2yYGpnYOmH2+g=";
};
};
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-07-31 00:07:40 -04:00
fmt_11
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
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 = [
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;
package = pkgs.clang-tools_18;
};
};
};
2024-05-27 05:40:36 -04:00
devShell = mkShell.override {inherit stdenv;} {
packages =
2024-05-29 00:28:54 -04:00
[
alejandra
bear
2024-06-01 06:59:01 -04:00
clang-tools_18
2024-06-06 04:14:52 -04:00
lldb
2024-06-08 04:57:32 -04:00
meson
2024-05-29 06:39:39 -04:00
ninja
2024-05-29 00:28:54 -04:00
pkg-config
2024-06-06 04:14:52 -04:00
unzip
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
);
}