Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional simplified configuration syntax #144

Merged
merged 8 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
with:
extra_nix_config: "system-features = kvm nixos-test"
- run: nix flake check -L --keep-going
- run: nix flake check -L --keep-going ./examples/homeManagerFlake
- run: nix flake check -L --keep-going ./examples/systemFlake
- run: nix flake check -L --keep-going --override-input plasma-manager . ./examples/homeManagerFlake
- run: nix flake check -L --keep-going --override-input plasma-manager . ./examples/systemFlake
1 change: 1 addition & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/flake.lock
4 changes: 2 additions & 2 deletions examples/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
# Some low-level settings:
#
configFile = {
"baloofilerc"."Basic Settings"."Indexing-Enabled".value = false;
"kwinrc"."org.kde.kdecoration2"."ButtonsOnLeft".value = "SF";
"baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
"kwinrc"."org.kde.kdecoration2"."ButtonsOnLeft" = "SF";
"kwinrc"."Desktops"."Number" = {
value = 8;
# Forces kde to not change this value (even through the settings app).
Expand Down
4 changes: 2 additions & 2 deletions examples/homeManager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
# Some low-level settings:
#
configFile = {
"baloofilerc"."Basic Settings"."Indexing-Enabled".value = false;
"kwinrc"."org.kde.kdecoration2"."ButtonsOnLeft".value = "SF";
"baloofilerc"."Basic Settings"."Indexing-Enabled" = false;
"kwinrc"."org.kde.kdecoration2"."ButtonsOnLeft" = "SF";
"kwinrc"."Desktops"."Number" = {
value = 8;
# Forces kde to not change this value (even through the settings app).
Expand Down
73 changes: 0 additions & 73 deletions examples/homeManagerFlake/flake.lock

This file was deleted.

4 changes: 2 additions & 2 deletions examples/homeManagerFlake/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
description = "Plasma Manager Example with standalone home-manager flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
Expand Down
73 changes: 0 additions & 73 deletions examples/systemFlake/flake.lock

This file was deleted.

4 changes: 2 additions & 2 deletions examples/systemFlake/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
description = "Plasma Manager Example with system configuration flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ let
};
};
});
coercedSettingsType = with lib.types;
coercedTo basicSettingsType (value: { inherit value; }) advancedSettingsType;
in
{
inherit basicSettingsType;
inherit advancedSettingsType;
inherit coercedSettingsType;
}
18 changes: 9 additions & 9 deletions modules/apps/kate/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ in

