2024-05-27 05:40:36 -04:00
|
|
|
{
|
|
|
|
description = "C/C++ environment";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
utils,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
utils.lib.eachDefaultSystem (
|
|
|
|
system: let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2024-05-31 04:01:31 -04:00
|
|
|
|
2024-05-27 05:40:36 -04:00
|
|
|
overlays = [
|
|
|
|
(self: super: {
|
|
|
|
ccacheWrapper = super.ccacheWrapper.override {
|
|
|
|
extraConfig = ''
|
|
|
|
export CCACHE_COMPRESS=1
|
2024-05-29 06:39:39 -04:00
|
|
|
export CCACHE_DIR="/var/cache/ccache"
|
2024-05-27 05:40:36 -04:00
|
|
|
export CCACHE_UMASK=007
|
|
|
|
if [ ! -d "$CCACHE_DIR" ]; then
|
|
|
|
echo "====="
|
|
|
|
echo "Directory '$CCACHE_DIR' does not exist"
|
|
|
|
echo "Please create it with:"
|
|
|
|
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
|
|
|
|
echo " sudo chown root:nixbld '$CCACHE_DIR'"
|
|
|
|
echo "====="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -w "$CCACHE_DIR" ]; then
|
|
|
|
echo "====="
|
|
|
|
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
|
|
|
|
echo "Please verify its access permissions"
|
|
|
|
echo "====="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2024-05-29 00:28:54 -04:00
|
|
|
|
2024-06-05 19:04:53 -04:00
|
|
|
stdenv = pkgs.llvmPackages_18.stdenv;
|
|
|
|
|
|
|
|
darwinPkgs = nixpkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin; [
|
|
|
|
apple_sdk.frameworks.CoreFoundation
|
|
|
|
apple_sdk.frameworks.MediaPlayer
|
|
|
|
]);
|
2024-05-31 04:01:31 -04:00
|
|
|
in
|
|
|
|
with pkgs; {
|
|
|
|
packages = rec {
|
|
|
|
draconis-cpp = stdenv.mkDerivation {
|
2024-05-27 05:40:36 -04:00
|
|
|
name = "draconis++";
|
2024-05-31 04:01:31 -04:00
|
|
|
version = "0.1.0";
|
2024-05-27 05:40:36 -04:00
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-05-31 04:01:31 -04:00
|
|
|
meson
|
2024-05-29 06:39:39 -04:00
|
|
|
ninja
|
2024-05-27 05:40:36 -04:00
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
2024-05-29 00:28:54 -04:00
|
|
|
propagatedBuildInputs =
|
|
|
|
[
|
|
|
|
libcpr
|
|
|
|
tomlplusplus
|
|
|
|
]
|
2024-05-31 04:01:31 -04:00
|
|
|
++ (lib.optionals pkgs.hostPlatform.isLinux [
|
|
|
|
glib
|
|
|
|
playerctl
|
|
|
|
]);
|
|
|
|
|
|
|
|
buildInputs = [
|
2024-06-05 19:04:53 -04:00
|
|
|
coost
|
2024-05-31 04:01:31 -04:00
|
|
|
fmt
|
|
|
|
];
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
meson setup build
|
|
|
|
'';
|
2024-05-27 05:40:36 -04:00
|
|
|
|
|
|
|
buildPhase = ''
|
2024-05-31 04:01:31 -04:00
|
|
|
meson compile -C build
|
2024-05-27 05:40:36 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2024-05-31 04:01:31 -04:00
|
|
|
mkdir -p $out/bin
|
|
|
|
mv build/draconis++ $out/bin/draconis++
|
2024-05-27 05:40:36 -04:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-31 04:01:31 -04:00
|
|
|
default = draconis-cpp;
|
|
|
|
};
|
|
|
|
|
|
|
|
formatter = alejandra;
|
2024-05-27 05:40:36 -04:00
|
|
|
|
2024-05-31 04:01:31 -04:00
|
|
|
devShell = mkShell.override {inherit stdenv;} {
|
|
|
|
packages =
|
2024-05-29 00:28:54 -04:00
|
|
|
[
|
2024-05-31 04:01:31 -04:00
|
|
|
alejandra
|
|
|
|
bear
|
2024-06-01 06:59:01 -04:00
|
|
|
clang-tools_18
|
2024-05-31 04:01:31 -04:00
|
|
|
meson
|
2024-05-29 06:39:39 -04:00
|
|
|
ninja
|
2024-05-29 00:28:54 -04:00
|
|
|
pkg-config
|
|
|
|
|
2024-06-05 19:04:53 -04:00
|
|
|
coost
|
2024-05-29 00:28:54 -04:00
|
|
|
fmt
|
|
|
|
glib
|
|
|
|
libcpr
|
|
|
|
tomlplusplus
|
|
|
|
]
|
2024-06-05 19:04:53 -04:00
|
|
|
++ (lib.optionals pkgs.hostPlatform.isLinux [playerctl])
|
|
|
|
++ darwinPkgs;
|
2024-05-31 04:01:31 -04:00
|
|
|
|
2024-06-05 19:04:53 -04:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
coost
|
|
|
|
libcpr
|
|
|
|
tomlplusplus
|
|
|
|
]
|
|
|
|
++ darwinPkgs;
|
2024-05-27 05:40:36 -04:00
|
|
|
|
|
|
|
name = "C++";
|
|
|
|
};
|
2024-05-31 04:01:31 -04:00
|
|
|
}
|
2024-05-27 05:40:36 -04:00
|
|
|
);
|
|
|
|
}
|