mirror of
https://github.com/EdenQwQ/nixos.git
synced 2025-12-26 18:34:56 +08:00
update colorscheme module; use maple mono font
This commit is contained in:
parent
0a0b350b3a
commit
0de8efbba0
11 changed files with 191 additions and 51 deletions
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -939,11 +939,11 @@
|
|||
},
|
||||
"nixpkgs_6": {
|
||||
"locked": {
|
||||
"lastModified": 1742422364,
|
||||
"narHash": "sha256-mNqIplmEohk5jRkqYqG19GA8MbQ/D4gQSK0Mu4LvfRQ=",
|
||||
"lastModified": 1742889210,
|
||||
"narHash": "sha256-hw63HnwnqU3ZQfsMclLhMvOezpM7RSB0dMAtD5/sOiw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a84ebe20c6bc2ecbcfb000a50776219f48d134cc",
|
||||
"rev": "698214a32beb4f4c8e3942372c694f40848b360d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -12,29 +12,32 @@ let
|
|||
name = colorScheme;
|
||||
isDefault = false;
|
||||
polarity = "dark";
|
||||
matugen = null;
|
||||
fromImage.enable = false;
|
||||
}
|
||||
else
|
||||
colorScheme;
|
||||
|
||||
wallpapers = config.wallpapers;
|
||||
|
||||
getImage =
|
||||
image:
|
||||
if builtins.typeOf image == "path" then
|
||||
image
|
||||
else
|
||||
pkgs.fetchurl {
|
||||
inherit (builtins.filter (wallpaper: wallpaper.name == image) wallpapers |> builtins.head)
|
||||
name
|
||||
url
|
||||
sha256
|
||||
;
|
||||
};
|
||||
|
||||
matugenToBase16 =
|
||||
colorScheme:
|
||||
let
|
||||
inherit (colorScheme) name matugen polarity;
|
||||
inherit (matugen) scheme;
|
||||
image =
|
||||
if builtins.typeOf matugen.image == "path" then
|
||||
matugen.image
|
||||
else
|
||||
pkgs.fetchurl {
|
||||
inherit (builtins.filter (wallpaper: wallpaper.name == matugen.image) wallpapers |> builtins.head)
|
||||
name
|
||||
url
|
||||
sha256
|
||||
;
|
||||
};
|
||||
inherit (colorScheme) name polarity fromImage;
|
||||
image = getImage fromImage.image;
|
||||
scheme = if builtins.hasAttr "scheme" fromImage.passthru then fromImage.passthru.scheme else null;
|
||||
in
|
||||
pkgs.runCommand "${name}.yaml" { buildInputs = [ pkgs.matugen ]; }
|
||||
# bash
|
||||
|
|
@ -43,6 +46,19 @@ let
|
|||
--name ${name} --polarity ${polarity} --type ${scheme} --output $out
|
||||
'';
|
||||
|
||||
hellwalToBase16 =
|
||||
colorScheme:
|
||||
let
|
||||
inherit (colorScheme) name polarity fromImage;
|
||||
image = getImage fromImage.image;
|
||||
in
|
||||
pkgs.runCommand "${name}.yaml" { buildInputs = [ pkgs.hellwal ]; }
|
||||
# bash
|
||||
''
|
||||
${pkgs.python3}/bin/python ${./hellwal2base16.py} ${image} \
|
||||
--name ${name} --polarity ${polarity} --output $out
|
||||
'';
|
||||
|
||||
buildColorScheme =
|
||||
colorScheme:
|
||||
let
|
||||
|
|
@ -50,16 +66,29 @@ let
|
|||
name
|
||||
isDefault
|
||||
polarity
|
||||
matugen
|
||||
fromImage
|
||||
;
|
||||
forceOrDefault = if isDefault then lib.mkDefault else lib.mkForce;
|
||||
in
|
||||
{
|
||||
base16Scheme =
|
||||
if matugen != null then
|
||||
"${matugenToBase16 colorScheme}"
|
||||
(
|
||||
if fromImage.enable then
|
||||
let
|
||||
inherit (fromImage) method;
|
||||
in
|
||||
if method == "matugen" then
|
||||
{
|
||||
base16Scheme = forceOrDefault "${matugenToBase16 colorScheme}";
|
||||
}
|
||||
else
|
||||
forceOrDefault "${pkgs.base16-schemes}/share/themes/${name}.yaml";
|
||||
{
|
||||
base16Scheme = forceOrDefault "${hellwalToBase16 colorScheme}";
|
||||
}
|
||||
else
|
||||
{
|
||||
base16Scheme = forceOrDefault "${pkgs.base16-schemes}/share/themes/${name}.yaml";
|
||||
}
|
||||
)
|
||||
// {
|
||||
inherit polarity;
|
||||
};
|
||||
|
||||
|
|
|
|||
56
home/lib/colorScheme/hellwal2base16.py
Normal file
56
home/lib/colorScheme/hellwal2base16.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import json
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Create base16 yaml file from matugen output"
|
||||
)
|
||||
parser.add_argument("image", help="The image to generate the colors from")
|
||||
parser.add_argument("--name", "-n", help="The name of the colorscheme")
|
||||
parser.add_argument("--polarity", "-p", help="Dark or light", default="dark")
|
||||
parser.add_argument("--output", "-o", help="The output file", default="base16.yaml")
|
||||
args = parser.parse_args()
|
||||
image = args.image
|
||||
name = args.name
|
||||
polarity = args.polarity
|
||||
output = args.output
|
||||
|
||||
hellwal_output = subprocess.run(
|
||||
["hellwal", "-i", image, "--dark" if polarity == "dark" else "--light", "--json"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout
|
||||
|
||||
colors = json.loads(hellwal_output)["colors"]
|
||||
|
||||
base16_colors = {
|
||||
name: f'"{colors[colorname].strip("'")}"'
|
||||
for name, colorname in [
|
||||
("base00", "color0"),
|
||||
("base01", "color1"),
|
||||
("base02", "color2"),
|
||||
("base03", "color3"),
|
||||
("base04", "color4"),
|
||||
("base05", "color5"),
|
||||
("base06", "color6"),
|
||||
("base07", "color7"),
|
||||
("base08", "color8"),
|
||||
("base09", "color9"),
|
||||
("base0A", "color10"),
|
||||
("base0B", "color11"),
|
||||
("base0C", "color12"),
|
||||
("base0D", "color13"),
|
||||
("base0E", "color14"),
|
||||
("base0F", "color15"),
|
||||
]
|
||||
}
|
||||
|
||||
yaml_content = f"""system: "base16"
|
||||
name: "{name}"
|
||||
author: "matugen"
|
||||
variant: "{polarity}"
|
||||
palette:
|
||||
""" + "\n".join([f" {k}: {v}" for k, v in base16_colors.items()])
|
||||
|
||||
with open(output, "w") as f:
|
||||
f.write(yaml_content)
|
||||
|
|
@ -12,8 +12,6 @@
|
|||
window_padding_width = "10 20 10 20";
|
||||
cursor_trail = 1;
|
||||
cursor_trail_start_threshold = 0;
|
||||
font_family = lib.mkForce "Monofur Nerd Font";
|
||||
font_size = lib.mkForce 15;
|
||||
};
|
||||
extraConfig = ''
|
||||
map ctrl+shift+p kitten hints --type path --program @
|
||||
|
|
|
|||
|
|
@ -36,12 +36,13 @@
|
|||
direnv
|
||||
entr
|
||||
lutgen
|
||||
matugen
|
||||
hellwal
|
||||
imagemagick
|
||||
ffmpeg
|
||||
nurl
|
||||
nix-init
|
||||
wl-color-picker
|
||||
matugen
|
||||
(config.lib.misc.addFlags "--wayland-text-input-version=3" "cherry-studio" cherry-studio)
|
||||
];
|
||||
imports = [
|
||||
|
|
|
|||
|
|
@ -5,13 +5,22 @@
|
|||
isDefault = true;
|
||||
}
|
||||
"everforest"
|
||||
"nord"
|
||||
{
|
||||
name = "frieren-butterflies-dark";
|
||||
fromImage = {
|
||||
enable = true;
|
||||
image = "frieren-butterflies.jpg";
|
||||
method = "hellwal";
|
||||
};
|
||||
}
|
||||
"petrichor-downpour"
|
||||
{
|
||||
name = "green-blue-flowers-dark";
|
||||
matugen = {
|
||||
image = "green-blue-flowers.jpg";
|
||||
scheme = "scheme-expressive";
|
||||
name = "zzzzoka-gbc-dark";
|
||||
fromImage = {
|
||||
enable = true;
|
||||
image = "zzzzoka-gbc.jpg";
|
||||
method = "matugen";
|
||||
passthru.scheme = "scheme-expressive";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ in
|
|||
size = 32;
|
||||
};
|
||||
fonts = {
|
||||
monospace.name = "Comic Mono";
|
||||
monospace.package = pkgs.comic-mono;
|
||||
monospace.name = "Maple Mono NF CN";
|
||||
monospace.package = pkgs.maple-mono.NF-CN;
|
||||
sansSerif.name = "LXGW WenKai";
|
||||
sansSerif.package = pkgs.lxgw-wenkai;
|
||||
serif.name = "LXGW WenKai";
|
||||
|
|
|
|||
|
|
@ -16,6 +16,29 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
fromImageOptions = submodule {
|
||||
options = {
|
||||
enable = mkEnableOption "Enable generating colorscheme from image";
|
||||
image = mkOption {
|
||||
type = either str path;
|
||||
description = "Path to the image";
|
||||
};
|
||||
method = mkOption {
|
||||
type = enum [
|
||||
"matugen"
|
||||
"hellwal"
|
||||
"stylix"
|
||||
];
|
||||
description = "The method to use to generate the colorscheme";
|
||||
default = "matugen";
|
||||
};
|
||||
passthru = mkOption {
|
||||
type = attrs;
|
||||
description = "Passthru options to the method";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
colorScheme = submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
|
|
@ -35,10 +58,12 @@ let
|
|||
description = "Polarity of the color scheme (dark or light)";
|
||||
default = "dark";
|
||||
};
|
||||
matugen = mkOption {
|
||||
type = nullOr matugenOptions;
|
||||
description = "Matugen options";
|
||||
default = null;
|
||||
fromImage = mkOption {
|
||||
type = fromImageOptions;
|
||||
description = "Options for generating colorscheme from image";
|
||||
default = {
|
||||
enable = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
nerd-fonts.hurmit
|
||||
nerd-fonts.monofur
|
||||
lxgw-wenkai
|
||||
maple-mono.NF-CN
|
||||
maple-mono.variable
|
||||
];
|
||||
fonts.fontDir.enable = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,41 @@ let
|
|||
cfg = self.homeConfigurations."${user}@${host}".config;
|
||||
in
|
||||
{
|
||||
stylix = {
|
||||
enable = true;
|
||||
base16Scheme = lib.mkDefault cfg.stylix.base16Scheme;
|
||||
autoEnable = false;
|
||||
targets = {
|
||||
console.enable = true;
|
||||
gnome.enable = true;
|
||||
grub.enable = true;
|
||||
plymouth.enable = true;
|
||||
};
|
||||
};
|
||||
stylix =
|
||||
{
|
||||
enable = true;
|
||||
autoEnable = false;
|
||||
targets = {
|
||||
console.enable = true;
|
||||
gnome.enable = true;
|
||||
grub.enable = true;
|
||||
plymouth.enable = true;
|
||||
};
|
||||
}
|
||||
// (
|
||||
if builtins.hasAttr "base16Scheme" cfg.stylix then
|
||||
{ base16Scheme = lib.mkDefault cfg.stylix.base16Scheme; }
|
||||
else
|
||||
{ }
|
||||
)
|
||||
// (
|
||||
if builtins.hasAttr "image" cfg.stylix then { image = lib.mkDefault cfg.stylix.image; } else { }
|
||||
);
|
||||
specialisation = builtins.mapAttrs (name: value: {
|
||||
configuration = {
|
||||
stylix.base16Scheme = lib.mkForce cfg.specialisation.${name}.configuration.stylix.base16Scheme;
|
||||
stylix =
|
||||
(
|
||||
if builtins.hasAttr "base16Scheme" value.configuration.stylix then
|
||||
{ base16Scheme = lib.mkForce cfg.specialisation.${name}.configuration.stylix.base16Scheme; }
|
||||
else
|
||||
{ }
|
||||
)
|
||||
// (
|
||||
if builtins.hasAttr "image" value.configuration.stylix then
|
||||
{ image = lib.mkForce cfg.specialisation.${name}.configuration.stylix.image; }
|
||||
else
|
||||
{ }
|
||||
);
|
||||
environment.etc."specialisation".text = name;
|
||||
};
|
||||
}) cfg.specialisation;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
inherit (pkgs.callPackage ./R.nix { }) myR;
|
||||
inherit (pkgs.callPackage ./R.nix { }) myRstudio;
|
||||
inherit (pkgs.callPackage ./R.nix { }) myR myRstudio;
|
||||
zju-connect = pkgs.callPackage ./zju-connect.nix { };
|
||||
swhkd = pkgs.callPackage ./swhkd.nix { };
|
||||
kose-font = pkgs.callPackage ./fonts/kose.nix { };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue