diff --git a/flake.nix b/flake.nix index 30d09482..97ce08a4 100644 --- a/flake.nix +++ b/flake.nix @@ -22,13 +22,6 @@ inherit (nixpkgs) lib; forAllSystems = fn: lib.genAttrs systems (s: fn nixpkgs.legacyPackages.${s}); - - sources = pkgs: - let - s = - import ./_sources/generated.nix { inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools; }; - in - builtins.mapAttrs (_: p: p.src) s; in { checks = forAllSystems (pkgs: lib.optionalAttrs pkgs.stdenv.isLinux { @@ -37,9 +30,9 @@ formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt); - homeManagerModules.catppuccin = import ./modules/home-manager { inherit inputs sources; }; + homeManagerModules.catppuccin = import ./modules/home-manager; - nixosModules.catppuccin = import ./modules/nixos { inherit inputs sources; }; + nixosModules.catppuccin = import ./modules/nixos; packages = forAllSystems (pkgs: let @@ -60,7 +53,7 @@ doc = pkgs.nixosOptionsDoc { options = lib.filterAttrs (n: _: n != "_module") (eval module).options; documentType = "none"; - revision = builtins.substring 0 7 self.rev or "dirty"; + revision = builtins.substring 0 8 self.rev or "dirty"; }; in pkgs.runCommand "${name}-module-doc.md" { } '' diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 268e7ca4..4987c64a 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,45 +1,4 @@ -{ inputs, ... }@flakeArgs: { lib, pkgs, ... }@systemArgs: -let - extendedLib = import ../lib/mkExtLib.nix inputs.nixpkgs.lib (flakeArgs // systemArgs); - inherit (extendedLib) ctp; -in +{ lib, pkgs, ... }@args: { - imports = - let - files = [ - ./alacritty.nix - ./bat.nix - ./bottom.nix - ./btop.nix - ./fish.nix - ./kitty.nix - ./lazygit.nix - ./starship.nix - ./helix.nix - ./hyprland.nix - ./glamour.nix - ./gtk.nix - ./mako.nix - ./neovim.nix - ./micro.nix - ./polybar.nix - ./sway.nix - ./tmux.nix - ./zathura.nix - ]; - in - extendedLib.ctp.mapModules extendedLib files; - - options.catppuccin = { - flavour = lib.mkOption { - type = ctp.types.flavourOption; - default = "latte"; - description = "Global Catppuccin flavour"; - }; - accent = lib.mkOption { - type = ctp.types.accentOption; - default = "teal"; - description = "Global Catppuccin accent"; - }; - }; + imports = import ../lib/mkImports.nix args ./.; } diff --git a/modules/home-manager/globals.nix b/modules/home-manager/globals.nix new file mode 100644 index 00000000..259cd99f --- /dev/null +++ b/modules/home-manager/globals.nix @@ -0,0 +1,15 @@ +{ lib, ... }: { + options.catppuccin = { + flavour = lib.mkOption { + type = lib.ctp.types.flavourOption; + default = "latte"; + description = "Global Catppuccin flavour"; + }; + + accent = lib.mkOption { + type = lib.ctp.types.accentOption; + default = "teal"; + description = "Global Catppuccin accent"; + }; + }; +} diff --git a/modules/home-manager/zathura.nix b/modules/home-manager/zathura.nix index 5bfbae9e..d19c4329 100644 --- a/modules/home-manager/zathura.nix +++ b/modules/home-manager/zathura.nix @@ -2,6 +2,7 @@ , pkgs , lib , sources +, ... }: let cfg = config.programs.zathura.catppuccin; diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 9db36882..272ce9f8 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -1,4 +1,4 @@ -lib: { config, pkgs, sources, ... }: +{ config, lib, pkgs, ... }: let # string -> type -> string -> a -> a # this is an internal function and shouldn't be @@ -80,16 +80,6 @@ in in fromJSON (readFile json); - # a -> a -> [path] -> [path] - # this imports a list of paths while inheriting - # multiple attributes - mapModules = extendedLib: - map (m: (import m { - inherit config pkgs; - sources = sources pkgs; - lib = extendedLib; - })); - # string -> a -> a # this creates a basic attrset only containing an # enable and flavour option. the fist string should diff --git a/modules/lib/mkExtLib.nix b/modules/lib/mkExtLib.nix deleted file mode 100644 index 45ef539b..00000000 --- a/modules/lib/mkExtLib.nix +++ /dev/null @@ -1 +0,0 @@ -lib: args: lib.extend (self: _: { ctp = import ./. self args; }) diff --git a/modules/lib/mkImports.nix b/modules/lib/mkImports.nix new file mode 100644 index 00000000..8eaa61f0 --- /dev/null +++ b/modules/lib/mkImports.nix @@ -0,0 +1,22 @@ +# this imports all files in a directory (besides default.nix) +# with our modified arguments +{ lib, pkgs, ... }@args: +dir: +let + generated = pkgs.callPackage ../../_sources/generated.nix { }; +in +lib.pipe dir [ + builtins.readDir + builtins.attrNames + + (builtins.filter ( + n: !(builtins.elem n [ "default.nix" ]) + )) + + (map ( + f: _: import "${dir}/${f}" (args // { + sources = builtins.mapAttrs (_: p: p.src) generated; + lib = lib.extend (_: _: { ctp = import ./. args; }); + }) + )) +] diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 07a17b2f..4987c64a 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,22 +1,4 @@ -{ inputs, ... }@flakeArgs: { lib, pkgs, ... }@systemArgs: -let - extendedLib = import ../lib/mkExtLib.nix inputs.nixpkgs.lib (systemArgs // flakeArgs); -in +{ lib, pkgs, ... }@args: { - imports = - let - files = [ - ./grub.nix - ]; - in - extendedLib.ctp.mapModules extendedLib files; - - - options.catppuccin = with extendedLib; { - flavour = mkOption { - type = ctp.types.flavourOption; - default = "latte"; - description = "Global Catppuccin flavour"; - }; - }; + imports = import ../lib/mkImports.nix args ./.; } diff --git a/modules/nixos/globals.nix b/modules/nixos/globals.nix new file mode 100644 index 00000000..63ea819f --- /dev/null +++ b/modules/nixos/globals.nix @@ -0,0 +1,9 @@ +{ lib, ... }: { + options.catppuccin = { + flavour = lib.mkOption { + type = lib.ctp.types.flavourOption; + default = "latte"; + description = "Global Catppuccin flavour"; + }; + }; +}