config.programs.plasma.configFile."katerc" = lib.mkIf cfg.enable {
"KTextEditor Document" = {
"Auto Detect Indent".value = cfg.editor.indent.autodetect;
"Indentation Width".value = cfg.editor.indent.width;
"Tab Handling".value = (tabHandlingMode cfg.editor.indent);
"Tab Width".value = cfg.editor.tabWidth;
"Keep Extra Spaces".value = cfg.editor.indent.keepExtraSpaces;
"ReplaceTabsDyn".value = cfg.editor.indent.replaceWithSpaces;
"Auto Detect Indent" = cfg.editor.indent.autodetect;
"Indentation Width" = cfg.editor.indent.width;
"Tab Handling" = (tabHandlingMode cfg.editor.indent);
"Tab Width" = cfg.editor.tabWidth;
"Keep Extra Spaces" = cfg.editor.indent.keepExtraSpaces;
"ReplaceTabsDyn" = cfg.editor.indent.replaceWithSpaces;
};

"KTextEditor Renderer" = {
"Show Indentation Lines".value = cfg.editor.indent.showLines;
"Show Indentation Lines" = cfg.editor.indent.showLines;


# COLORTHEME (cannot define this below)
# Do pick the theme if the user chose one,
# Do not touch the theme settings otherwise
"Auto Color Theme Selection".value = lib.mkIf (cfg.editor.theme.name != "") false;
"Color Theme".value = lib.mkIf (cfg.editor.theme.name != "") cfg.editor.theme.name;
"Auto Color Theme Selection" = lib.mkIf (cfg.editor.theme.name != "") false;
"Color Theme" = lib.mkIf (cfg.editor.theme.name != "") cfg.editor.theme.name;
};
};

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/konsole.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ in
programs.plasma.configFile."konsolerc" = lib.mkMerge [
(
lib.mkIf (cfg.defaultProfile != null) {
"Desktop Entry"."DefaultProfile".value = "${cfg.defaultProfile}.profile";
"Desktop Entry"."DefaultProfile" = "${cfg.defaultProfile}.profile";
}
)
(
Expand Down
4 changes: 2 additions & 2 deletions modules/files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

let
inherit (import ../lib/writeconfig.nix { inherit lib pkgs config; }) writeConfig;
inherit (import ../lib/types.nix { inherit lib; }) advancedSettingsType;
inherit (import ../lib/types.nix { inherit lib; }) coercedSettingsType;

# Helper function to prepend the appropriate path prefix (e.g. XDG_CONFIG_HOME) to file
prependPath = prefix: attrset:
Expand All @@ -16,7 +16,7 @@ let
(prependPath config.xdg.configHome plasmaCfg.configFile) //
(prependPath config.xdg.dataHome plasmaCfg.dataFile);

fileSettingsType = with lib.types; attrsOf (attrsOf (attrsOf advancedSettingsType));
fileSettingsType = with lib.types; attrsOf (attrsOf (attrsOf coercedSettingsType));

##############################################################################
# Generate a script that will use write_config.py to update all
Expand Down
41 changes: 22 additions & 19 deletions modules/fonts.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
lib,
config,
...
}: let
{ lib
, config
, ...
}:
let
inherit (lib) mkIf mkOption types;
qfont = import ../lib/qfont.nix {inherit lib;};
qfont = import ../lib/qfont.nix { inherit lib; };

styleStrategyType = types.submodule {
options = with qfont.styleStrategy; {
Expand Down Expand Up @@ -180,7 +180,7 @@
};
styleStrategy = mkOption {
type = styleStrategyType;
default = {};
default = { };
description = ''
The strategy for matching similar fonts to this font.

Expand All @@ -200,7 +200,8 @@

inherit (config.programs.plasma) enable;
cfg = lib.filterAttrs (_: v: v != null) config.programs.plasma.fonts;
in {
in
{
options.programs.plasma.fonts = {
general = mkOption {
type = types.nullOr fontType;
Expand Down Expand Up @@ -270,16 +271,18 @@ in {
};
};

config.programs.plasma.configFile.kdeglobals = let
mkFont = f: mkIf (enable && builtins.hasAttr f cfg) (qfont.fontToString cfg.${f});
in {
General = {
font.value = mkFont "general";
fixed.value = mkFont "fixedWidth";
smallestReadableFont.value = mkFont "small";
toolBarFont.value = mkFont "toolbar";
menuFont.value = mkFont "menu";
config.programs.plasma.configFile.kdeglobals =
let
mkFont = f: mkIf (enable && builtins.hasAttr f cfg) (qfont.fontToString cfg.${f});
in
{
General = {
font = mkFont "general";
fixed = mkFont "fixedWidth";
smallestReadableFont = mkFont "small";
toolBarFont = mkFont "toolbar";
menuFont = mkFont "menu";
};
WM.activeFont = mkFont "windowTitle";
};
WM.activeFont.value = mkFont "windowTitle";
};
}
14 changes: 6 additions & 8 deletions modules/hotkeys.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,17 @@ in
};

programs.plasma.configFile."kglobalshortcutsrc"."${group.desktop}" = {
_k_friendly_name.value = group.description;
_k_friendly_name = group.description;
} // lib.mapAttrs
(_: command:
let
keys = command.keys ++ lib.optionals (command.key != "") [ command.key ];
in
{
value = lib.concatStringsSep "," [
(lib.concatStringsSep "\t" (map (lib.escape [ "," ]) keys))
"" # List of default keys, not needed.
command.comment
];
})
lib.concatStringsSep "," [
(lib.concatStringsSep "\t" (map (lib.escape [ "," ]) keys))
"" # List of default keys, not needed.
command.comment
])
cfg.hotkeys.commands;
};
}
Loading
Loading