Compare commits

...

9 Commits

15 changed files with 69 additions and 124 deletions

View File

@@ -17,7 +17,7 @@ let
paths = with pkgs;
[
gnuplot localPackages.vaspkit pv python localPackages.vasp.intel chn-bsub hwloc
lsd prrte.dev
lsd glibc glibc.bin
];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs chn-bsub; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };

View File

@@ -1,10 +1,3 @@
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH=/data/gpfs01/wlin/.nix/state/gcroots/current/bin:$HOME/bin:$PATH
ulimit -s unlimited

View File

@@ -1,7 +1,10 @@
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -z "${BASHRC_SOURCED-}" ]; then
export PATH=$HOME/.nix/state/gcroots/current/bin:$HOME/bin:$PATH
ulimit -s unlimited
export HISTFILESIZE=1000000
export BASHRC_SOURCED=1
fi

8
flake.lock generated
View File

@@ -1785,12 +1785,12 @@
"ufo": {
"flake": false,
"locked": {
"lastModified": 1762315512,
"lastModified": 1767597695,
"lfs": true,
"narHash": "sha256-tTVQrXhnfFdrRwYJ60mpGdlbvUOE6egAxtqD0d80Crw=",
"narHash": "sha256-JNCSBKjslaT4kjMCWCImN1iS9ZRwfCN4GpP7dWECdas=",
"ref": "refs/heads/main",
"rev": "dc6b431bf92db5ba22aac745a90e058528d9b5e3",
"revCount": 85,
"rev": "19736049c9e117c642f3f0a5e81af5cf2a40b392",
"revCount": 86,
"type": "git",
"url": "https://git.chn.moe/chn/ufo.git"
},

View File

@@ -1,64 +1,64 @@
{ inputs }: let inherit (inputs.self.nixosConfigurations.pc) pkgs; in
{
biu = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
biu = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.biu ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
hpcstat = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
hpcstat = pkgs.mkShell
{
inputsFrom = [ (pkgs.localPackages.hpcstat.override { version = null; }) ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
sbatch-tui = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
sbatch-tui = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.sbatch-tui ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
ufo = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
ufo = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.ufo ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
chn-bsub = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.chn-bsub ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
info = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
info = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.info ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
vm = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
vm = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.vm ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
xinli = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
xinli = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.xinli ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
missgram = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
missgram = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.missgram ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};

View File

@@ -78,6 +78,7 @@ in platformConfig //
configureFlags = prev.configureFlags or [] ++ [ "--with-lsf" ];
buildInputs = prev.buildInputs or [] ++ [ final.localPackages.lsf final.libnsl ];
});
cpptrace = prev.cpptrace.overrideAttrs (prev: { doCheck = !final.stdenv.hostPlatform.isStatic; });
}
// (
let

View File

