updated flake

This commit is contained in:
2025-12-12 14:06:33 +03:00
parent cf8c93e31b
commit 2a81fa7b1b
2 changed files with 129 additions and 109 deletions

175
flake.nix
View File

@@ -5,92 +5,121 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
outputs = { self, nixpkgs, ... }: let outputs =
system = "x86_64-linux"; { self, nixpkgs, ... }:
pkgs = nixpkgs.legacyPackages.${system}; let
in { system = "x86_64-linux";
packages.${system} = rec { pkgs = nixpkgs.legacyPackages.${system};
clrsync = pkgs.stdenv.mkDerivation rec { in
pname = "clrsync"; {
version = "unstable"; packages.${system} = rec {
clrsync = pkgs.stdenv.mkDerivation rec {
pname = "clrsync";
version = "unstable";
src = self; src = self;
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.cmake pkgs.cmake
pkgs.git pkgs.git
pkgs.pkg-config pkgs.pkg-config
pkgs.makeWrapper pkgs.makeWrapper
]; pkgs.wayland-protocols
];
buildInputs = [ buildInputs = [
pkgs.glfw pkgs.glfw
pkgs.freetype pkgs.freetype
pkgs.fontconfig pkgs.fontconfig
pkgs.xorg.libXcursor pkgs.xorg.libXcursor
pkgs.mesa pkgs.mesa
pkgs.xorg.libX11 pkgs.xorg.libX11
pkgs.xorg.libXrandr pkgs.xorg.libXrandr
pkgs.xorg.libXi pkgs.xorg.libXi
pkgs.xorg.libXinerama pkgs.xorg.libXinerama
pkgs.xorg.libXcursor pkgs.xorg.libXcursor
pkgs.wayland pkgs.wayland
pkgs.wayland-protocols pkgs.wayland-protocols
pkgs.libxkbcommon pkgs.libxkbcommon
pkgs.zlib pkgs.zlib
pkgs.bzip2 pkgs.bzip2
]; ];
cmakeFlags = [ cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_BUILD_TYPE=Release"
"-DUSE_SYSTEM_GLFW=ON" "-DUSE_SYSTEM_GLFW=ON"
]; ];
installPhase = '' installPhase = ''
cmake --install . --prefix $out cmake --install . --prefix $out
wrapProgram $out/bin/clrsync_gui \ wrapProgram $out/bin/clrsync_gui \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
wrapProgram $out/bin/clrsync_cli \ wrapProgram $out/bin/clrsync_cli \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs} --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
''; '';
meta = with pkgs.lib; { meta = with pkgs.lib; {
description = "Color scheme manager (git version)"; description = "Color scheme manager (git version)";
homepage = "https://github.com/obsqrbtz/clrsync"; homepage = "https://github.com/obsqrbtz/clrsync";
license = licenses.mit; license = licenses.mit;
platforms = platforms.linux; platforms = platforms.linux;
mainProgram = "clrsync_gui"; mainProgram = "clrsync_gui";
};
}; };
default = clrsync;
}; };
default = clrsync; apps.${system} = {
}; clrsync-gui = {
type = "app";
program = "${self.packages.${system}.clrsync}/bin/clrsync_gui";
};
apps.${system} = { clrsync-cli = {
clrsync-gui = { type = "app";
type = "app"; program = "${self.packages.${system}.clrsync}/bin/clrsync_cli";
program = "${self.packages.${system}.clrsync}/bin/clrsync_gui"; };
default = self.apps.${system}.clrsync-gui;
}; };
clrsync-cli = { devShells.${system}.default = pkgs.mkShell {
type = "app"; buildInputs = with pkgs; [
program = "${self.packages.${system}.clrsync}/bin/clrsync_cli"; 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
'';
}; };
default = self.apps.${system}.clrsync-gui;
}; };
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
cmake
git
pkg-config
glfw
freetype
fontconfig
xorg.libXcursor
mesa
];
};
};
} }

View File

@@ -1,16 +1,16 @@
#include <iostream>
#include <cstdlib> #include <cstdlib>
#include <iostream>
#include <string> #include <string>
#include <argparse/argparse.hpp> #include <argparse/argparse.hpp>
#include <core/utils.hpp>
#include <core/config/config.hpp> #include <core/config/config.hpp>
#include <core/io/toml_file.hpp> #include <core/io/toml_file.hpp>
#include <core/palette/palette_file.hpp> #include <core/palette/palette_file.hpp>
#include <core/palette/palette_manager.hpp> #include <core/palette/palette_manager.hpp>
#include <core/theme/theme_template.hpp>
#include <core/theme/theme_renderer.hpp> #include <core/theme/theme_renderer.hpp>
#include <core/theme/theme_template.hpp>
#include <core/utils.hpp>
#include <core/version.hpp> #include <core/version.hpp>
void handle_show_vars() void handle_show_vars()
@@ -21,8 +21,7 @@ void handle_show_vars()
void handle_list_themes() void handle_list_themes()
{ {
auto palette_manager = clrsync::core::palette_manager<clrsync::core::io::toml_file>(); auto palette_manager = clrsync::core::palette_manager<clrsync::core::io::toml_file>();
palette_manager.load_palettes_from_directory( palette_manager.load_palettes_from_directory(clrsync::core::config::instance().palettes_path());
clrsync::core::config::instance().palettes_path());
const auto &palettes = palette_manager.palettes(); const auto &palettes = palette_manager.palettes();
std::cout << "Available themes:" << std::endl; std::cout << "Available themes:" << std::endl;
@@ -70,28 +69,20 @@ void initialize_config(const std::string &config_path)
void setup_argument_parser(argparse::ArgumentParser &program) void setup_argument_parser(argparse::ArgumentParser &program)
{ {
program.add_argument("-a", "--apply") program.add_argument("-a", "--apply").help("applies default theme").flag();
.help("applies default theme")
.flag();
program.add_argument("-c", "--config") program.add_argument("-c", "--config")
.default_value(clrsync::core::get_default_config_path()) .default_value(clrsync::core::get_default_config_path())
.help("sets config file path") .help("sets config file path")
.metavar("PATH"); .metavar("PATH");
program.add_argument("-l", "--list-themes") program.add_argument("-l", "--list-themes").help("lists available themes").flag();
.help("lists available themes")
.flag();
program.add_argument("-s", "--show-vars") program.add_argument("-s", "--show-vars").help("shows color keys").flag();
.help("shows color keys")
.flag();
auto &group = program.add_mutually_exclusive_group(); auto &group = program.add_mutually_exclusive_group();
group.add_argument("-t", "--theme") group.add_argument("-t", "--theme").help("sets theme <theme_name> to apply");
.help("sets theme <theme_name> to apply"); group.add_argument("-p", "--path").help("sets theme file <path/to/theme> to apply");
group.add_argument("-p", "--path")
.help("sets theme file <path/to/theme> to apply");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])