draconisplusplus/flake.nix

127 lines
3.2 KiB
Nix
Raw Normal View History

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-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-02 06:03:21 -04:00
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.stdenv;
in
with pkgs; {
packages = rec {
draconis-cpp = 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-05-29 00:28:54 -04:00
propagatedBuildInputs =
[
libcpr
tomlplusplus
]
++ (lib.optionals pkgs.hostPlatform.isLinux [
glib
playerctl
]);
buildInputs = [
boost185
fmt
];
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
'';
};
default = draconis-cpp;
};
formatter = alejandra;
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
meson
2024-05-29 06:39:39 -04:00
ninja
2024-05-29 00:28:54 -04:00
pkg-config
boost185
fmt
glib
libcpr
tomlplusplus
]
++ (lib.optionals pkgs.hostPlatform.isLinux [playerctl]);
buildInputs = [
2024-05-31 22:59:00 -04:00
boost185
libcpr
tomlplusplus
];
2024-05-27 05:40:36 -04:00
name = "C++";
};
}
2024-05-27 05:40:36 -04:00
);
}