mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-08 20:19:04 +03:00
cleaned up module and added package with overlay
This commit is contained in:
32
.gitignore
vendored
32
.gitignore
vendored
@@ -3,17 +3,20 @@
|
|||||||
.vs
|
.vs
|
||||||
out
|
out
|
||||||
|
|
||||||
/build
|
build/
|
||||||
/build-*
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
cmake_install.cmake
|
||||||
|
Makefile
|
||||||
|
*.cmake
|
||||||
|
|
||||||
/AUR/clrsync-git
|
AUR/clrsync-git
|
||||||
/AUR/pkg
|
AUR/pkg
|
||||||
/AUR/src
|
AUR/src
|
||||||
|
|
||||||
/result
|
result
|
||||||
/result-*
|
result-*
|
||||||
|
.direnv/
|
||||||
/.direnv
|
|
||||||
|
|
||||||
*.log
|
*.log
|
||||||
*tar.zst
|
*tar.zst
|
||||||
@@ -22,4 +25,13 @@ out
|
|||||||
*.swp
|
*.swp
|
||||||
*.bak
|
*.bak
|
||||||
*.tmp
|
*.tmp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
140
README.md
140
README.md
@@ -10,19 +10,41 @@ A theme management tool for synchronizing color schemes across multiple applicat
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
- [Features](#features)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [NixOS](#nixos)
|
||||||
|
- [Home Manager Module](#home-manager-module)
|
||||||
|
- [Package](#package)
|
||||||
|
- [Install to profile](#install-to-profile)
|
||||||
|
- [Run without installing](#run-without-installing)
|
||||||
|
- [Other systems](#other-systems)
|
||||||
|
- [Building](#building)
|
||||||
|
- [Prerequisites](#prerequisites)
|
||||||
|
- [With CMake](#with-cmake)
|
||||||
|
- [Configuration](#configuration)
|
||||||
|
- [Palette Files](#palette-files)
|
||||||
|
- [Template Files](#template-files)
|
||||||
|
- [Color Format Specifiers](#color-format-specifiers)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [CLI](#cli)
|
||||||
|
- [GUI](#gui)
|
||||||
|
- [Acknowledgments](#acknowledgments)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Unified Color Management**: Define color palettes in TOML format and apply them across multiple applications
|
- **Unified Color Management**: Define color palettes in TOML format and apply them across multiple applications
|
||||||
- **CLI & GUI**: Choose between a command-line interface or a graphical editor
|
- **CLI & GUI**: Choose between a command-line interface or a graphical editor
|
||||||
- **Live Reload**: Define post-apply hooks (configurable per template)
|
- **Live Reload**: Define post-apply hooks (configurable per template)
|
||||||
- **Flexible Color Formats**: Support for HEX, RGB, HSL with multi-component access (e.g., `{color.r}`, `{color.hex}`, `{color.hsl}`)
|
- **Flexible Color Formats**: Support for HEX, RGB, HSL with multi-component access (e.g., `{color.r}`, `{color.hex}`, `{color.hsl}`)
|
||||||
- **Pre-built Themes**: Includes popular themes
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### NixOS
|
### NixOS
|
||||||
|
|
||||||
#### Home Manager Module
|
<details>
|
||||||
|
<summary>Home Manager Module</summary>
|
||||||
|
|
||||||
1. Add clrsync to your flake inputs
|
1. Add clrsync to your flake inputs
|
||||||
|
|
||||||
@@ -37,21 +59,38 @@ A theme management tool for synchronizing color schemes across multiple applicat
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Import the Home Manager module
|
2. Add clrsync to flake outputs
|
||||||
|
|
||||||
In home.nix:
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
imports = [
|
outputs =
|
||||||
inputs.clrsync.homemanagermodules.default
|
{
|
||||||
];
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
home-manager,
|
||||||
|
clrsync,
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# ...
|
||||||
|
homeConfigurations.<Your user name> = home-manager.lib.homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
extraSpecialArgs = { inherit inputs; };
|
||||||
|
modules = [
|
||||||
|
./home.nix
|
||||||
|
clrsync.homeManagerModules.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Configure in home manager
|
3. Configure in home manager
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
programs.clrsync = {
|
programs.clrsync = {
|
||||||
enable = true;
|
|
||||||
package = inputs.clrsync.packages.x86_64-linux.default;
|
package = inputs.clrsync.packages.x86_64-linux.default;
|
||||||
defaultTheme = "dark";
|
defaultTheme = "dark";
|
||||||
palettesPath = "~/.config/clrsync/palettes";
|
palettesPath = "~/.config/clrsync/palettes";
|
||||||
@@ -75,13 +114,17 @@ programs.clrsync = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Rebuild
|
4. Rebuild
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
home-manager switch --flake .
|
home-manager switch --flake .
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Package (For non-declarative configurations)
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Package</summary>
|
||||||
|
|
||||||
1. Add clrsync to your flake inputs
|
1. Add clrsync to your flake inputs
|
||||||
|
|
||||||
@@ -97,13 +140,31 @@ home-manager switch --flake .
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
# In NixOS configuration.nix:
|
# In NixOS configuration.nix:
|
||||||
environment.systemPackages = [
|
nixpkgs.overlays = [
|
||||||
inputs.clrsync.packages.x86_64-linux.default
|
inputs.clrsync.overlays.default
|
||||||
];
|
];
|
||||||
|
|
||||||
# Or in Home Manager:
|
environment.systemPackages = [
|
||||||
|
clrsync
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
Or for home manager:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# flake.nix
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [
|
||||||
|
clrsync.overlays.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# home.nix
|
||||||
home.packages = [
|
home.packages = [
|
||||||
inputs.clrsync.packages.x86_64-linux.default
|
clrsync
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -116,10 +177,30 @@ clrsync_gui
|
|||||||
clrsync_cli --apply --theme dark
|
clrsync_cli --apply --theme dark
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Install to profile</summary>
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix profile add github:obsqrbtz/clrsync
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Run without installing</summary>
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix run github:obsqrbtz/clrsync
|
||||||
|
nix run github:obsqrbtz/clrsync#clrsync-cli
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### Other systems
|
### Other systems
|
||||||
|
|
||||||
Follow the steps from Building section then install with cmake:
|
Follow the steps from Building section then install with cmake:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd build
|
cd build
|
||||||
cmake --install .
|
cmake --install .
|
||||||
@@ -137,7 +218,6 @@ cmake --install .
|
|||||||
- freetype
|
- freetype
|
||||||
|
|
||||||
### With CMake
|
### With CMake
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
@@ -147,7 +227,6 @@ cmake --build .
|
|||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Edit or create a configuration file at `~/.config/clrsync/config.toml`:
|
Edit or create a configuration file at `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[general]
|
[general]
|
||||||
palettes_path = "~/.config/clrsync/palettes"
|
palettes_path = "~/.config/clrsync/palettes"
|
||||||
@@ -162,8 +241,10 @@ reload_cmd = "pkill -SIGUSR1 kitty"
|
|||||||
|
|
||||||
### Palette Files
|
### Palette Files
|
||||||
|
|
||||||
Create palette files in your `palettes_path` directory:
|
<details>
|
||||||
|
<summary>Example palette file</summary>
|
||||||
|
|
||||||
|
Create palette files in your `palettes_path` directory:
|
||||||
```toml
|
```toml
|
||||||
# ~/.config/clrsync/palettes/dark.toml
|
# ~/.config/clrsync/palettes/dark.toml
|
||||||
[general]
|
[general]
|
||||||
@@ -222,10 +303,14 @@ surface_variant = '#1C1C1CFF'
|
|||||||
warning = '#E1C135FF'
|
warning = '#E1C135FF'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### Template Files
|
### Template Files
|
||||||
|
|
||||||
Create template files at `~/.config/clrsync/templates` using color variables:
|
<details>
|
||||||
|
<summary>Example template file</summary>
|
||||||
|
|
||||||
|
Create template files at `~/.config/clrsync/templates` using color variables:
|
||||||
```conf
|
```conf
|
||||||
# ~/.config/clrsync/templates/kitty.conf
|
# ~/.config/clrsync/templates/kitty.conf
|
||||||
cursor {cursor}
|
cursor {cursor}
|
||||||
@@ -253,10 +338,12 @@ color7 {base07}
|
|||||||
color15 {base0F}
|
color15 {base0F}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Color Format Specifiers
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Color Format Specifiers</summary>
|
||||||
|
|
||||||
Format colors using dot notation:
|
Format colors using dot notation:
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
# HEX formats
|
# HEX formats
|
||||||
{color} # Default: #RRGGBB
|
{color} # Default: #RRGGBB
|
||||||
@@ -286,42 +373,38 @@ Format colors using dot notation:
|
|||||||
{color.a} # Alpha component
|
{color.a} # Alpha component
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### CLI
|
### CLI
|
||||||
|
|
||||||
List available themes:
|
List available themes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --list-themes
|
clrsync_cli --list-themes
|
||||||
```
|
```
|
||||||
|
|
||||||
Apply the default theme:
|
Apply the default theme:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --apply
|
clrsync_cli --apply
|
||||||
```
|
```
|
||||||
|
|
||||||
Apply a specific theme:
|
Apply a specific theme:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --apply --theme cursed
|
clrsync_cli --apply --theme cursed
|
||||||
```
|
```
|
||||||
|
|
||||||
Apply a theme from a file path:
|
Apply a theme from a file path:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --apply --path /path/to/theme.toml
|
clrsync_cli --apply --path /path/to/theme.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
Show available color variables:
|
Show available color variables:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --show-vars
|
clrsync_cli --show-vars
|
||||||
```
|
```
|
||||||
|
|
||||||
Use a custom config file:
|
Use a custom config file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_cli --config /path/to/config.toml --apply
|
clrsync_cli --config /path/to/config.toml --apply
|
||||||
```
|
```
|
||||||
@@ -329,7 +412,6 @@ clrsync_cli --config /path/to/config.toml --apply
|
|||||||
### GUI
|
### GUI
|
||||||
|
|
||||||
Launch the graphical editor:
|
Launch the graphical editor:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clrsync_gui
|
clrsync_gui
|
||||||
```
|
```
|
||||||
@@ -348,4 +430,4 @@ The GUI provides:
|
|||||||
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
|
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
|
||||||
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
|
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
|
||||||
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
|
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
|
||||||
- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme
|
- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme
|
||||||
158
flake.nix
158
flake.nix
@@ -8,121 +8,79 @@
|
|||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, ... }:
|
{ self, nixpkgs, ... }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
supportedSystems = [
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${system} = rec {
|
packages = forAllSystems (
|
||||||
clrsync = pkgs.stdenv.mkDerivation rec {
|
system:
|
||||||
pname = "clrsync";
|
let
|
||||||
version = "unstable";
|
pkgs = nixpkgsFor.${system};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
clrsync = pkgs.callPackage ./package.nix { };
|
||||||
|
default = clrsync;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
src = self;
|
homeModules = {
|
||||||
|
default = import ./home-manager-module.nix self;
|
||||||
nativeBuildInputs = [
|
clrsync = self.homeModules.default;
|
||||||
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
|
|
||||||
];
|
|
||||||
|
|
||||||
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}
|
|
||||||
'';
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
homeManagerModules.default = import ./home-manager-module.nix;
|
apps = forAllSystems (system: {
|
||||||
homeManagerModules.clrsync = self.homeManagerModules.default;
|
|
||||||
|
|
||||||
apps.${system} = {
|
|
||||||
clrsync-gui = {
|
clrsync-gui = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.packages.${system}.clrsync}/bin/clrsync_gui";
|
program = "${self.packages.${system}.clrsync}/bin/clrsync_gui";
|
||||||
|
meta = {
|
||||||
|
description = "clrsync gui app";
|
||||||
|
license = self.packages.x86_64-linux.licenses.mit;
|
||||||
|
maintainers = [ "Daniel Dada" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
clrsync-cli = {
|
clrsync-cli = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.packages.${system}.clrsync}/bin/clrsync_cli";
|
program = "${self.packages.${system}.clrsync}/bin/clrsync_cli";
|
||||||
|
meta = {
|
||||||
|
description = "clrsync cli app";
|
||||||
|
license = self.packages.x86_64-linux.licenses.mit;
|
||||||
|
maintainers = [ "Daniel Dada" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
default = self.apps.${system}.clrsync-gui;
|
default = self.apps.${system}.clrsync-cli;
|
||||||
|
});
|
||||||
|
|
||||||
|
devShells = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgsFor.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
inputsFrom = [ self.packages.${system}.clrsync ];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
cmake
|
||||||
|
ninja
|
||||||
|
clang-tools
|
||||||
|
gdb
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export CMAKE_GENERATOR="Ninja"
|
||||||
|
export CMAKE_EXPORT_COMPILE_COMMANDS=1
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
overlays.default = final: prev: {
|
||||||
|
clrsync = self.packages.${final.system}.clrsync;
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
flake:
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
@@ -8,11 +9,8 @@ with lib;
|
|||||||
let
|
let
|
||||||
cfg = config.programs.clrsync;
|
cfg = config.programs.clrsync;
|
||||||
|
|
||||||
defaultPackage =
|
clrsyncPackage = flake.packages.${pkgs.system}.default;
|
||||||
if args ? inputs && args.inputs ? clrsync
|
|
||||||
then args.inputs.clrsync.packages.${pkgs.system}.default or null
|
|
||||||
else null;
|
|
||||||
|
|
||||||
templateType = types.submodule {
|
templateType = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
enabled = mkOption {
|
enabled = mkOption {
|
||||||
@@ -35,6 +33,7 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
configFormat = pkgs.formats.toml { };
|
configFormat = pkgs.formats.toml { };
|
||||||
configFile = configFormat.generate "config.toml" {
|
configFile = configFormat.generate "config.toml" {
|
||||||
general = {
|
general = {
|
||||||
@@ -43,43 +42,44 @@ let
|
|||||||
font = cfg.font;
|
font = cfg.font;
|
||||||
font_size = cfg.fontSize;
|
font_size = cfg.fontSize;
|
||||||
};
|
};
|
||||||
templates = mapAttrs (name: template: {
|
templates = mapAttrs (
|
||||||
enabled = template.enabled;
|
name: template: {
|
||||||
input_path = template.inputPath;
|
enabled = template.enabled;
|
||||||
output_path = template.outputPath;
|
input_path = template.inputPath;
|
||||||
reload_cmd = template.reloadCmd;
|
output_path = template.outputPath;
|
||||||
}) cfg.templates;
|
reload_cmd = template.reloadCmd;
|
||||||
|
}
|
||||||
|
) cfg.templates;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.clrsync = {
|
options.programs.clrsync = {
|
||||||
enable = mkEnableOption "clrsync color synchronization";
|
enable = mkEnableOption "clrsync color synchronization";
|
||||||
package = mkOption {
|
|
||||||
type = types.nullOr types.package;
|
|
||||||
default = defaultPackage;
|
|
||||||
defaultText = literalExpression "inputs.clrsync.packages.\${pkgs.system}.default";
|
|
||||||
description = "The clrsync package to use.";
|
|
||||||
};
|
|
||||||
defaultTheme = mkOption {
|
defaultTheme = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "cursed";
|
default = "cursed";
|
||||||
description = "Default theme to use.";
|
description = "Default theme to use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
palettesPath = mkOption {
|
palettesPath = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "~/.config/clrsync/palettes";
|
default = "~/.config/clrsync/palettes";
|
||||||
description = "Path to color palettes directory.";
|
description = "Path to color palettes directory.";
|
||||||
};
|
};
|
||||||
|
|
||||||
font = mkOption {
|
font = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "JetBrainsMono Nerd Font Mono";
|
default = "JetBrainsMono Nerd Font Mono";
|
||||||
description = "Font family to use.";
|
description = "Font family to use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
fontSize = mkOption {
|
fontSize = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 14;
|
default = 14;
|
||||||
description = "Font size.";
|
description = "Font size.";
|
||||||
};
|
};
|
||||||
|
|
||||||
templates = mkOption {
|
templates = mkOption {
|
||||||
type = types.attrsOf templateType;
|
type = types.attrsOf templateType;
|
||||||
default = { };
|
default = { };
|
||||||
@@ -95,64 +95,61 @@ in
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
applyTheme = mkOption {
|
applyTheme = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether to apply the default theme on activation.";
|
description = "Whether to apply the default theme on activation.";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemdTarget = mkOption {
|
systemdTarget = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "graphical-session.target";
|
default = "graphical-session.target";
|
||||||
description = "Systemd target to bind the clrsync service to.";
|
description = "Systemd target to bind the clrsync service to.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable (mkMerge [
|
|
||||||
{
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
home.packages = [ clrsyncPackage ];
|
||||||
{
|
|
||||||
assertion = cfg.package != null;
|
xdg.enable = true;
|
||||||
message = ''
|
|
||||||
programs.clrsync.package could not be automatically determined.
|
home.activation.clrsyncDesktop = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
Please add clrsync to your flake inputs and pass it via extraSpecialArgs:
|
if [ -d "$HOME/.nix-profile/share/applications" ]; then
|
||||||
|
${pkgs.desktop-file-utils}/bin/update-desktop-database "$HOME/.nix-profile/share/applications" || true
|
||||||
home-manager.extraSpecialArgs = { inherit inputs; };
|
fi
|
||||||
|
'';
|
||||||
Or manually set:
|
|
||||||
programs.clrsync.package = inputs.clrsync.packages.''${pkgs.system}.default;
|
xdg.configFile."clrsync/config.toml" = {
|
||||||
'';
|
source = configFile;
|
||||||
}
|
force = true;
|
||||||
];
|
};
|
||||||
}
|
|
||||||
(mkIf (cfg.package != null) {
|
home.activation.clrsyncConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
home.packages = [ cfg.package ];
|
run --quiet mkdir -p $HOME/.config/clrsync
|
||||||
xdg.configFile."clrsync/config.toml" = {
|
run --quiet cp -f ${configFile} $HOME/.config/clrsync/config.toml
|
||||||
source = configFile;
|
'';
|
||||||
force = true;
|
|
||||||
|
home.activation.clrsyncApply = mkIf cfg.applyTheme (
|
||||||
|
lib.hm.dag.entryAfter [ "clrsyncConfig" ] ''
|
||||||
|
run --quiet ${clrsyncPackage}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
systemd.user.services.clrsync = mkIf cfg.applyTheme {
|
||||||
|
Unit = {
|
||||||
|
Description = "Apply clrsync color palette";
|
||||||
|
After = [ cfg.systemdTarget ];
|
||||||
|
PartOf = [ cfg.systemdTarget ];
|
||||||
};
|
};
|
||||||
home.activation.clrsyncConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
Service = {
|
||||||
run --quiet mkdir -p $HOME/.config/clrsync
|
Type = "oneshot";
|
||||||
run --quiet cp -f ${configFile} $HOME/.config/clrsync/config.toml
|
ExecStart = "${clrsyncPackage}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}";
|
||||||
'';
|
RemainAfterExit = true;
|
||||||
home.activation.clrsyncApply = mkIf cfg.applyTheme (
|
|
||||||
lib.hm.dag.entryAfter [ "clrsyncConfig" ] ''
|
|
||||||
run --quiet ${cfg.package}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}
|
|
||||||
''
|
|
||||||
);
|
|
||||||
systemd.user.services.clrsync = mkIf cfg.applyTheme {
|
|
||||||
Unit = {
|
|
||||||
Description = "Apply clrsync color palette";
|
|
||||||
After = [ cfg.systemdTarget ];
|
|
||||||
PartOf = [ cfg.systemdTarget ];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
Type = "oneshot";
|
|
||||||
ExecStart = "${cfg.package}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
|
||||||
Install = {
|
|
||||||
WantedBy = [ cfg.systemdTarget ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
})
|
Install = {
|
||||||
]);
|
WantedBy = [ cfg.systemdTarget ];
|
||||||
}
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
93
package.nix
Normal file
93
package.nix
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
cmake,
|
||||||
|
git,
|
||||||
|
pkg-config,
|
||||||
|
makeWrapper,
|
||||||
|
wayland-protocols,
|
||||||
|
glfw,
|
||||||
|
freetype,
|
||||||
|
fontconfig,
|
||||||
|
mesa,
|
||||||
|
xorg,
|
||||||
|
wayland,
|
||||||
|
libxkbcommon,
|
||||||
|
zlib,
|
||||||
|
bzip2,
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "clrsync";
|
||||||
|
version = "unstable-2024-12-15";
|
||||||
|
|
||||||
|
src = lib.cleanSourceWith {
|
||||||
|
src = ./.;
|
||||||
|
filter = path: type:
|
||||||
|
let
|
||||||
|
baseName = baseNameOf path;
|
||||||
|
in
|
||||||
|
! (lib.hasSuffix ".o" baseName
|
||||||
|
|| lib.hasSuffix ".a" baseName
|
||||||
|
|| baseName == "build"
|
||||||
|
|| baseName == "CMakeCache.txt"
|
||||||
|
|| baseName == "CMakeFiles"
|
||||||
|
|| baseName == ".git"
|
||||||
|
|| baseName == "result"
|
||||||
|
|| baseName == ".direnv"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake
|
||||||
|
git
|
||||||
|
pkg-config
|
||||||
|
makeWrapper
|
||||||
|
wayland-protocols
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
glfw
|
||||||
|
freetype
|
||||||
|
fontconfig
|
||||||
|
xorg.libXcursor
|
||||||
|
mesa
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXi
|
||||||
|
xorg.libXinerama
|
||||||
|
wayland
|
||||||
|
wayland-protocols
|
||||||
|
libxkbcommon
|
||||||
|
zlib
|
||||||
|
bzip2
|
||||||
|
];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DCMAKE_BUILD_TYPE=Release"
|
||||||
|
"-DUSE_SYSTEM_GLFW=ON"
|
||||||
|
];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
cmake --install . --prefix $out
|
||||||
|
|
||||||
|
wrapProgram $out/bin/clrsync_gui \
|
||||||
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
|
||||||
|
|
||||||
|
wrapProgram $out/bin/clrsync_cli \
|
||||||
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Color scheme manager with GUI and CLI";
|
||||||
|
homepage = "https://github.com/obsqrbtz/clrsync";
|
||||||
|
license = licenses.mit;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
mainProgram = "clrsync_gui";
|
||||||
|
maintainers = [ ];
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user