Major updates to readme and example flakes (#104)

Co-authored-by: blitter <blitter@blaupost.de>
This commit is contained in:
magnouvean 2024-03-31 23:29:18 +02:00 committed by GitHub
parent 22b423b9c6
commit 88cf932923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 271 additions and 142 deletions

View File

@ -14,4 +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 ./example
- run: nix flake check -L --keep-going ./examples/homeManagerFlake
- run: nix flake check -L --keep-going ./examples/systemFlake

155
README.md
View File

@ -3,94 +3,85 @@
This project aims to provide [Home Manager][home-manager] modules which allow you
to configure KDE Plasma using Nix.
Configuration is broken down into three layers:
## Table of contents
- [What's supported](#whats-supported)
- [What's not supported](#whats-not-well-supported-at-the-moment)
- [Getting started](#getting-started)
- [Enabling declarative configuration](#make-your-configuration-more-declarative-with-overrideconfig)
- [Capturing existing configuration](#capturing-your-current-configuration-with-rc2nix)
- [Contributions and maintenance](#contributions-and-maintenance)
- [Special thanks](#special-thanks)
1. High-level interface like many Home Manager modules:
## What's supported
At the moment `plasma-manager` supports configuring the following:
- KDE configuration files (via the `files` module)
- Global themes, colorschemes, icons, cursortheme, wallpaper (via the `workspace` module)
- Configuration of spectacle (via the `spectacle` module)
- Shortcuts (via the `shortcuts` module)
- Hotkeys (via the `hotkeys` module)
- Panels (via the `panels` module)
- KDE apps (via the `apps` module). In particular the following kde apps have
modules in `plasma-manager`:
- kate
- konsole
```nix
{
programs.plasma = {
workspace = {
clickItemTo = "select";
tooltipDelay = 5;
theme = "breeze-dark";
colorScheme = "BreezeDark";
wallpaper = "${pkgs.libsForQt5.plasma-workspace-wallpapers}/share/wallpapers/Kay/contents/images/1080x1920.png";
};
Additionally there are more functionality than just listed above, and more
functionality to come in the future!
kwin.titlebarButtons = {
left = [ "on-all-desktops" "keep-above-windows" ];
right = [ "help" "minimize" "maximize" "close" ]
};
spectacle.shortcuts = {
captureActiveWindow = "Meta+Print";
captureCurrentMonitor = "Print";
captureEntireDesktop = "Shift+Print";
captureRectangularRegion = "Meta+Shift+S";
captureWindowUnderCursor = "Meta+Ctrl+Print";
launch = "Meta+S";
launchWithoutCapturing = "Meta+Alt+S";
};
};
}
```
## What's not well supported (at the moment)
There also are some things which at the moment isn't very well supported, in
particular:
- Real-time updates of configuration without having to log out and back in
- Configuration of LibInput devices (see https://github.com/pjones/plasma-manager/issues/47)
- Usage of high-level modules in the configuration generated by `rc2nix`
This layer is doesn't currently have many options. If using a
high-level interface like this sounds interesting to you please
consider contributing more options.
There may also be more things we aren't aware of. If you find some other
limitations don't hesitate to open an issue or submit a pr.
2. Mid-level interface:
## Getting started
We provide some examples to help you get started. These are located in the
[examples](./examples/) directory. Here you in particular can find:
- [An example flake.nix for usage with home-manager only](./examples/homeManagerFlake//flake.nix)
- [An example flake.nix for usage with the system configuration](./examples/systemFlake/flake.nix)
- [An example home.nix showing some of the capabilities of plasma-manager](./examples/home.nix)
```nix
{
programs.plasma = {
shortcuts.kwin = {
"Switch Window Down" = "Meta+J";
"Switch Window Left" = "Meta+H";
"Switch Window Right" = "Meta+L";
"Switch Window Up" = "Meta+K";
};
};
}
```
With more to come! These should give you some idea how to get started with
`plasma-manager`.
This layer is considered mid level because, while it generates a
great deal of configuration for you, you must still know the name
of the corresponding KDE setting to use it. (See information
about the `rc2nix` tool below.)
## Make your configuration more declarative with overrideConfig
By default `plasma-manager` will simply write the specified configurations to
various config-files and leave all other options alone. This way settings not
specified in `plasma-manager` will be left alone, meaning that configurations
made outside `plasma-manager` will still be set. This can lead to different
settings on different machines even with the same `plasma-manager`
configuration. If you like a declarative approach better consider enabling
`overrideConfig`. This makes it so all options not set by `plasma-manager` will
be set to the default on login. In practice this then becomes a declarative
setup, much like what you would expect from most `home-manager` options/modules.
3. A low-level interface:
One thing to keep in mind is that enabling this option will delete all the KDE
config-files on `home-manager` activation, and replace them with config-files
generated by `plasma-manager`. Therefore make sure you backup your KDE
config-files before enabling this option if you don't want to lose them.
```nix
{
programs.plasma = {
configFile."baloofilerc"."Basic Settings"."Indexing-Enabled".value = false;
};
}
```
## Capturing Your Current Configuration with rc2nix
The other two layers ultimately generate Nix configuration for
this low-level layer. Configuration at this level is essentially
in the final state before being sent to our custom
configuration-writing script (which is very similar to
`kwriteconfig5`).
To make it easier to migrate to `plasma-manager`, and to help maintain your Nix
configuration when not using `overrideConfig`, this project includes a tool
called `rc2nix`.
For some examples see the [example](./example/) directory.
This tool will read KDE configuration files and translate them to Nix. The
translated configuration is written to standard output. This makes it easy to:
## Capturing Your Current Configuration
- Generate an initial Plasma Manager configuration file.
- See what settings are changed by a GUI tool by capturing a file
before and after using the tool and then using `diff`.
To make it easier to migrate to Plasma Manger, and to help maintain
your Nix configuration, this project includes a tool called `rc2nix`.
This tool will read KDE configuration files and translate them to
Nix. The translated configuration is written to standard output.
This makes it easy to:
* Generate an initial Plasma Manager configuration file.
* See what settings are changed by a GUI tool by capturing a file
before and after using the tool and then using `diff`.
Keep in mind that the `rc2nix` module isn't perfect and often will give somewhat
suboptimal configurations (it will in some cases prefer using the `files` module
when better configurations can be achieved using higher-level modules). However,
it is still a useful tool to quickly get your configuration up and running or
converting config-files generated by the gui settings app to nix expressions.
To run the `rc2nix` tool without having to clone this repository run
the following shell command:
@ -101,18 +92,14 @@ nix run github:pjones/plasma-manager
## Contributions and Maintenance
I consider this a community project and welcome all contributions. If
there's enough interest I would love to move this into
[nix-community][] once it has matured.
That said, this project works well enough for my needs. I don't have
enough free time to maintain this project on my own. Therefore I
won't be able to fix issues or implement new features without help.
This is a community project and we welcome all contributions. If there's enough
interest we would love to move this into [nix-community] once it has matured.
## Special Thanks
This work was inspired by the suggestions on [Home Manger Issue
#607][hm607] by people such as [bew](https://github.com/bew) and [kurnevsky](https://github.com/kurnevsky). Thank you.
This work was inspired by the suggestions on [Home Manger Issue #607][hm607] by
people such as [bew](https://github.com/bew) and
[kurnevsky](https://github.com/kurnevsky). Thank you.
[home-manager]: https://github.com/nix-community/home-manager
[hm607]: https://github.com/nix-community/home-manager/issues/607

View File

@ -1,45 +0,0 @@
{
description = "Plasma Manager Example";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager.url = "github:nix-community/home-manager/release-23.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.url = "github:pjones/plasma-manager";
plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.inputs.home-manager.follows = "home-manager";
};
outputs = inputs:
let
system = "x86_64-linux";
username = "jdoe";
in
{
# Standalone Home Manager Setup:
homeConfigurations.${username} =
inputs.home-manager.lib.homeManagerConfiguration {
# Ensure Plasma Manager is available:
extraModules = [
inputs.plasma-manager.homeManagerModules.plasma-manager
];
# Specify the path to your home configuration here:
configuration = import ./home.nix;
inherit system username;
homeDirectory = "/home/${username}";
};
# A shell where Home Manager can be used:
devShells.${system}.default =
let pkgs = import inputs.nixpkgs { inherit system; }; in
pkgs.mkShell {
buildInputs = [
inputs.home-manager.packages.${system}.home-manager
];
};
};
}

View File

@ -1,5 +1,7 @@
{ pkgs, ... }:
{
home.stateVersion = "23.11";
programs.plasma = {
enable = true;
@ -26,11 +28,23 @@
location = "bottom";
widgets = [
"org.kde.plasma.kickoff"
"org.kde.plasma.icontasks"
# We can also configure the widgets. For example if you want to pin
# konsole and dolphin to the task-launcher the following widget will
# have that.
{
name = "org.kde.plasma.icontasks";
config = {
General.launchers = [
"applications:org.kde.dolphin.desktop"
"applications:org.kde.konsole.desktop"
];
};
}
"org.kde.plasma.marginsseperator"
"org.kde.plasma.systemtray"
"org.kde.plasma.digitalclock"
];
hiding = "autohide";
}
# Global menu at the top
{

View File

@ -7,32 +7,32 @@
]
},
"locked": {
"lastModified": 1655880690,
"narHash": "sha256-pO+EqUefNFolIWV1DHXPfI8NuUtD4fd7JFKoaCjVXOs=",
"lastModified": 1710888565,
"narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a839432a5c3d2a762d68168093349097e6affb07",
"rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-22.05",
"ref": "release-23.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1656007306,
"narHash": "sha256-MsC44YZ6wuBwn5Bu8T+RVoQWlp2l5BR6hhmNoAAHIEw=",
"lastModified": 1711668574,
"narHash": "sha256-u1dfs0ASQIEr1icTVrsKwg2xToIpn7ZXxW3RHfHxshg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ccf8bdf72624521358be6bb7d9b524c4cbcf7aff",
"rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
@ -47,11 +47,11 @@
]
},
"locked": {
"lastModified": 1656109003,
"narHash": "sha256-UUhp5bBKEL370r5EphALfOrAiBO3w48U1B+97/HPlWY=",
"lastModified": 1711880258,
"narHash": "sha256-4lcNTaKYxKXqAD+OrTC68T2W/Cr69VSogS+R5tjdn+M=",
"owner": "pjones",
"repo": "plasma-manager",
"rev": "1492919230b9484f5b91abdf4759bdbbdd7b6aaa",
"rev": "22b423b9c6f157373d56413835d1d65ea4c5f481",
"type": "github"
},
"original": {

View File

@ -0,0 +1,45 @@
{
description = "Plasma Manager Example with standalone home-manager flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
url = "github:pjones/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
};
outputs = inputs@ { nixpkgs, home-manager, plasma-manager, ... }:
let
# Replace with your username
username = "jdoe";
# Replace with the fitting architecture
system = "x86_64-linux";
in
{
# Replace `standAloneConfig` with the name of your configuration (your `username` or `"username@hostname"`)
homeConfigurations.standAloneConfig = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { inherit system; };
modules = [
inputs.plasma-manager.homeManagerModules.plasma-manager
# Specify the path to your home configuration here:
../home.nix
{
home = {
inherit username;
homeDirectory = "/home/${username}";
};
}
];
};
};
}

View File

@ -0,0 +1,73 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1710888565,
"narHash": "sha256-s9Hi4RHhc6yut4EcYD50sZWRDKsugBJHSbON8KFwoTw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "f33900124c23c4eca5831b9b5eb32ea5894375ce",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711668574,
"narHash": "sha256-u1dfs0ASQIEr1icTVrsKwg2xToIpn7ZXxW3RHfHxshg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"plasma-manager": {
"inputs": {
"home-manager": [
"home-manager"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1711880258,
"narHash": "sha256-4lcNTaKYxKXqAD+OrTC68T2W/Cr69VSogS+R5tjdn+M=",
"owner": "pjones",
"repo": "plasma-manager",
"rev": "22b423b9c6f157373d56413835d1d65ea4c5f481",
"type": "github"
},
"original": {
"owner": "pjones",
"repo": "plasma-manager",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"plasma-manager": "plasma-manager"
}
}
},
"root": "root",
"version": 7
}

View File

@ -0,0 +1,54 @@
{
description = "Plasma Manager Example with system configuration flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
url = "github:pjones/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
};
outputs = inputs@ { nixpkgs, home-manager, plasma-manager, ... }:
let
# Replace with your username
username = "jdoe";
# Replace with the fitting architecture
system = "x86_64-linux";
in
{
# Replace `moduleConfig` with the name of you configuration
nixosConfigurations.moduleConfig = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
# We include the system-configuration here as well. Replace this with
# your own configuration or import your configuration.nix. The demo
# here is just the bare minimum to get the flake to not fail.
{
system.stateVersion = "23.11";
users.users."${username}".isNormalUser = true;
fileSystems."/".device = "/dev/sda";
boot.loader.grub.devices = [ "/dev/sda" ];
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ];
# This should point to your home.nix path of course. For an example
# of this see ./home.nix in this directory.
home-manager.users."${username}" = import ../home.nix;
}
];
};
};
}