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;
|
|
|
|
overlays = [
|
|
|
|
(self: super: {
|
|
|
|
ccacheWrapper = super.ccacheWrapper.override {
|
|
|
|
extraConfig = ''
|
|
|
|
export CCACHE_COMPRESS=1
|
|
|
|
export CCACHE_DIR="/var/cache/ccache"
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
llvm = pkgs.llvmPackages_latest;
|
|
|
|
stdenv = pkgs.ccacheStdenv.override {stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv;};
|
|
|
|
in {
|
|
|
|
packages = rec {
|
|
|
|
draconis-cpp = with pkgs;
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "draconis++";
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2024-05-28 03:29:11 -04:00
|
|
|
boost
|
2024-05-27 05:40:36 -04:00
|
|
|
glib
|
|
|
|
playerctl
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
fmt
|
2024-05-28 03:29:11 -04:00
|
|
|
libcpr
|
|
|
|
tomlplusplus
|
2024-05-27 05:40:36 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cmake .
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 ./draconis++ $out/bin/draconis++
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
default = draconis-cpp;
|
|
|
|
};
|
|
|
|
|
|
|
|
devShell = with pkgs;
|
|
|
|
mkShell.override {inherit stdenv;} {
|
|
|
|
CXX = "${clang}/bin/clang++";
|
|
|
|
CC = "${clang}/bin/clang++";
|
|
|
|
|
|
|
|
packages = with pkgs; [
|
|
|
|
# builder
|
|
|
|
gnumake
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
|
|
|
|
# debugger
|
|
|
|
lldb
|
|
|
|
|
|
|
|
# fix headers not found
|
|
|
|
clang-tools
|
|
|
|
|
|
|
|
# LSP and compiler
|
|
|
|
llvm.libstdcxxClang
|
|
|
|
|
|
|
|
# other tools
|
|
|
|
cppcheck
|
|
|
|
llvm.libllvm
|
|
|
|
|
|
|
|
# stdlib for cpp
|
|
|
|
llvm.libcxx
|
|
|
|
|
|
|
|
# libraries
|
2024-05-28 03:29:11 -04:00
|
|
|
boost
|
2024-05-27 05:40:36 -04:00
|
|
|
fmt
|
|
|
|
glib
|
2024-05-28 03:29:11 -04:00
|
|
|
libcpr
|
2024-05-27 05:40:36 -04:00
|
|
|
playerctl
|
|
|
|
tomlplusplus
|
|
|
|
];
|
|
|
|
|
|
|
|
name = "C++";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|