mirror of
https://github.com/EdenQwQ/nixos.git
synced 2025-12-29 13:05:01 +08:00
treewide: make the libs actual libs
This commit is contained in:
parent
225f2c1b32
commit
3e6796b3ea
14 changed files with 230 additions and 197 deletions
|
|
@ -6,7 +6,7 @@
|
|||
pkill -HUP swhkd
|
||||
|
||||
super + enter
|
||||
kitty /home/${user}
|
||||
kitty -d /home/${user}
|
||||
|
||||
super + alt + c
|
||||
wl-color-picker
|
||||
|
|
|
|||
|
|
@ -14,19 +14,12 @@ in
|
|||
];
|
||||
programs.fastfetch.enable = true;
|
||||
xdg.configFile."fastfetch/config.jsonc".source = ./fastfetch.jsonc;
|
||||
home.file."Pictures/face.jpg".source = import ../../../lib/wallpaper/goNord.nix {
|
||||
inherit
|
||||
pkgs
|
||||
config
|
||||
;
|
||||
wallpaper = {
|
||||
name = "face";
|
||||
path = pkgs.fetchurl {
|
||||
name = "face.jpg";
|
||||
url = "https://avatars.githubusercontent.com/EdenQwQ";
|
||||
sha256 = "1hxl459l3ni5yaj72dngy9wx9rd1yvb85v31nibv5mih4mp1p6cp";
|
||||
};
|
||||
|
||||
home.file."Pictures/face.jpg".source = config.lib.wallpapers.goNord {
|
||||
name = "face";
|
||||
path = pkgs.fetchurl {
|
||||
name = "face.jpg";
|
||||
url = "https://avatars.githubusercontent.com/EdenQwQ";
|
||||
sha256 = "1hxl459l3ni5yaj72dngy9wx9rd1yvb85v31nibv5mih4mp1p6cp";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
67
home/tweaks/colorscheme.nix
Normal file
67
home/tweaks/colorscheme.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
matugenOptions = lib.types.submodule {
|
||||
options = {
|
||||
image = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.path;
|
||||
description = "Path to the image";
|
||||
};
|
||||
scheme = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The material you scheme to use";
|
||||
default = "scheme-tonal-spot";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
colorScheme = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the color scheme";
|
||||
};
|
||||
isDefault = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Whether the color scheme is the default";
|
||||
default = false;
|
||||
};
|
||||
polarity = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"dark"
|
||||
"light"
|
||||
];
|
||||
description = "Polarity of the color scheme (dark or light)";
|
||||
default = "dark";
|
||||
};
|
||||
matugen = lib.mkOption {
|
||||
type = lib.types.nullOr matugenOptions;
|
||||
description = "Matugen options";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
options.colorSchemes = lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.either colorScheme lib.types.str);
|
||||
description = "List of colorschemes";
|
||||
};
|
||||
|
||||
config =
|
||||
with config.lib.colorScheme;
|
||||
let
|
||||
colorSchemes = config.colorSchemes |> map convertColorScheme;
|
||||
in
|
||||
{
|
||||
stylix = {
|
||||
enable = true;
|
||||
inherit (builtins.filter (c: c.isDefault) colorSchemes |> builtins.head |> buildColorScheme)
|
||||
base16Scheme
|
||||
polarity
|
||||
;
|
||||
};
|
||||
specialisation =
|
||||
builtins.filter (c: !c.isDefault) colorSchemes |> map buildSpecialisation |> builtins.listToAttrs;
|
||||
};
|
||||
}
|
||||
|
|
@ -4,5 +4,7 @@
|
|||
./fcitx5.nix
|
||||
./dconf.nix
|
||||
./stylix.nix
|
||||
./wallpaper.nix
|
||||
./colorscheme.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
recolorScript = import ../../lib/colorScheme/recolor.nix { inherit pkgs config; };
|
||||
inherit (config.lib.colorScheme) recolorScript;
|
||||
in
|
||||
{
|
||||
stylix = {
|
||||
|
|
|
|||
42
home/tweaks/wallpaper.nix
Normal file
42
home/tweaks/wallpaper.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, ... }:
|
||||
with config.lib.wallpapers;
|
||||
let
|
||||
wallpaper = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the wallpaper";
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "URL of the wallpaper";
|
||||
};
|
||||
sha256 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "SHA256 of the wallpaper";
|
||||
};
|
||||
convertMethod = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Method to convert the wallpaper (gonord, lutgen, none)";
|
||||
default = "lutgen";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.wallpapers = lib.mkOption {
|
||||
type = lib.types.listOf wallpaper;
|
||||
description = "List of wallpapers";
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
wallpapers = map getWallpaper config.wallpapers;
|
||||
generatedWallpapers = map generateWallpaper wallpapers;
|
||||
normalWallpapers = map setWallpaper generatedWallpapers |> builtins.listToAttrs;
|
||||
blurredWallpapers = map blurWallpaper generatedWallpapers |> builtins.listToAttrs;
|
||||
in
|
||||
{
|
||||
home.file = normalWallpapers // blurredWallpapers;
|
||||
};
|
||||
}
|
||||
|
|
@ -17,8 +17,8 @@ let
|
|||
../home
|
||||
../nix/nixpkgs.nix
|
||||
../sharedConfig.nix
|
||||
../lib/colorScheme/buildColorScheme.nix
|
||||
../lib/wallpaper/buildWallpaper.nix
|
||||
../lib/colorScheme
|
||||
../lib/wallpaper
|
||||
inputs.nur.modules.homeManager.default
|
||||
inputs.stylix.homeManagerModules.stylix
|
||||
inputs.niri.homeModules.niri
|
||||
|
|
|
|||
|
|
@ -5,53 +5,13 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
matugenOptions = lib.types.submodule {
|
||||
options = {
|
||||
image = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.path;
|
||||
description = "Path to the image";
|
||||
};
|
||||
polarity = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"dark"
|
||||
"light"
|
||||
];
|
||||
description = "Polarity of the color scheme (dark or light)";
|
||||
default = "dark";
|
||||
};
|
||||
scheme = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The material you scheme to use";
|
||||
default = "scheme-tonal-spot";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
colorScheme = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the color scheme";
|
||||
};
|
||||
isDefault = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Whether the color scheme is the default";
|
||||
default = false;
|
||||
};
|
||||
matugen = lib.mkOption {
|
||||
type = lib.types.nullOr matugenOptions;
|
||||
description = "Matugen options";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
convertColorScheme =
|
||||
colorScheme:
|
||||
if builtins.typeOf colorScheme == "string" then
|
||||
{
|
||||
name = colorScheme;
|
||||
isDefault = false;
|
||||
polarity = "dark";
|
||||
matugen = null;
|
||||
}
|
||||
else
|
||||
|
|
@ -62,8 +22,8 @@ let
|
|||
matugenToBase16 =
|
||||
colorScheme:
|
||||
let
|
||||
inherit (colorScheme) name matugen;
|
||||
inherit (matugen) polarity scheme;
|
||||
inherit (colorScheme) name matugen polarity;
|
||||
inherit (matugen) scheme;
|
||||
image =
|
||||
if builtins.typeOf matugen.image == "path" then
|
||||
matugen.image
|
||||
|
|
@ -89,6 +49,7 @@ let
|
|||
inherit (colorScheme)
|
||||
name
|
||||
isDefault
|
||||
polarity
|
||||
matugen
|
||||
;
|
||||
forceOrDefault = if isDefault then lib.mkDefault else lib.mkForce;
|
||||
|
|
@ -99,13 +60,7 @@ let
|
|||
"${matugenToBase16 colorScheme}"
|
||||
else
|
||||
forceOrDefault "${pkgs.base16-schemes}/share/themes/${name}.yaml";
|
||||
polarity =
|
||||
if matugen != null then
|
||||
matugen.polarity
|
||||
else if builtins.fromJSON config.lib.stylix.colors.base00-dec-r < 0.5 then
|
||||
forceOrDefault "dark"
|
||||
else
|
||||
forceOrDefault "light";
|
||||
inherit polarity;
|
||||
};
|
||||
|
||||
buildSpecialisation =
|
||||
|
|
@ -122,21 +77,7 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
options.colorSchemes = lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.either colorScheme lib.types.str);
|
||||
description = "List of colorschemes";
|
||||
config.lib.colorScheme = {
|
||||
inherit convertColorScheme buildColorScheme buildSpecialisation;
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
colorSchemes = config.colorSchemes |> map convertColorScheme;
|
||||
in
|
||||
{
|
||||
stylix = {
|
||||
enable = true;
|
||||
} // (builtins.filter (c: c.isDefault) colorSchemes |> builtins.head |> buildColorScheme);
|
||||
|
||||
specialisation =
|
||||
builtins.filter (c: !c.isDefault) colorSchemes |> map buildSpecialisation |> builtins.listToAttrs;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
6
lib/colorScheme/default.nix
Normal file
6
lib/colorScheme/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./recolor.nix
|
||||
./buildColorScheme.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, config }:
|
||||
{ pkgs, config, ... }:
|
||||
let
|
||||
cfg.recolor = {
|
||||
recolorConfig = {
|
||||
mode = "palette";
|
||||
colors = config.lib.stylix.colors.withHashtag.toList;
|
||||
smooth = true;
|
||||
|
|
@ -31,14 +31,16 @@ let
|
|||
]
|
||||
);
|
||||
in
|
||||
with cfg.recolor;
|
||||
''
|
||||
${pythonEnv}/bin/python ${./recolor.py} --src $out/share/icons \
|
||||
--smooth '${toString smooth}' \
|
||||
${
|
||||
if cfg.recolor.mode == "monochrome" then
|
||||
"--monochrome '${builtins.concatStringsSep "," cfg.recolor.colors}'"
|
||||
else
|
||||
"--palette ''${builtins.concatStringsSep "," cfg.recolor.colors}''"
|
||||
}
|
||||
''
|
||||
with recolorConfig;
|
||||
{
|
||||
config.lib.colorScheme.recolorScript = ''
|
||||
${pythonEnv}/bin/python ${./recolor.py} --src $out/share/icons \
|
||||
--smooth '${toString smooth}' \
|
||||
${
|
||||
if mode == "monochrome" then
|
||||
"--monochrome '${builtins.concatStringsSep "," colors}'"
|
||||
else
|
||||
"--palette ''${builtins.concatStringsSep "," colors}''"
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
}:
|
||||
with builtins;
|
||||
let
|
||||
inherit (config.lib.wallpapers) goNord lutgen;
|
||||
|
||||
getWallpaper =
|
||||
wallpaper:
|
||||
let
|
||||
|
|
@ -16,12 +18,6 @@ let
|
|||
path = "${wallpaperPkg}";
|
||||
};
|
||||
|
||||
wallpapers = map getWallpaper config.wallpapers;
|
||||
|
||||
goNord = wallpaper: import ./goNord.nix { inherit pkgs config wallpaper; };
|
||||
|
||||
lutgen = wallpaper: import ./lutgen.nix { inherit pkgs config wallpaper; };
|
||||
|
||||
getName =
|
||||
path:
|
||||
baseNameOf path |> match "(.*)\\..*" |> head |> lib.splitString "-" |> tail |> concatStringsSep "-";
|
||||
|
|
@ -47,8 +43,6 @@ let
|
|||
path;
|
||||
};
|
||||
|
||||
generatedWallpapers = map generateWallpaper wallpapers;
|
||||
|
||||
setWallpaper =
|
||||
wallpaper:
|
||||
let
|
||||
|
|
@ -78,39 +72,15 @@ let
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
normalWallpapers = map setWallpaper generatedWallpapers |> listToAttrs;
|
||||
blurredWallpapers = map blurWallpaper generatedWallpapers |> listToAttrs;
|
||||
|
||||
wallpaper = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the wallpaper";
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "URL of the wallpaper";
|
||||
};
|
||||
sha256 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "SHA256 of the wallpaper";
|
||||
};
|
||||
convertMethod = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Method to convert the wallpaper (gonord, lutgen, none)";
|
||||
default = "lutgen";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.wallpapers = lib.mkOption {
|
||||
type = lib.types.listOf wallpaper;
|
||||
description = "List of wallpapers";
|
||||
};
|
||||
|
||||
config = {
|
||||
home.file = normalWallpapers // blurredWallpapers;
|
||||
config.lib.wallpapers = {
|
||||
inherit
|
||||
getWallpaper
|
||||
convertWallpaper
|
||||
generateWallpaper
|
||||
setWallpaper
|
||||
blurWallpaper
|
||||
;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
7
lib/wallpaper/default.nix
Normal file
7
lib/wallpaper/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
imports = [
|
||||
./goNord.nix
|
||||
./lutgen.nix
|
||||
./buildWallpaper.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,50 +1,50 @@
|
|||
{ config, pkgs, ... }:
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
wallpaper,
|
||||
}:
|
||||
let
|
||||
goNordScript =
|
||||
pkgs.writers.writePython3Bin "goNord"
|
||||
{
|
||||
libraries = with pkgs.python3Packages; [
|
||||
image-go-nord
|
||||
pyyaml
|
||||
];
|
||||
doCheck = false;
|
||||
}
|
||||
''
|
||||
from ImageGoNord import GoNord
|
||||
import argparse
|
||||
import yaml
|
||||
config.lib.wallpapers.goNord =
|
||||
image:
|
||||
let
|
||||
goNordScript =
|
||||
pkgs.writers.writePython3Bin "goNord"
|
||||
{
|
||||
libraries = with pkgs.python3Packages; [
|
||||
image-go-nord
|
||||
pyyaml
|
||||
];
|
||||
doCheck = false;
|
||||
}
|
||||
''
|
||||
from ImageGoNord import GoNord
|
||||
import argparse
|
||||
import yaml
|
||||
|
||||
parser = argparse.ArgumentParser(description="Go nord")
|
||||
parser.add_argument(
|
||||
"--colorscheme", "-c", help="Path to the yaml file containing the colorscheme"
|
||||
)
|
||||
parser.add_argument("--image", "-i", help="Path to the image to quantize")
|
||||
parser.add_argument(
|
||||
"--output", "-o", help="Path to the output image", default="output.png"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
colorscheme = args.colorscheme
|
||||
image = args.image
|
||||
output = args.output
|
||||
parser = argparse.ArgumentParser(description="Go nord")
|
||||
parser.add_argument(
|
||||
"--colorscheme", "-c", help="Path to the yaml file containing the colorscheme"
|
||||
)
|
||||
parser.add_argument("--image", "-i", help="Path to the image to quantize")
|
||||
parser.add_argument(
|
||||
"--output", "-o", help="Path to the output image", default="output.png"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
colorscheme = args.colorscheme
|
||||
image = args.image
|
||||
output = args.output
|
||||
|
||||
go_nord = GoNord()
|
||||
go_nord.enable_avg_algorithm()
|
||||
go_nord.enable_gaussian_blur()
|
||||
image = go_nord.open_image(image)
|
||||
if colorscheme:
|
||||
go_nord.reset_palette()
|
||||
palette = set(yaml.safe_load(open(colorscheme))["palette"].values())
|
||||
for color in palette:
|
||||
go_nord.add_color_to_palette(color)
|
||||
go_nord.quantize_image(image, save_path=output)
|
||||
'';
|
||||
go_nord = GoNord()
|
||||
go_nord.enable_avg_algorithm()
|
||||
go_nord.enable_gaussian_blur()
|
||||
image = go_nord.open_image(image)
|
||||
if colorscheme:
|
||||
go_nord.reset_palette()
|
||||
palette = set(yaml.safe_load(open(colorscheme))["palette"].values())
|
||||
for color in palette:
|
||||
go_nord.add_color_to_palette(color)
|
||||
go_nord.quantize_image(image, save_path=output)
|
||||
'';
|
||||
|
||||
inherit (wallpaper) name path;
|
||||
in
|
||||
pkgs.runCommand "${name}.jpg" { } ''
|
||||
${goNordScript}/bin/goNord -c ${config.stylix.base16Scheme} -i ${path} -o $out
|
||||
''
|
||||
inherit (image) name path;
|
||||
in
|
||||
pkgs.runCommand "${name}.jpg" { } ''
|
||||
${goNordScript}/bin/goNord -c ${config.stylix.base16Scheme} -i ${path} -o $out
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
wallpaper,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (wallpaper) name path live;
|
||||
colors = builtins.concatStringsSep " " config.lib.stylix.colors.toList;
|
||||
in
|
||||
if live then
|
||||
pkgs.runCommand "${name}.gif" { } ''
|
||||
${pkgs.lutgen}/bin/lutgen generate -o palette.png -- ${colors}
|
||||
${pkgs.ffmpeg}/bin/ffmpeg -i ${path} -i palette.png -filter_complex '[0][1] haldclut' $out
|
||||
''
|
||||
else
|
||||
pkgs.runCommand "${name}.jpg" { } ''
|
||||
${pkgs.lutgen}/bin/lutgen apply -o $out ${path} -- ${colors}
|
||||
''
|
||||
{
|
||||
config.lib.wallpapers.lutgen =
|
||||
image:
|
||||
let
|
||||
inherit (image) name path live;
|
||||
colors = builtins.concatStringsSep " " config.lib.stylix.colors.toList;
|
||||
in
|
||||
if live then
|
||||
pkgs.runCommand "${name}.gif" { } ''
|
||||
${pkgs.lutgen}/bin/lutgen generate -o palette.png -- ${colors}
|
||||
${pkgs.ffmpeg}/bin/ffmpeg -i ${path} -i palette.png -filter_complex '[0][1] haldclut' $out
|
||||
''
|
||||
else
|
||||
pkgs.runCommand "${name}.jpg" { } ''
|
||||
${pkgs.lutgen}/bin/lutgen apply -o $out ${path} -- ${colors}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue