refactor rice into config

This commit is contained in:
atagen 2025-07-21 12:26:28 +10:00
parent 8872a12d20
commit e4b7d76769
64 changed files with 225 additions and 230 deletions

View file

@ -1,10 +0,0 @@
{ inputs, mainUser, ... }:
{
imports = [
inputs.meat.nixosModules.meat
];
programs.meat = {
enable = true;
flake = "/home/${mainUser}/.nix";
};
}

View file

@ -1,10 +1,11 @@
{
inputs,
pkgs,
rice,
config,
...
}:
let
inherit (config) rice;
pal = rice.palette.hex;
in
{

View file

@ -1,5 +1,8 @@
{ mainUser, ... }:
{ inputs, mainUser, ... }:
{
imports = [
inputs.meat.nixosModules.meat
];
programs.meat = {
enable = true;
flake = "/home/${mainUser}/.nix";

55
common/rice/default.nix Normal file
View file

@ -0,0 +1,55 @@
{
lib,
inputs,
...
}:
let
nix-rice = import "${inputs.nix-rice}/lib.nix" {
inherit lib;
kitty-themes-src = { };
};
inherit (nix-rice) kitty-themes;
inherit (nix-rice.palette) toRGBShortHex toRGBHex;
theme = kitty-themes.parseTheme ./pal.conf;
in
{
options.rice = lib.mkOption {
description = "ricing related variables";
default = { };
type = lib.types.attrsOf lib.types.anything;
};
config.rice = rec {
palette = theme // {
normal = {
black = theme.color0;
red = theme.color1;
green = theme.color2;
yellow = theme.color3;
blue = theme.color4;
magenta = theme.color5;
cyan = theme.color6;
white = theme.color7;
};
bright = {
black = theme.color8;
red = theme.color9;
green = theme.color10;
yellow = theme.color11;
blue = theme.color12;
magenta = theme.color13;
cyan = theme.color14;
white = theme.color15;
};
util = {
fg = theme.foreground;
bg = theme.background;
fg_sel = theme.selection_foreground;
bg_sel = theme.selection_background;
inherit (theme) cursor;
# url = theme.url_color;
};
hex = toRGBHex palette;
shortHex = toRGBShortHex palette;
};
};
}

View file

@ -1,10 +1,11 @@
{
pkgs,
rice,
inputs,
config,
...
}:
let
inherit (config) rice;
inherit (pkgs) fish;
in
{
@ -29,7 +30,7 @@ in
"la" = "eza -lg --icons=always --colour=always | culr";
};
interactiveShellInit = ''
${../rice/header.sh}
${./rice/header.sh}
'';
};
programs.zoxide = {

View file

@ -1,25 +0,0 @@
{
pkgs,
lib,
inputs,
rice,
...
}:
{
hm.home.packages =
let
inherit (rice) icons fonts cursor;
in
fonts.pkgs
++ icons.pkgs
++ [
cursor.package
];
_module.args.rice = import ../rice {
inherit
inputs
lib
pkgs
;
};
}

View file

@ -6,16 +6,16 @@ in
quiver = {
user = "bolt";
imports = [
./base
./desktop
./common
./graphical
./hosts/quiver
];
};
adrift = {
user = "plank";
imports = [
./base
./desktop
./common
./graphical
./hosts/adrift
];
};

View file

@ -1,4 +1,7 @@
{ rice, ... }:
{ config, ... }:
let
inherit (config) rice;
in
{
boot.tmp.useTmpfs = true;

View file

@ -1,9 +1,10 @@
{
rice,
pkgs,
config,
...
}:
let
inherit (config) rice;
pal = rice.palette.hex;
in
{

View file

@ -1,4 +1,7 @@
{ pkgs, rice, ... }:
{ pkgs, config, ... }:
let
inherit (config) rice;
in
{
# for quickshell
qt.enable = true;

106
graphical/rice.nix Normal file
View file

@ -0,0 +1,106 @@
{
pkgs,
userPkgs,
config,
inputs,
...
}:
{
hm.home.packages =
let
inherit (config.rice) icons fonts cursor;
in
fonts.pkgs
++ icons.pkgs
++ [
cursor.package
];
rice = {
fonts =
let
sans = {
name = "Inria Sans";
size = 12;
package = pkgs.inriafonts;
};
serif = {
name = "Inria Serif";
size = 12;
package = pkgs.inriafonts;
};
monospace = {
name = "Fira Code";
size = 10;
package = pkgs.fira-code;
};
emoji = {
name = "Twitter Color Emoji";
size = 12;
package = pkgs.twemoji-color-font;
};
in
{
inherit
sans
serif
monospace
emoji
;
pkgs = [
sans.package
serif.package
monospace.package
emoji.package
pkgs.meslo-lgs-nf
];
};
icons =
let
package = pkgs.papirus-icon-theme;
in
{
inherit package;
name = "Papirus-Dark";
pkgs = [
package
];
};
gtk-theme = {
name = "nix-rice";
package = pkgs.callPackage userPkgs.gtk-theme { palette = config.rice.palette.shortHex; };
};
borders = {
thickness = 6;
rounding = 0;
gaps_in = 32;
gaps_out = 72;
};
bg = {
src = builtins.path {
name = "wallpaper.jpg";
path = ./rice/wallpaper.jpg;
sha256 = "2db3f9d0397fbd4746ada297bd14c0c7d3e22c7d4e894968fcfece90bbfb902a";
};
};
cursor = {
package = pkgs.afterglow-cursors-recolored.override {
themeVariants = [ "Dracula" ];
draculaColorVariants = [ "Orange" ];
};
name = "Afterglow-Recolored-Dracula-Orange";
};
plymouth = {
theme = "starship";
font = "${config.rice.fonts.sans.package}/share/fonts/truetype/InriaSans-Regular.ttf";
themePackages = [
inputs.hudcore.packages.${pkgs.system}.default
];
};
};
}

View file

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.7 MiB

Before After
Before After

View file

@ -2,12 +2,13 @@
pkgs,
lib,
inputs,
rice,
mainUser,
config,
...
}:
let
inherit (lib) getExe getExe';
inherit (config) rice;
in
{
# quickshell stuff
@ -67,7 +68,7 @@ in
clobber = true;
};
files."/home/${mainUser}/.config/quickshell" = {
source = "/home/${mainUser}/.nix/desktop/quickshell";
source = "/home/${mainUser}/.nix/graphical/shell/quickshell";
uid = 1000;
gid = 100;
};

View file

@ -1,10 +1,13 @@
{
pkgs,
mainUser,
rice,
inputs,
config,
...
}:
let
inherit (config) rice;
in
{
imports = [
inputs.niri.nixosModules.niri

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ config, ... }:
{
boot.initrd.availableKernelModules = [
"xhci_pci"
@ -29,7 +29,8 @@
boot.loader.efi.canTouchEfiVariables = true;
boot.plymouth = {
enable = true;
# inherit (rice.plymouth) theme themePackages font;
# theme needs fixing
# inherit (config.rice.plymouth) theme themePackages font;
};
boot.loader.limine.extraEntries = ''

View file

@ -1,5 +1,4 @@
{ pkgs }:
{ palette }:
{ pkgs, palette }:
let
rendersvg = pkgs.runCommand "rendersvg" { } ''
mkdir -p $out/bin

View file

@ -1,143 +0,0 @@
{
pkgs,
lib,
inputs,
}:
let
nix-rice = import "${inputs.nix-rice}/lib.nix" {
inherit lib;
kitty-themes-src = { };
};
inherit (nix-rice) kitty-themes;
inherit (nix-rice.palette) toRGBShortHex toRGBHex;
theme = kitty-themes.parseTheme ./pal.conf;
in
rec {
palette = theme // {
normal = {
black = theme.color0;
red = theme.color1;
green = theme.color2;
yellow = theme.color3;
blue = theme.color4;
magenta = theme.color5;
cyan = theme.color6;
white = theme.color7;
};
bright = {
black = theme.color8;
red = theme.color9;
green = theme.color10;
yellow = theme.color11;
blue = theme.color12;
magenta = theme.color13;
cyan = theme.color14;
white = theme.color15;
};
util = {
fg = theme.foreground;
bg = theme.background;
fg_sel = theme.selection_foreground;
bg_sel = theme.selection_background;
inherit (theme) cursor;
# url = theme.url_color;
};
hex = toRGBHex palette;
shortHex = toRGBShortHex palette;
};
fonts =
let
sans = {
name = "Inria Sans";
size = 12;
package = pkgs.inriafonts;
};
serif = {
name = "Inria Serif";
size = 12;
package = pkgs.inriafonts;
};
monospace = {
name = "Fira Code";
size = 10;
package = pkgs.fira-code;
};
emoji = {
name = "Twitter Color Emoji";
size = 12;
package = pkgs.twemoji-color-font;
};
in
{
inherit
sans
serif
monospace
emoji
;
pkgs = [
sans.package
serif.package
monospace.package
emoji.package
pkgs.meslo-lgs-nf
];
};
icons =
let
package = pkgs.papirus-icon-theme;
in
{
inherit package;
name = "Papirus-Dark";
pkgs = [
package
];
};
gtk-theme = {
name = "nix-rice";
package = pkgs.callPackage ./gtk-theme.nix { } { palette = toRGBShortHex palette; };
};
borders = {
thickness = 6;
rounding = 0;
gaps_in = 32;
gaps_out = 72;
};
bg = rec {
src =
let
name = "wallpaper.jpg";
in
builtins.path {
inherit name;
path = ./${name};
sha256 = "2db3f9d0397fbd4746ada297bd14c0c7d3e22c7d4e894968fcfece90bbfb902a";
};
image = pkgs.callPackage ./wallpaper.nix { } {
palette = toRGBShortHex palette;
wallpaper = src;
};
};
cursor = {
package = pkgs.afterglow-cursors-recolored.override {
themeVariants = [ "Dracula" ];
draculaColorVariants = [ "Orange" ];
};
name = "Afterglow-Recolored-Dracula-Orange";
};
plymouth = {
theme = "starship";
font = "${fonts.sans.package}/share/fonts/truetype/InriaSans-Regular.ttf";
themePackages = [
inputs.hudcore.packages.${pkgs.system}.default
];
};
}

View file

@ -1,34 +0,0 @@
{
pkgs,
lib,
stdenv,
...
}:
{
palette,
wallpaper,
}:
let
strPal =
let
inherit (lib) concatStringsSep;
inherit (builtins) foldl' attrValues;
in
concatStringsSep " " (
foldl' (acc: el: acc ++ (attrValues el)) [ ] [ palette.normal palette.bright palette.util ]
);
in
stdenv.mkDerivation {
name = "generated-wallpaper.png";
src = wallpaper;
buildInputs = [
pkgs.lutgen
];
phases = [ "installPhase" ];
installPhase = ''
echo -e "Generating wallpaper from ${wallpaper} using palette:\n${strPal}.."
${lib.getExe pkgs.lutgen} apply --lum 0.8 -l 10 -s 128 -n 8 -o $out ${wallpaper} -- ${strPal}
'';
}

View file

@ -3,6 +3,7 @@ let
inherit (inputs) nixpkgs;
inherit (nixpkgs) lib;
recursivelyImport = import ./recursively-import.nix { inherit lib; };
recursivePkgs = import ./recursive-pkgs.nix { inherit lib; };
in
{
systems =
@ -12,6 +13,7 @@ in
nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
userPkgs = recursivePkgs ../pkg;
mainUser = info.user;
};
modules = [

28
util/recursive-pkgs.nix Normal file
View file

@ -0,0 +1,28 @@
{ lib }:
let
getFiles =
path:
builtins.filter (i: lib.hasSuffix ".nix" (builtins.toString i)) (
lib.filesystem.listFilesRecursive path
);
getPkgsAttrs =
path:
let
prefix = builtins.toString path;
in
map (
file:
let
name = lib.pipe file [
builtins.toString
(lib.removePrefix (prefix + "/"))
(lib.removeSuffix ".nix")
];
in
{
"${name}" = file;
}
) (getFiles path);
getAllPkgs = path: lib.mergeAttrsList (getPkgsAttrs path);
in
getAllPkgs