From 2a81fa7b1b2c54ffc27d0ef18ad0961f84aefdad Mon Sep 17 00:00:00 2001 From: Daniel Dada Date: Fri, 12 Dec 2025 14:06:33 +0300 Subject: [PATCH] updated flake --- flake.nix | 181 +++++++++++++++++++++++++++-------------------- src/cli/main.cpp | 57 +++++++-------- 2 files changed, 129 insertions(+), 109 deletions(-) diff --git a/flake.nix b/flake.nix index 765f534..e073d5d 100644 --- a/flake.nix +++ b/flake.nix @@ -5,92 +5,121 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, ... }: let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in { - packages.${system} = rec { - clrsync = pkgs.stdenv.mkDerivation rec { - pname = "clrsync"; - version = "unstable"; + outputs = + { self, nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages.${system} = rec { + clrsync = pkgs.stdenv.mkDerivation rec { + pname = "clrsync"; + version = "unstable"; - src = self; + src = self; - nativeBuildInputs = [ - pkgs.cmake - pkgs.git - pkgs.pkg-config - pkgs.makeWrapper - ]; + nativeBuildInputs = [ + pkgs.cmake + pkgs.git + pkgs.pkg-config + pkgs.makeWrapper + pkgs.wayland-protocols + ]; - buildInputs = [ - pkgs.glfw - pkgs.freetype - pkgs.fontconfig - pkgs.xorg.libXcursor - pkgs.mesa - pkgs.xorg.libX11 - pkgs.xorg.libXrandr - pkgs.xorg.libXi - pkgs.xorg.libXinerama - pkgs.xorg.libXcursor - pkgs.wayland - pkgs.wayland-protocols - pkgs.libxkbcommon - pkgs.zlib - pkgs.bzip2 - ]; + buildInputs = [ + pkgs.glfw + pkgs.freetype + pkgs.fontconfig + pkgs.xorg.libXcursor + pkgs.mesa + pkgs.xorg.libX11 + pkgs.xorg.libXrandr + pkgs.xorg.libXi + pkgs.xorg.libXinerama + pkgs.xorg.libXcursor + pkgs.wayland + pkgs.wayland-protocols + pkgs.libxkbcommon + pkgs.zlib + pkgs.bzip2 + ]; - cmakeFlags = [ - "-DCMAKE_BUILD_TYPE=Release" - "-DUSE_SYSTEM_GLFW=ON" - ]; + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=Release" + "-DUSE_SYSTEM_GLFW=ON" + ]; - installPhase = '' - cmake --install . --prefix $out - wrapProgram $out/bin/clrsync_gui \ - --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} - wrapProgram $out/bin/clrsync_cli \ - --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} - ''; + installPhase = '' + cmake --install . --prefix $out + wrapProgram $out/bin/clrsync_gui \ + --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} + wrapProgram $out/bin/clrsync_cli \ + --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} + ''; - meta = with pkgs.lib; { - description = "Color scheme manager (git version)"; - homepage = "https://github.com/obsqrbtz/clrsync"; - license = licenses.mit; - platforms = platforms.linux; - mainProgram = "clrsync_gui"; + meta = with pkgs.lib; { + description = "Color scheme manager (git version)"; + homepage = "https://github.com/obsqrbtz/clrsync"; + license = licenses.mit; + platforms = platforms.linux; + mainProgram = "clrsync_gui"; + }; }; + + default = clrsync; }; - default = clrsync; - }; + apps.${system} = { + clrsync-gui = { + type = "app"; + program = "${self.packages.${system}.clrsync}/bin/clrsync_gui"; + }; - apps.${system} = { - clrsync-gui = { - type = "app"; - program = "${self.packages.${system}.clrsync}/bin/clrsync_gui"; - }; - - clrsync-cli = { - type = "app"; - program = "${self.packages.${system}.clrsync}/bin/clrsync_cli"; - }; - - default = self.apps.${system}.clrsync-gui; - }; + clrsync-cli = { + type = "app"; + program = "${self.packages.${system}.clrsync}/bin/clrsync_cli"; + }; + + default = self.apps.${system}.clrsync-gui; + }; + + devShells.${system}.default = pkgs.mkShell { + buildInputs = with pkgs; [ + cmake + git + pkg-config + makeWrapper + ninja + stdenv.cc.cc.lib + clang-tools + gdb + + glfw + freetype + fontconfig + mesa + xorg.libX11 + xorg.libXrandr + xorg.libXi + xorg.libXinerama + xorg.libXcursor + libxkbcommon + zlib + bzip2 + wayland + wayland-scanner + wayland-protocols + ]; + + shellHook = '' + export CMAKE_GENERATOR="Ninja" + export CMAKE_EXPORT_COMPILE_COMMANDS=1 + export CPLUS_INCLUDE_PATH="${pkgs.gcc.cc}/include/c++/${pkgs.gcc.cc.version}:${pkgs.gcc.cc}/include/c++/${pkgs.gcc.cc.version}/x86_64-unknown-linux-gnu:$CPLUS_INCLUDE_PATH" + export C_INCLUDE_PATH="${pkgs.gcc.cc}/include:$C_INCLUDE_PATH" + export PATH=${pkgs.wayland-protocols}/bin:$PATH + ''; + }; - devShells.${system}.default = pkgs.mkShell { - buildInputs = with pkgs; [ - cmake - git - pkg-config - glfw - freetype - fontconfig - xorg.libXcursor - mesa - ]; }; - }; } diff --git a/src/cli/main.cpp b/src/cli/main.cpp index f392777..fb827c8 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -1,16 +1,16 @@ -#include #include +#include #include #include -#include #include #include #include #include -#include #include +#include +#include #include void handle_show_vars() @@ -21,9 +21,8 @@ void handle_show_vars() void handle_list_themes() { auto palette_manager = clrsync::core::palette_manager(); - palette_manager.load_palettes_from_directory( - clrsync::core::config::instance().palettes_path()); - + palette_manager.load_palettes_from_directory(clrsync::core::config::instance().palettes_path()); + const auto &palettes = palette_manager.palettes(); std::cout << "Available themes:" << std::endl; for (const auto &p : palettes) @@ -36,7 +35,7 @@ int handle_apply_theme(const argparse::ArgumentParser &program, const std::strin { clrsync::core::theme_renderer renderer; std::string theme_identifier; - + if (program.is_used("--theme")) { theme_identifier = program.get("--theme"); @@ -57,7 +56,7 @@ int handle_apply_theme(const argparse::ArgumentParser &program, const std::strin theme_identifier = default_theme; renderer.apply_theme(theme_identifier); } - + std::cout << "Applied theme " << theme_identifier << std::endl; return 0; } @@ -70,35 +69,27 @@ void initialize_config(const std::string &config_path) void setup_argument_parser(argparse::ArgumentParser &program) { - program.add_argument("-a", "--apply") - .help("applies default theme") - .flag(); - + program.add_argument("-a", "--apply").help("applies default theme").flag(); + program.add_argument("-c", "--config") .default_value(clrsync::core::get_default_config_path()) .help("sets config file path") .metavar("PATH"); - - program.add_argument("-l", "--list-themes") - .help("lists available themes") - .flag(); - - program.add_argument("-s", "--show-vars") - .help("shows color keys") - .flag(); - + + program.add_argument("-l", "--list-themes").help("lists available themes").flag(); + + program.add_argument("-s", "--show-vars").help("shows color keys").flag(); + auto &group = program.add_mutually_exclusive_group(); - group.add_argument("-t", "--theme") - .help("sets theme to apply"); - group.add_argument("-p", "--path") - .help("sets theme file to apply"); + group.add_argument("-t", "--theme").help("sets theme to apply"); + group.add_argument("-p", "--path").help("sets theme file to apply"); } int main(int argc, char *argv[]) { argparse::ArgumentParser program("clrsync", clrsync::core::version_string()); setup_argument_parser(program); - + try { program.parse_args(argc, argv); @@ -109,9 +100,9 @@ int main(int argc, char *argv[]) std::cerr << program; return 1; } - + std::string config_path = program.get("--config"); - + try { initialize_config(config_path); @@ -121,19 +112,19 @@ int main(int argc, char *argv[]) std::cerr << "Error loading config: " << err.what() << std::endl; return 1; } - + if (program.is_used("--show-vars")) { handle_show_vars(); return 0; } - + if (program.is_used("--list-themes")) { handle_list_themes(); return 0; } - + if (program.is_used("--apply")) { const std::string default_theme = clrsync::core::config::instance().default_theme(); @@ -141,6 +132,6 @@ int main(int argc, char *argv[]) } std::cout << program << std::endl; - + return 0; -} \ No newline at end of file +}