Skip to content

Commit

Permalink
feat(modules): add COSMIC Files and add package default
Browse files Browse the repository at this point in the history
- Add COSMIC Files configuration module with comprehensive settings
- Make package names default to component name in applets and applications
- Update RON expression list handling in utils
- Remove redundant package definition in cosmic-term
  • Loading branch information
HeitorAugustoLN committed Jan 13, 2025
1 parent 6ab7c5b commit 8d91d0c
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/applets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
maintainers,
name,
originalName ? name,
package ? if isBuiltin then null else package,
package ? if isBuiltin then null else name,
settingsDescription ? "Configuration entries for ${originalName} applet.",
settingsOptions ? { },
settingsExample ? null,
Expand Down
2 changes: 1 addition & 1 deletion lib/applications.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
maintainers,
name,
originalName ? name,
package,
package ? name,
settingsDescription ? "Configuration entries for ${originalName}.",
settingsOptions ? { },
settingsExample ? null,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ in
else
toRonExpression value.__type value.value
else if builtins.isList value then
map (v: mkRonExpression' nextIndent v null) value
map (v: mkRonExpression' nextIndent v "list") value
else if builtins.isAttrs value then
builtins.mapAttrs (_: v: mkRonExpression' nextIndent v null) value
else
Expand Down
253 changes: 253 additions & 0 deletions modules/apps/by-name/cosmic-files/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
{ lib, ... }:
let
inherit (lib.cosmic) defaultNullOpts mkRonExpression;
in
lib.cosmic.applications.mkCosmicApplication {
name = "cosmic-files";
originalName = "COSMIC Files";
identifier = "com.system76.CosmicFiles";
configurationVersion = 1;

maintainers = [ lib.maintainers.HeitorAugustoLN ];

settingsOptions = {
app_theme =
defaultNullOpts.mkRonEnum [ "Dark" "Light" "System" ]
{
__type = "enum";
variant = "System";
}
''
The theme of the application.
'';

desktop =
defaultNullOpts.mkNullable
(lib.types.submodule {
freeformType = with lib.types; attrsOf cosmicEntryValue;
options = {
show_content = lib.mkOption {
type = with lib.types; maybeRonRaw bool;
example = true;
description = ''
Whether to show the content of the Desktop folder.
'';
};

show_mounted_drives = lib.mkOption {
type = with lib.types; maybeRonRaw bool;
example = false;
description = ''
Whether to show mounted drives on the Desktop.
'';
};

show_trash = lib.mkOption {
type = with lib.types; maybeRonRaw bool;
example = false;
description = ''
Whether to show the Trash on the Desktop.
'';
};
};
})
{
show_content = true;
show_mounted_drives = false;
show_trash = false;
}
''
The desktop icons settings.
'';

favorites =
defaultNullOpts.mkListOf
(
with lib.types;
either (ronEnum [
"Documents"
"Downloads"
"Home"
"Music"
"Pictures"
"Videos"
]) (ronTupleEnumOf lib.types.str [ "Path" ])
)
[
{
__type = "enum";
variant = "Home";
}
{
__type = "enum";
variant = "Documents";
}
{
__type = "enum";
variant = "Downloads";
}
{
__type = "enum";
variant = "Music";
}
{
__type = "enum";
variant = "Pictures";
}
{
__type = "enum";
variant = "Videos";
}
]
''
The list of favorite folders.
'';

show_details = defaultNullOpts.mkBool false ''
Whether to show file details.
'';

tab =
defaultNullOpts.mkNullable
(lib.types.submodule {
freeformType = with lib.types; attrsOf cosmicEntryValue;
options = {
folders_first = lib.mkOption {
type = with lib.types; maybeRonRaw bool;
example = true;
description = ''
Whether to show folders before files.
'';
};

icon_sizes = lib.mkOption {
type = lib.types.submodule {
freeformType = with lib.types; attrsOf cosmicEntryValue;
options = {
grid = lib.mkOption {
type =
with lib.types;
maybeRonRaw (
addCheck ints.u16 (x: x > 0)
// {
description = "Non-zero unsigned 16-bit integer";
}
);
example = 100;
description = ''
The size of the icons in the grid view.
'';
};

list = lib.mkOption {
type =
with lib.types;
maybeRonRaw (
addCheck ints.u16 (x: x > 0)
// {
description = "Non-zero unsigned 16-bit integer";
}
);
example = 100;
description = ''
The size of the icons in the list view.
'';
};
};
};
};

show_hidden = lib.mkOption {
type = with lib.types; maybeRonRaw bool;
example = false;
description = ''
Whether to show hidden files.
'';
};

view = lib.mkOption {
type =
with lib.types;
maybeRonRaw (ronEnum [
"Grid"
"List"
]);
example = mkRonExpression 0 {
__type = "enum";
variant = "List";
} null;
};
};
})
{
folders_first = true;
icon_sizes = {
grid = 100;
list = 100;
};
show_hidden = false;
view = {
__type = "enum";
variant = "List";
};
}
''
The tab settings.
'';
};

settingsExample = {
app_theme = {
__type = "enum";
variant = "System";
};

desktop = {
show_content = true;
show_mounted_drives = false;
show_trash = false;
};

favorites = [
{
__type = "enum";
variant = "Home";
}
{
__type = "enum";
variant = "Documents";
}
{
__type = "enum";
variant = "Downloads";
}
{
__type = "enum";
variant = "Music";
}
{
__type = "enum";
variant = "Pictures";
}
{
__type = "enum";
variant = "Videos";
}
];

show_details = false;

tab = {
folders_first = true;
icon_sizes = {
grid = 100;
list = 100;
};
show_hidden = false;
view = {
__type = "enum";
variant = "List";
};
};
};
}
1 change: 0 additions & 1 deletion modules/apps/by-name/cosmic-term/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ in
lib.cosmic.applications.mkCosmicApplication {
name = "cosmic-term";
originalName = "COSMIC Terminal Emulator";
package = "cosmic-term";
identifier = "com.system76.CosmicTerm";
configurationVersion = 1;

Expand Down

0 comments on commit 8d91d0c

Please sign in to comment.