Skip to content

Commit

Permalink
feat(cosmic-term): add comprehensive terminal configuration support
Browse files Browse the repository at this point in the history
- Add complete configuration options for COSMIC Terminal
- Implement color scheme management with dark/light themes
- Add profile management with default profile validation
- Fix RON map key handling for numeric keys
- Add hex color type validation
- Add utilities for null-or options
- Make configuration conditional on hasSettings flag

The module now supports full configuration of COSMIC Terminal including
profiles, color schemes, font settings, and appearance options.
  • Loading branch information
HeitorAugustoLN committed Dec 19, 2024
1 parent 4813846 commit 2b80b44
Show file tree
Hide file tree
Showing 5 changed files with 565 additions and 14 deletions.
8 changes: 5 additions & 3 deletions lib/applications.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@
];

home.packages = lib.optionals (cfg.package != null) [ cfg.package ];
}

wayland.desktopManager.cosmic.configFile = {
"${identifier}" = {
(lib.optionalAttrs hasSettings {
wayland.desktopManager.cosmic = {
configFile."${identifier}" = {
entries = cfg.settings;
version = configurationVersion;
};
};
}
})

(lib.optionalAttrs (args ? extraConfig) (
lib.cosmic.modules.applyExtraConfig { inherit cfg extraConfig; }
Expand Down
6 changes: 5 additions & 1 deletion lib/generators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@
let
keys = builtins.attrNames value.value;
count = builtins.length keys;

isNumeric = string: builtins.match "^[0-9]+$" string != null;
in
if count == 0 then
"{}"
else
"{\n${
lib.concatImapStringsSep "\n" (
index: key:
"${indent nextIndent}\"${key}\": ${toRON' nextIndent (builtins.getAttr key value.value)}${
"${indent nextIndent}${
if isNumeric key then key else lib.strings.escapeNixString key
}: ${toRON' nextIndent (builtins.getAttr key value.value)}${
lib.optionalString (index != count) ","
}"
) keys
Expand Down
14 changes: 14 additions & 0 deletions lib/options.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{ lib, ... }:
{
mkNullOrOption =
{
type,
default ? null,
...
}@args:
lib.mkOption (
args
// {
type = lib.types.nullOr type;
inherit default;
}
);

mkSettingsOption =
{
description,
Expand Down
63 changes: 53 additions & 10 deletions lib/types.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{ lib, ... }:
{
cosmicEntryValue =
with lib.types;
nullOr (oneOf [
str
number
bool
(listOf anything)
(attrsOf anything)
]);

cosmicComponent = lib.types.submodule {
options = {
version = lib.mkOption {
Expand Down Expand Up @@ -37,4 +27,57 @@
};
};
};

cosmicEntryValue =
with lib.types;
nullOr (oneOf [
str
number
bool
(listOf anything)
(attrsOf anything)
]);

cosmicOption = lib.types.submodule {
options = {
__type = lib.mkOption {
type = lib.types.enum [ "option" ];
visible = false;
};
value = lib.mkOption {
type = lib.types.cosmicEntryValue;
visible = false;
};
};
};

cosmicRaw = lib.types.submodule {
options = {
__type = lib.mkOption {
type = lib.types.enum [ "raw" ];
visible = false;
};
value = lib.mkOption {
type = lib.types.str;
visible = false;
};
};
};

cosmicRawEnum =
enum:
lib.types.submodule {
options = {
__type = lib.mkOption {
type = lib.types.enum [ "raw" ];
visible = false;
};
value = lib.mkOption {
type = lib.types.enum enum;
visible = false;
};
};
};

hexColor = lib.types.strMatching "^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$";
}
Loading

0 comments on commit 2b80b44

Please sign in to comment.