@@ -12,9 +12,7 @@
duc = pkgs.pkgsStatic.duc.override { enableCairo = false; cairo = null; pango = null; };
glaze = pkgs.pkgs-2411.pkgsStatic.glaze.overrideAttrs
(prev: { cmakeFlags = prev.cmakeFlags ++ [ "-Dglaze_ENABLE_FUZZING=OFF" ]; });
# pkgsStatic.clangStdenv have a bug
# https://github.com/NixOS/nixpkgs/issues/177129
biu = pkgs.pkgsStatic.localPackages.biu.override { stdenv = pkgs.pkgsStatic.gcc14Stdenv; inherit glaze; };
biu = pkgs.pkgsStatic.localPackages.biu.override { inherit glaze; };
in pkgs.pkgsStatic.localPackages.hpcstat.override
{
inherit openssh duc biu;

View File

@@ -77,9 +77,10 @@ inputs:
"Mod+Ctrl+C".action.spawn = [ "sh" "-c" "${xsel} -ob | ${wl-copy}" ];
"Mod+Ctrl+V".action.spawn = [ "sh" "-c" "${wl-paste} -n | ${xsel} -ib" ];
"Mod+S".action.screenshot = {};
"Mod+F".action.set-column-width= "100%";
"Mod+R".action.switch-preset-column-width = {};
"Mod+T".action.expand-column-to-available-width = {};
"Mod+F".action.switch-preset-column-width = {};
"Mod+T".action.spawn = [ "ghostty" ];
"Mod+B".action.spawn = [ "firefox" ];
"Mod+Escape".action.power-off-monitors = {};
};
outputs =
{
@@ -102,7 +103,7 @@ inputs:
layout =
{
default-column-width.proportion = 0.5;
preset-column-widths = [ { proportion = 0.33333; } { proportion = 0.5; } { proportion = 0.66667; } ];
preset-column-widths = [ { proportion = 0.5; } { proportion = 1.; } ];
};
spawn-at-startup =
[

View File

@@ -13,8 +13,7 @@ endif()
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process stacktrace_from_exception
stacktrace_backtrace)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
find_package(Eigen3 REQUIRED)
@@ -22,13 +21,14 @@ set(HIGHFIVE_FIND_HDF5 Off)
find_package(HighFive REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)
find_path(POCKETFFT_INCLUDE_DIR pocketfft.h REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(glaze REQUIRED)
find_package(cpptrace REQUIRED)
# on static build, cpptrace requires zlib
find_library(ZLIB_LIBRARY NAMES z REQUIRED)
add_library(biu src/common.cpp src/hdf5.cpp src/string.cpp)
target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -36,7 +36,7 @@ target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_D
${LIBBACKTRACE_INCLUDE_DIR} ${POCKETFFT_INCLUDE_DIR})
target_link_libraries(biu PUBLIC magic_enum::magic_enum fmt::fmt Boost::headers Boost::iostreams Boost::filesystem
range-v3::range-v3 Eigen3::Eigen HighFive TgBot::TgBot ${LIBBACKTRACE_LIBRARY} hdf5::hdf5 concurrencpp::concurrencpp
yaml-cpp::yaml-cpp glaze::glaze Boost::process Boost::stacktrace_from_exception Boost::stacktrace_backtrace)
yaml-cpp::yaml-cpp glaze::glaze Boost::process cpptrace::cpptrace ${ZLIB_LIBRARY})
target_compile_features(biu PUBLIC cxx_std_23)
target_compile_options(biu PUBLIC -Wno-gnu-string-literal-operator-template)
install(TARGETS biu EXPORT biuTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@@ -1,18 +1,16 @@
include("${CMAKE_CURRENT_LIST_DIR}/biuTargets.cmake")
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process stacktrace_from_exception
stacktrace_backtrace)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(HighFive REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)
find_path(POCKETFFT_INCLUDE_DIR pocketfft.h REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(glaze REQUIRED)
find_package(cpptrace REQUIRED)

View File

@@ -1,7 +1,7 @@
{
stdenv, cmake, lib,
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits, highfive, tgbot-cpp, libbacktrace, hdf5, concurrencpp,
pocketfft, yaml-cpp, glaze
pocketfft, yaml-cpp, glaze, cpptrace
}: stdenv.mkDerivation rec
{
name = "biu";
@@ -10,6 +10,7 @@
[
magic-enum fmt boost range-v3 nameof zpp-bits eigen libbacktrace hdf5
concurrencpp pocketfft yaml-cpp glaze (highfive.override { inherit boost; }) (tgbot-cpp.override { inherit boost; })
cpptrace
];
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [ cmake ];

View File

@@ -1,7 +1,5 @@
# pragma once
# include <map>
# define BOOST_STACKTRACE_USE_BACKTRACE
# include <boost/stacktrace.hpp>
# include <biu/atomic.hpp>
namespace biu
@@ -53,15 +51,6 @@ namespace biu
// List of objects that is being monitored by ObjectMonitor, {address, type}
protected: static Atomic<std::multimap<const void*, std::string_view>> Objects_;
public: template <typename FinalException> class Exception : public std::exception
{
protected: const std::string Message_;
protected: const boost::stacktrace::stacktrace Stacktrace_;
public: explicit Exception(const std::string& message);
public: const char* what() const noexcept final {return Message_.c_str();}
};
public: template <typename Function> static void try_exec(Function&& function);
// Monitor the start and end of a function, as well as corresponding thread.
@@ -94,12 +83,6 @@ namespace biu
public: [[gnu::always_inline]] inline void error(const std::string& message) const;
public: [[gnu::always_inline]] inline void info(const std::string& message) const;
public: [[gnu::always_inline]] inline void debug(const std::string& message) const;
public: [[gnu::always_inline]] inline void print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const;
};
friend class Guard;

View File

@@ -5,6 +5,8 @@
# include <biu/common.hpp>
# include <biu/format.hpp>
# include <boost/exception/diagnostic_information.hpp>
# include <cpptrace/cpptrace.hpp>
# include <cpptrace/from_current.hpp>
namespace biu
{
@@ -63,13 +65,6 @@ namespace biu
}
inline Atomic<std::multimap<const void*, std::string_view>> Logger::Objects_;
template <typename FinalException> Logger::Exception<FinalException>::Exception(const std::string& message)
{
Logger::Guard log(message);
log.print_exception
(std::pair<std::string, std::string>(nameof::nameof_full_type<FinalException>(), message), Stacktrace_);
}
template <typename Function> inline void Logger::try_exec(Function&& function)
{
Logger::Guard log;
@@ -77,8 +72,12 @@ namespace biu
catch (...)
{
log.error(boost::current_exception_diagnostic_information());
log.print_exception
(std::nullopt, boost::stacktrace::stacktrace::from_current_exception());
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
cpptrace::from_current_exception().print(*lock->Stream);
*lock->Stream << std::flush;
}
}
}
@@ -124,13 +123,13 @@ namespace biu
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
auto time = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
boost::stacktrace::stacktrace stack;
auto frame = cpptrace::stacktrace::current(0, 1).frames[0];
# ifdef BIU_LOGGER_SOURCE_ROOT
auto source_root = std::string_view(BIU_LOGGER_SOURCE_ROOT "/");
auto source_file = stack[0].source_file().starts_with(source_root) ?
stack[0].source_file().substr(source_root.size()) : stack[0].source_file();
auto source_file = frame.filename.starts_with(source_root) ?
frame.filename.substr(source_root.size()) : frame.filename;
# else
auto source_file = stack[0].source_file();
auto source_file = frame.filename;
# endif
*lock->Stream << "[ {:%T} {:02x} {:02} ] {} (at {}:{} {} )\n"_f
(
@@ -139,8 +138,8 @@ namespace biu
Indent_,
message,
source_file.empty() ? "??"s : source_file,
stack[0].source_line() == 0 ? "??"s : "{}"_f(stack[0].source_line()),
stack[0].name()
frame.line.has_value() ? "{}"_f(frame.line.value()) : "??"s,
frame.symbol
) << std::flush;
}
}
@@ -154,26 +153,5 @@ namespace biu
return std::forward<T>(value);
}
inline void Logger::Guard::print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const
{
if (type_and_message) log<Level::Error>("{}: {}"_f(type_and_message->first, type_and_message->second));
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
for (auto frame : stacktrace)
*lock->Stream << "\tfrom {}:{} {}\n"_f
(
frame.source_file().empty() ? "??"s : frame.source_file(),
frame.source_line() == 0 ? "??"s : "{}"_f(frame.source_line()),
frame.name()
);
*lock->Stream << std::flush;
}
}
inline Atomic<std::map<std::size_t, std::size_t>> Logger::Threads_;
}

