From 326ef12cfe2f05a91a1d504949bcbc16e5285361 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 19 Oct 2024 10:53:12 -0700 Subject: [PATCH] feat: Update base module name to rose-pine --- flake.nix | 6 +- modules/lib/default.nix | 133 ++++++++++++++++--------------------- modules/lib/mk-ext-lib.nix | 2 +- 3 files changed, 60 insertions(+), 81 deletions(-) diff --git a/flake.nix b/flake.nix index e5bac3b..9c91483 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; } diff --git a/modules/lib/default.nix b/modules/lib/default.nix index ec44674..b84c2f5 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -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,51 +46,43 @@ 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 - # convert to json - json = pkgs.runCommand "converted.json" { } '' - ${lib.getExe pkgs.yj} < ${file} > $out - ''; - in + fromYaml = file: let + # convert to json + json = pkgs.runCommand "converted.json" {} '' + ${lib.getExe pkgs.yj} < ${file} > $out + ''; + in builtins.fromJSON (builtins.readFile json); # a -> path -> a # fromJSON but for ini (and without readFile) # a should be the local pkgs attrset - fromINI = - file: - let - # convert to json - json = pkgs.runCommand "converted.json" { } '' - ${lib.getExe pkgs.jc} --ini < ${file} > $out - ''; - in + fromINI = file: let + # convert to json + json = pkgs.runCommand "converted.json" {} '' + ${lib.getExe pkgs.jc} --ini < ${file} > $out + ''; + in builtins.fromJSON (builtins.readFile json); # a -> path -> a # fromJSON but for raw ini (and without readFile) # a should be the local pkgs attrset - fromINIRaw = - file: - let - inherit (builtins) fromJSON readFile; + fromINIRaw = file: let + inherit (builtins) fromJSON readFile; - # convert to json - json = - with pkgs; - runCommand "converted.json" { } '' - ${jc}/bin/jc --ini -r < ${file} > $out - ''; - in + # convert to json + json = with pkgs; + runCommand "converted.json" {} '' + ${jc}/bin/jc --ini -r < ${file} > $out + ''; + in fromJSON (readFile json); # string -> a @@ -111,24 +91,24 @@ in # of the module, while `enableDefault` is a boolean # representing the default of the created `enable` # option - mkCatppuccinOpt = - { - name, - enableDefault ? config.catppuccin.enable, - }: - { - enable = lib.mkEnableOption "Catppuccin theme for ${name}" // { + mkRosePineOpt = { + 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 - or (throw "Couldn't determine release version!"); + 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"; }; } diff --git a/modules/lib/mk-ext-lib.nix b/modules/lib/mk-ext-lib.nix index 55f39e8..247f202 100644 --- a/modules/lib/mk-ext-lib.nix +++ b/modules/lib/mk-ext-lib.nix @@ -6,7 +6,7 @@ }: lib.extend ( final: _: { - ctp = import ./. { + rp = import ./. { inherit config pkgs; lib = final; };