mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-11 16:49:22 +08:00
packages.sbatch-tui: set config path at compile time
This commit is contained in:
@@ -249,7 +249,21 @@ inputs:
|
||||
};
|
||||
nixos =
|
||||
{
|
||||
packages.packages._packages = [ inputs.pkgs.localPackages.sbatch-tui ];
|
||||
packages.packages._packages = [(inputs.pkgs.localPackages.sbatch-tui.override
|
||||
{
|
||||
sbatchConfig = inputs.pkgs.writeText "sbatch.yaml" (builtins.toJSON
|
||||
{
|
||||
GpuIds = slurm.tui.gpuIds;
|
||||
GpuPartition = slurm.tui.gpuPartition;
|
||||
CpuQueues = builtins.map
|
||||
(queue:
|
||||
[
|
||||
queue.name
|
||||
{ CpuMpiThreads = queue.mpiThreads; CpuOpenmpThreads = queue.openmpThreads; MemoryGB = queue.memoryGB; }
|
||||
])
|
||||
slurm.tui.cpuQueues;
|
||||
});
|
||||
})];
|
||||
user.sharedModules = [{ home.packages =
|
||||
[
|
||||
(inputs.pkgs.writeShellScriptBin "sbatch"
|
||||
@@ -257,18 +271,6 @@ inputs:
|
||||
];}];
|
||||
services.mariadb = { enable = true; instances.slurm = {}; };
|
||||
};
|
||||
environment.etc."sbatch-tui.yaml".text = builtins.toJSON
|
||||
{
|
||||
GpuIds = slurm.tui.gpuIds;
|
||||
GpuPartition = slurm.tui.gpuPartition;
|
||||
CpuQueues = builtins.map
|
||||
(queue:
|
||||
[
|
||||
queue.name
|
||||
{ CpuMpiThreads = queue.mpiThreads; CpuOpenmpThreads = queue.openmpThreads; MemoryGB = queue.memoryGB; }
|
||||
])
|
||||
slurm.tui.cpuQueues;
|
||||
};
|
||||
networking.firewall =
|
||||
let config = inputs.lib.mkIf slurm.setupFirewall [ 6817 ];
|
||||
in { allowedTCPPorts = config; allowedUDPPorts = config; };
|
||||
|
||||
@@ -15,6 +15,9 @@ find_package(biu REQUIRED)
|
||||
add_executable(sbatch-tui src/main.cpp)
|
||||
target_compile_features(sbatch-tui PUBLIC cxx_std_23)
|
||||
target_link_libraries(sbatch-tui PRIVATE ftxui::screen ftxui::dom ftxui::component biu::biu)
|
||||
if(SBATCH_CONFIG)
|
||||
target_compile_definitions(sbatch-tui PRIVATE SBATCH_CONFIG="${SBATCH_CONFIG}")
|
||||
endif()
|
||||
|
||||
install(TARGETS sbatch-tui RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{ stdenv, cmake, pkg-config, ftxui, biu }: stdenv.mkDerivation
|
||||
{ lib, stdenv, cmake, pkg-config, sbatchConfig ? null, ftxui, biu }: stdenv.mkDerivation
|
||||
{
|
||||
name = "sbatch-tui";
|
||||
src = ./.;
|
||||
buildInputs = [ ftxui biu ];
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
cmakeFlags = lib.optional (sbatchConfig != null) [ "-DSBATCH_CONFIG=${sbatchConfig}" ];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
# include <boost/algorithm/string.hpp>
|
||||
# include <biu.hpp>
|
||||
|
||||
# ifndef SBATCH_CONFIG
|
||||
# define SBATCH_CONFIG "./sbatch-tui.yaml"
|
||||
# endif
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
@@ -17,7 +21,7 @@ int main()
|
||||
std::optional<std::vector<std::string>> GpuIds;
|
||||
std::string GpuPartition;
|
||||
};
|
||||
auto device = YAML::LoadFile("/etc/sbatch-tui.yaml").as<Device>();
|
||||
auto device = YAML::LoadFile(SBATCH_CONFIG).as<Device>();
|
||||
|
||||
// 需要绑定到界面上的变量
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user