View File

@@ -14,11 +14,7 @@ inputs: rec
};
v-sim = inputs.pkgs.callPackage ./v-sim.nix { src = inputs.topInputs.v-sim; };
concurrencpp = inputs.pkgs.callPackage ./concurrencpp.nix { src = inputs.topInputs.concurrencpp; };
matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus.nix
{
src = inputs.topInputs.matplotplusplus;
stdenv = inputs.pkgs.clang18Stdenv;
};
matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus.nix { src = inputs.topInputs.matplotplusplus; };
zpp-bits = inputs.pkgs.callPackage ./zpp-bits.nix { src = inputs.topInputs.zpp-bits; };
nameof = inputs.pkgs.callPackage ./nameof.nix { src = inputs.topInputs.nameof; };
pslist = inputs.pkgs.callPackage ./pslist.nix { src = inputs.topInputs.self.src.pslist; };
@@ -67,9 +63,7 @@ inputs: rec
inherit nameof zpp-bits tgbot-cpp concurrencpp pocketfft;
# TODO: report glaze bug to upstream
inherit (inputs.pkgs.pkgs-2411) glaze;
stdenv = inputs.pkgs.clang18Stdenv;
boost = (inputs.pkgs.boost188.override { extraB2Args = [ "boost.stacktrace.backtrace=on" ]; }).overrideAttrs
(prev: { buildInputs = prev.buildInputs ++ [(inputs.pkgs.libbacktrace.override { enableStatic = true; })]; });
boost = inputs.pkgs.boost188;
fmt = inputs.pkgs.fmt_11.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./biu/fmt.patch ]; });
};
hpcstat = inputs.pkgs.callPackage ./hpcstat
@@ -77,13 +71,8 @@ inputs: rec
openxlsx = inputs.pkgs.callPackage ./openxlsx.nix { src = inputs.topInputs.openxlsx; };
sqlite-orm = inputs.pkgs.callPackage ./sqlite-orm.nix { src = inputs.topInputs.sqlite-orm; };
mkPnpmPackage = inputs.pkgs.callPackage ./mkPnpmPackage.nix {};
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
ufo = inputs.pkgs.callPackage inputs.topInputs.ufo
{
inherit biu matplotplusplus;
tbb = inputs.pkgs.tbb_2022;
stdenv = inputs.pkgs.clang18Stdenv;
};
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; };
ufo = inputs.pkgs.callPackage inputs.topInputs.ufo { inherit biu matplotplusplus; tbb = inputs.pkgs.tbb_2022; };
chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; };
py4vasp = inputs.pkgs.python3Packages.callPackage ./py4vasp.nix { src = inputs.topInputs.py4vasp; };
pocketfft = inputs.pkgs.callPackage ./pocketfft.nix { src = inputs.topInputs.pocketfft; };
@@ -112,14 +101,14 @@ inputs: rec
];
};
stickerpicker = inputs.pkgs.python3Packages.callPackage ./stickerpicker.nix { src = inputs.topInputs.stickerpicker; };
info = inputs.pkgs.callPackage ./info { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
info = inputs.pkgs.callPackage ./info { inherit biu; };
blog = inputs.pkgs.callPackage inputs.topInputs.blog
{
inherit (inputs.topInputs) hextra;
buildProxy = inputs.pkgs.lib.mkBuildproxy ./blog-buildproxy.nix;
};
phono3py = inputs.pkgs.python3Packages.callPackage ./phono3py.nix { src = inputs.topInputs.phono3py; };
vm = inputs.pkgs.callPackage ./vm { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
vm = inputs.pkgs.callPackage ./vm { inherit biu; };
oneapiPackages = inputs.pkgs.lib.makeScope inputs.pkgs.newScope (final:
{
stdenv = inputs.pkgs.callPackage ./oneapi/stdenv.nix { src = inputs.topInputs.self.src.oneapi; inherit gccFull; };
@@ -137,14 +126,14 @@ inputs: rec
speedtest = inputs.pkgs.callPackage ./speedtest.nix { src = inputs.topInputs.speedtest; };
atat = inputs.pkgs.callPackage ./atat.nix { src = inputs.topInputs.self.src.atat; };
atomkit = inputs.pkgs.callPackage ./atomkit.nix { src = inputs.topInputs.self.src.atomkit; };
xinli = inputs.pkgs.callPackage ./xinli { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
xinli = inputs.pkgs.callPackage ./xinli { inherit biu; };
pybinding = inputs.pkgs.pkgs-2411.python310Packages.callPackage ./pybinding
{
src = inputs.topInputs.pybinding;
buildProxy = inputs.pkgs.lib.mkBuildproxy ./pybinding/proxy.nix;
};
brokenaxes = inputs.pkgs.python3Packages.callPackage ./brokenaxes.nix { src = inputs.topInputs.brokenaxes; };
missgram = inputs.pkgs.callPackage ./missgram { inherit biu sqlgen; stdenv = inputs.pkgs.clang18Stdenv; };
missgram = inputs.pkgs.callPackage ./missgram { inherit biu sqlgen; };
sqlgen = inputs.pkgs.callPackage ./sqlgen.nix { src = inputs.topInputs.sqlgen; inherit reflectcpp; };
reflectcpp = inputs.pkgs.callPackage ./reflectcpp.nix { src = inputs.topInputs.reflectcpp; };
lsf = inputs.pkgs.callPackage ./lsf.nix { src = inputs.topInputs.self.src.lsf; };

View File

@@ -1,4 +1,4 @@
{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl }:
{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl, prrte }:
let
vasp = stdenv.mkDerivation
{
@@ -26,7 +26,7 @@ let
};
wrapper = writeShellScriptBin "vasp-intel"
''
export PATH=${vasp}/bin:${mpi}/bin''${PATH:+:$PATH}
export PATH=${vasp}/bin:${mpi}/bin:${mpi.dev}/bin:${prrte}/bin:${prrte.dev}/bin''${PATH:+:$PATH}
# set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set
if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then