feat: Update base module name to rose-pine
This commit is contained in:
parent
847491e797
commit
326ef12cfe
3 changed files with 60 additions and 81 deletions
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
description = "Soothing pastel theme for Nix";
|
||||
description = "Soho vibes for Nix";
|
||||
|
||||
outputs = _: {
|
||||
homeManagerModules.catppuccin = import ./modules/home-manager;
|
||||
nixosModules.catppuccin = import ./modules/nixos;
|
||||
homeManagerModules.rose-pine = import ./modules/home-manager;
|
||||
nixosModules.rose-pine = import ./modules/nixos;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,54 +3,42 @@
|
|||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
# this is a recursive attribute with all the functions below
|
||||
inherit (lib) ctp;
|
||||
in
|
||||
{
|
||||
inherit (lib) rp;
|
||||
in {
|
||||
# string -> type -> string -> a
|
||||
# this is an internal function and shouldn't be
|
||||
# used unless you know what you're doing. it takes
|
||||
# a string (the name of the property, i.e., flavor
|
||||
# or accent), the type of the property, the name of
|
||||
# the module, followed by local config attrset
|
||||
mkBasicOpt =
|
||||
attr: type: name:
|
||||
mkBasicOpt = attr: type: name:
|
||||
lib.mkOption {
|
||||
inherit type;
|
||||
default = config.catppuccin.${attr};
|
||||
description = "Catppuccin ${attr} for ${name}";
|
||||
default = config.rose-pine.${attr};
|
||||
description = "Rose Pine ${attr} for ${name}";
|
||||
};
|
||||
|
||||
# string -> a
|
||||
# this creates a flavor option for modules
|
||||
# the first string should be the name of the module,
|
||||
# followed by the local config attrset
|
||||
mkFlavorOpt = ctp.mkBasicOpt "flavor" ctp.types.flavorOption;
|
||||
mkFlavorOpt = rp.mkBasicOpt "flavor" rp.types.flavorOption;
|
||||
|
||||
types = {
|
||||
flavorOption = lib.types.enum [
|
||||
"latte"
|
||||
"frappe"
|
||||
"macchiato"
|
||||
"mocha"
|
||||
"dawn"
|
||||
"moon"
|
||||
"main"
|
||||
];
|
||||
accentOption = lib.types.enum [
|
||||
"blue"
|
||||
"flamingo"
|
||||
"green"
|
||||
"lavender"
|
||||
"maroon"
|
||||
"mauve"
|
||||
"peach"
|
||||
"pink"
|
||||
"red"
|
||||
"rosewater"
|
||||
"sapphire"
|
||||
"sky"
|
||||
"teal"
|
||||
"yellow"
|
||||
"love"
|
||||
"gold"
|
||||
"rose"
|
||||
"pine"
|
||||
"foam"
|
||||
"iris"
|
||||
];
|
||||
};
|
||||
|
||||
|
@ -58,16 +46,13 @@ in
|
|||
# this capitalizes the first letter in a string,
|
||||
# which is sometimes needed in order to format
|
||||
# the names of themes correctly
|
||||
mkUpper =
|
||||
str:
|
||||
mkUpper = str:
|
||||
(lib.toUpper (builtins.substring 0 1 str)) + (builtins.substring 1 (builtins.stringLength str) str);
|
||||
|
||||
# a -> path -> a
|
||||
# fromJSON but for yaml (and without readFile)
|
||||
# a should be the local pkgs attrset
|
||||
fromYaml =
|
||||
file:
|
||||
let
|
||||
fromYaml = file: let
|
||||
# convert to json
|
||||
json = pkgs.runCommand "converted.json" {} ''
|
||||
${lib.getExe pkgs.yj} < ${file} > $out
|
||||
|
@ -78,9 +63,7 @@ in
|
|||
# a -> path -> a
|
||||
# fromJSON but for ini (and without readFile)
|
||||
# a should be the local pkgs attrset
|
||||
fromINI =
|
||||
file:
|
||||
let
|
||||
fromINI = file: let
|
||||
# convert to json
|
||||
json = pkgs.runCommand "converted.json" {} ''
|
||||
${lib.getExe pkgs.jc} --ini < ${file} > $out
|
||||
|
@ -91,14 +74,11 @@ in
|
|||
# a -> path -> a
|
||||
# fromJSON but for raw ini (and without readFile)
|
||||
# a should be the local pkgs attrset
|
||||
fromINIRaw =
|
||||
file:
|
||||
let
|
||||
fromINIRaw = file: let
|
||||
inherit (builtins) fromJSON readFile;
|
||||
|
||||
# convert to json
|
||||
json =
|
||||
with pkgs;
|
||||
json = with pkgs;
|
||||
runCommand "converted.json" {} ''
|
||||
${jc}/bin/jc --ini -r < ${file} > $out
|
||||
'';
|
||||
|
@ -111,24 +91,24 @@ in
|
|||
# of the module, while `enableDefault` is a boolean
|
||||
# representing the default of the created `enable`
|
||||
# option
|
||||
mkCatppuccinOpt =
|
||||
{
|
||||
mkRosePineOpt = {
|
||||
name,
|
||||
enableDefault ? config.catppuccin.enable,
|
||||
}:
|
||||
{
|
||||
enable = lib.mkEnableOption "Catppuccin theme for ${name}" // {
|
||||
enableDefault ? config.rose-pine.enable,
|
||||
}: {
|
||||
enable =
|
||||
lib.mkEnableOption "Rose Pine theme for ${name}"
|
||||
// {
|
||||
default = enableDefault;
|
||||
};
|
||||
|
||||
flavor = ctp.mkFlavorOpt name;
|
||||
flavor = rp.mkFlavorOpt name;
|
||||
};
|
||||
|
||||
# string -> a
|
||||
# this creates an accent option for modules
|
||||
# the first string should be the name of the module,
|
||||
# followed by the local config attrset
|
||||
mkAccentOpt = ctp.mkBasicOpt "accent" ctp.types.accentOption;
|
||||
mkAccentOpt = rp.mkBasicOpt "accent" rp.types.accentOption;
|
||||
|
||||
# a -> a -> a
|
||||
# see https://nlewo.github.io/nixos-manual-sphinx/development/option-types.xml.html
|
||||
|
@ -140,23 +120,22 @@ in
|
|||
# returns the current release version of nixos or home-manager. throws an evaluation error if neither are
|
||||
# found
|
||||
getModuleRelease =
|
||||
config.home.version.release or config.system.nixos.release
|
||||
config.home.version.release
|
||||
or config.system.nixos.release
|
||||
or (throw "Couldn't determine release version!");
|
||||
|
||||
# string -> a -> a
|
||||
# if the current module release is less than `minVersion`, all options are made no-ops with
|
||||
# `lib.mkSinkUndeclaredOptions`
|
||||
mkVersionedOpts =
|
||||
minVersion: option:
|
||||
if lib.versionAtLeast ctp.getModuleRelease minVersion then
|
||||
option
|
||||
else
|
||||
lib.mkSinkUndeclaredOptions { };
|
||||
mkVersionedOpts = minVersion: option:
|
||||
if lib.versionAtLeast rp.getModuleRelease minVersion
|
||||
then option
|
||||
else lib.mkSinkUndeclaredOptions {};
|
||||
|
||||
# string -> a
|
||||
# this is to ensure users are running a supported version of nixos/home-manager
|
||||
assertMinimumVersion = version: {
|
||||
assertion = lib.versionAtLeast ctp.getModuleRelease version;
|
||||
message = "`catppuccin/nix` requires at least version ${version} of NixOS/home-manager";
|
||||
assertion = lib.versionAtLeast rp.getModuleRelease version;
|
||||
message = "`rose-pine/nix` requires at least version ${version} of NixOS/home-manager";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}:
|
||||
lib.extend (
|
||||
final: _: {
|
||||
ctp = import ./. {
|
||||
rp = import ./. {
|
||||
inherit config pkgs;
|
||||
lib = final;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue