diff --git a/flake.nix b/flake.nix
index 235d5aa4..c7d7c689 100644
--- a/flake.nix
+++ b/flake.nix
@@ -116,21 +116,18 @@
{
system = "x86_64-linux";
config.allowUnfree = true;
- overlays =
- [
- inputs.self.overlays.default
- (final: prev:
- {
- boost = (prev.boost.override { zstd = null; }).overrideAttrs (prev:
- { patches = prev.patches or [] ++ [ ./local/pkgs/winjob/boost.patch ]; });
- magic-enum = prev.magic-enum.overrideAttrs (prev: { cmakeFlags = prev.cmakeFlags ++
- [ "-DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF" "-DMAGIC_ENUM_OPT_BUILD_TESTS=OFF" ]; });
- range-v3 = prev.range-v3.overrideAttrs (prev: { cmakeFlags = prev.cmakeFlags ++
- [ "-DRANGE_V3_DOCS=OFF" "-DRANGE_V3_TESTS=OFF" "-DRANGE_V3_EXAMPLES=OFF" ]; });
- abseil-cpp = prev.abseil-cpp.overrideAttrs (prev: { buildInputs = prev.buildInputs ++
- [ final.windows.pthreads ]; });
- })
- ];
+ overlays = [ inputs.self.overlays.default ];
+ crossOverlays = [(final: prev:
+ {
+ boost = (prev.boost.override { zstd = null; }).overrideAttrs (prev:
+ { patches = prev.patches or [] ++ [ ./local/pkgs/winjob/boost.patch ]; });
+ magic-enum = prev.magic-enum.overrideAttrs (prev: { cmakeFlags = prev.cmakeFlags ++
+ [ "-DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF" "-DMAGIC_ENUM_OPT_BUILD_TESTS=OFF" ]; });
+ range-v3 = prev.range-v3.overrideAttrs (prev: { cmakeFlags = prev.cmakeFlags ++
+ [ "-DRANGE_V3_DOCS=OFF" "-DRANGE_V3_TESTS=OFF" "-DRANGE_V3_EXAMPLES=OFF" ]; });
+ abseil-cpp = prev.abseil-cpp.overrideAttrs (prev: { buildInputs = prev.buildInputs ++
+ [ final.windows.pthreads ]; });
+ })];
};
in rec
{
@@ -213,7 +210,7 @@
winjob = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.winjob ];
- packages = [ pkgs.clang-tools_18 pkgs.qt6.full pkgs.qtcreator ];
+ packages = with pkgs; [ clang-tools_18 qt6.full qtcreator ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
};
diff --git a/local/pkgs/winjob/.clangd b/local/pkgs/winjob/.clangd
index 31d7203a..a6585d7e 100644
--- a/local/pkgs/winjob/.clangd
+++ b/local/pkgs/winjob/.clangd
@@ -1,3 +1,3 @@
CompileFlags:
- Add: [ -Wall, -Wextra, -std=c++26 ]
+ Add: [ -Wall, -Wextra, -std=c++23 ]
Compiler: g++
diff --git a/local/pkgs/winjob/CMakeLists.txt b/local/pkgs/winjob/CMakeLists.txt
index f083fad3..57b18179 100644
--- a/local/pkgs/winjob/CMakeLists.txt
+++ b/local/pkgs/winjob/CMakeLists.txt
@@ -15,17 +15,23 @@ set(WINJOB_VERSION "unknown" CACHE STRING "Version of the winjob")
find_package(Boost REQUIRED COMPONENTS headers filesystem)
find_package(nlohmann_json REQUIRED)
-add_executable(winjob src/winjob.cpp src/windows.cpp)
+add_executable(winjob src/winjob.cpp src/os.cpp)
target_compile_features(winjob PRIVATE cxx_std_23)
target_include_directories(winjob PRIVATE ${PROJECT_SOURCE_DIR}/include)
-target_link_libraries(winjob PRIVATE Boost::headers Boost::filesystem ws2_32 wsock32)
+target_link_libraries(winjob PRIVATE Boost::headers Boost::filesystem)
+if(WIN32)
+ target_link_libraries(winjob PRIVATE ws2_32 wsock32)
+endif()
target_compile_definitions(winjob PRIVATE winjob_VERSION="${winjob_VERSION}")
-add_executable(winjobd src/winjobd.cpp src/windows.cpp)
+add_executable(winjobd src/winjobd.cpp src/os.cpp src/scheduler.cpp)
target_compile_features(winjob PRIVATE cxx_std_23)
target_compile_options(winjobd PRIVATE -fpermissive)
target_include_directories(winjobd PRIVATE ${PROJECT_SOURCE_DIR}/include)
-target_link_libraries(winjobd PRIVATE Boost::headers Boost::filesystem ws2_32 wsock32)
+target_link_libraries(winjobd PRIVATE Boost::headers Boost::filesystem)
+if(WIN32)
+ target_link_libraries(winjobd PRIVATE ws2_32 wsock32)
+endif()
target_compile_definitions(winjobd PRIVATE winjob_VERSION="${winjob_VERSION}")
install(TARGETS winjob RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/local/pkgs/winjob/CMakeLists.txt.user b/local/pkgs/winjob/CMakeLists.txt.user
deleted file mode 100644
index 9719f8cf..00000000
--- a/local/pkgs/winjob/CMakeLists.txt.user
+++ /dev/null
@@ -1,540 +0,0 @@
-
-
-
-
-
- EnvironmentId
- {717c3fd4-7fd4-4144-8aac-caa048cb2e1f}
-
-
- ProjectExplorer.Project.ActiveTarget
- 1
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- 0
- false
- true
- false
- 2
- true
- true
- 0
- 8
- true
- false
- 1
- true
- true
- true
- *.md, *.MD, Makefile
- false
- true
- true
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
- true
- false
- true
- true
- true
- true
-
-
- 0
- true
-
- true
- true
- Builtin.DefaultTidyAndClazy
- 16
- true
-
-
-
- true
-
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop
- Qt 6.7.2 in PATH (jm3abgh7h0gjhxzcs4gs9h6pv2m5wcgm-qt-full-6.7.2)
- Qt 6.7.2 in PATH (jm3abgh7h0gjhxzcs4gs9h6pv2m5wcgm-qt-full-6.7.2)
- {b52150f1-39f8-4684-b635-76d19c99973c}
- 0
- 0
- 0
-
- Debug
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- /home/chn/repo/nixos/local/pkgs/winjob
- /home/chn/repo/nixos/local/pkgs/winjob/build
-
-
-
-
- all
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug
- CMakeProjectManager.CMakeBuildConfiguration
-
- 1
-
-
- 0
- 部署
- 部署
- ProjectExplorer.BuildSteps.Deploy
-
- 1
-
- false
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
- 0
- true
-
- 2
-
- false
- -e cpu-cycles --call-graph dwarf,4096 -F 250
-
- ProjectExplorer.CustomExecutableRunConfiguration
-
- false
- true
- true
-
- 1
-
-
-
- ProjectExplorer.Project.Target.1
-
- Desktop
- 桌面
- 桌面
- {4cd1732e-0e6c-49a0-8965-8e5466221bf8}
- 0
- 0
- 0
-
- Debug
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- 0
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-Debug
-
-
-
-
- all
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- Release
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=Release
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-Release
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Release
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- RelWithDebInfo
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-RelWithDebInfo
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Release with Debug Information
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- RelWithDebInfo
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- 0
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-Profile
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Profile
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- MinSizeRel
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Unix Makefiles
--DCMAKE_BUILD_TYPE:STRING=MinSizeRel
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-MinSizeRel
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Minimum Size Release
- CMakeProjectManager.CMakeBuildConfiguration
-
- 5
-
-
- 0
- 部署
- 部署
- ProjectExplorer.BuildSteps.Deploy
-
- 1
-
- false
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
- 0
- true
-
- 2
-
- false
- -e cpu-cycles --call-graph dwarf,4096 -F 250
- winjob
- CMakeProjectManager.CMakeRunConfiguration.winjob
- winjob
- false
- true
- true
- true
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-Debug
-
-
- true
- true
- 0
- true
-
- 2
-
- false
- -e cpu-cycles --call-graph dwarf,4096 -F 250
- winjobd
- CMakeProjectManager.CMakeRunConfiguration.winjobd
- winjobd
- false
- true
- true
- true
- /home/chn/repo/nixos/local/pkgs/winjob/build/unknown-Debug
-
- 2
-
-
-
- ProjectExplorer.Project.TargetCount
- 2
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 22
-
-
- Version
- 22
-
-
diff --git a/local/pkgs/winjob/config.json b/local/pkgs/winjob/config.json
new file mode 100644
index 00000000..7de48dec
--- /dev/null
+++ b/local/pkgs/winjob/config.json
@@ -0,0 +1,3 @@
+{
+ "cpu": 8
+}
diff --git a/local/pkgs/winjob/include/winjob/job.hpp b/local/pkgs/winjob/include/winjob/job.hpp
new file mode 100644
index 00000000..c16a8088
--- /dev/null
+++ b/local/pkgs/winjob/include/winjob/job.hpp
@@ -0,0 +1,17 @@
+# pragma once
+# include
+# include
+# include
+
+namespace winjob
+{
+ enum class JobStatus { Pending, Starting, Running, Done, Exit, Canceled, Lost };
+ struct Job
+ {
+ unsigned Id, Cpu;
+ std::string User, Program;
+ std::vector Args;
+ JobStatus Status;
+ std::chrono::steady_clock::time_point LastReported, Started, Finished;
+ };
+}
diff --git a/local/pkgs/winjob/include/winjob/scheduler.hpp b/local/pkgs/winjob/include/winjob/scheduler.hpp
new file mode 100644
index 00000000..1a5e0a36
--- /dev/null
+++ b/local/pkgs/winjob/include/winjob/scheduler.hpp
@@ -0,0 +1,27 @@
+# pragma once
+# include
+# include
+# include