1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

Optimize Nix Flake for Niri / Hyprland (#242)

* feat: Make niri stuff optional

* doc: Add some documentation about the flake

* Simplify modules.

* Overlay pkgs and simplify modules.

* Fix niri config levels.

* Fix documentation.

* Just pass the packages to the module

---------

Co-authored-by: Eduardo Barreto Alexandre <blibs@blobs.com>
Co-authored-by: Luis González <5774777+luis-agm@users.noreply.github.com>
This commit is contained in:
Eduardo B. A.
2025-09-26 11:44:41 -03:00
committed by GitHub
parent e6296f20b9
commit 97b86c6faa
4 changed files with 262 additions and 178 deletions

View File

@@ -175,6 +175,60 @@ paru -S dms-shell-git
nix profile install github:AvengeMedia/DankMaterialShell
```
#### nixOS - via home-manager
To install using home-manager, you need to add this repo into your flake inputs:
``` nix
dankMaterialShell = {
url = "github:AvengeMedia/DankMaterialShell/make_niri_optional";
inputs.nixpkgs.follows = "nixpkgs";
};
```
Then somewhere in your home-manager config, add this to the imports:
``` nix
imports = [
inputs.dankMaterialShell.homeModules.dankMaterialShell.default
];
```
If you use Niri, the `niri` homeModule provides additional options for Niri integration, such as key bindings and spawn:
``` nix
imports = [
inputs.dankMaterialShell.homeModules.dankMaterialShell.default
inputs.dankMaterialShell.homeModules.dankMaterialShell.niri
];
```
> [!IMPORTANT]
> To use the `niri` homeModule, you must have `sobidoo/niri-flake` in your inputs:
``` nix
niri = {
url = "github:sodiboo/niri-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
```
And import it in home-manager:
``` nix
imports = [
inputs.niri.homeModules.niri
];
```
Now you can enable it with:
``` nix
programs.dankMaterialShell.enable = true;
```
There are a lot of possible configurations that you can enable/disable in the flake, check [nix/default.nix](nix/default.nix) and [nix/niri.nix](nix/niri.nix) to see them all.
#### Other Distributions - via manual installation
**1. Install Quickshell (Varies by Distribution)**

188
flake.nix
View File

@@ -48,185 +48,17 @@
default = self.packages.${system}.dankMaterialShell;
});
homeModules.dankMaterialShell = {
config,
pkgs,
lib,
...
}: let
cfg = config.programs.dankMaterialShell;
inherit (lib.types) bool;
homeModules.dankMaterialShell.default = {pkgs, ...}: let
dmsPkgs = {
dmsCli = dms-cli.packages.${pkgs.system}.default;
dgop = dgop.packages.${pkgs.system}.dgop;
dankMaterialShell = self.packages.${pkgs.system}.dankMaterialShell;
};
in {
options.programs.dankMaterialShell = {
enable = lib.mkEnableOption "DankMaterialShell";
enableKeybinds = lib.mkEnableOption "DankMaterialShell niri keybinds";
enableSystemd = lib.mkEnableOption "DankMaterialShell systemd startup";
enableSpawn = lib.mkEnableOption "DankMaterialShell niri spawn-at-startup";
enableSystemMonitoring = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use system monitoring widgets";
};
enableClipboard = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use the clipboard widget";
};
enableVPN = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use the VPN widget";
};
enableBrightnessControl = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have brightness/backlight support";
};
enableNightMode = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have night mode support";
};
enableDynamicTheming = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have dynamic theming support";
};
enableAudioWavelength = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have audio waveleng support";
};
enableCalendarEvents = lib.mkOption {
type = bool;
default = true;
description = "Add calendar events support via khal";
};
quickshell = {
package = lib.mkPackageOption pkgs "quickshell" {};
};
};
config = lib.mkIf cfg.enable {
programs.quickshell = {
enable = true;
package = cfg.quickshell.package;
configs.dms = "${
self.packages.${pkgs.system}.dankMaterialShell
}/etc/xdg/quickshell/DankMaterialShell";
activeConfig = lib.mkIf cfg.enableSystemd "dms";
systemd = lib.mkIf cfg.enableSystemd {
enable = true;
target = "graphical-session.target";
};
};
programs.niri.settings = lib.mkMerge [
(lib.mkIf cfg.enableKeybinds {
binds = with config.lib.niri.actions; let
dms-ipc = spawn "dms" "ipc";
in
{
"Mod+Space" = {
action = dms-ipc "spotlight" "toggle";
hotkey-overlay.title = "Toggle Application Launcher";
};
"Mod+N" = {
action = dms-ipc "notifications" "toggle";
hotkey-overlay.title = "Toggle Notification Center";
};
"Mod+Comma" = {
action = dms-ipc "settings" "toggle";
hotkey-overlay.title = "Toggle Settings";
};
"Mod+P" = {
action = dms-ipc "notepad" "toggle";
hotkey-overlay.title = "Toggle Notepad";
};
"Super+Alt+L" = {
action = dms-ipc "lock" "lock";
hotkey-overlay.title = "Toggle Lock Screen";
};
"Mod+X" = {
action = dms-ipc "powermenu" "toggle";
hotkey-overlay.title = "Toggle Power Menu";
};
"XF86AudioRaiseVolume" = {
allow-when-locked = true;
action = dms-ipc "audio" "increment" "3";
};
"XF86AudioLowerVolume" = {
allow-when-locked = true;
action = dms-ipc "audio" "decrement" "3";
};
"XF86AudioMute" = {
allow-when-locked = true;
action = dms-ipc "audio" "mute";
};
"XF86AudioMicMute" = {
allow-when-locked = true;
action = dms-ipc "audio" "micmute";
};
}
// lib.attrsets.optionalAttrs cfg.enableSystemMonitoring {
"Mod+M" = {
action = dms-ipc "processlist" "toggle";
hotkey-overlay.title = "Toggle Process List";
};
}
// lib.attrsets.optionalAttrs cfg.enableClipboard {
"Mod+V" = {
action = dms-ipc "clipboard" "toggle";
hotkey-overlay.title = "Toggle Clipboard Manager";
};
}
// lib.attrsets.optionalAttrs cfg.enableBrightnessControl {
"XF86MonBrightnessUp" = {
allow-when-locked = true;
action = dms-ipc "brightness" "increment" "5" "";
};
"XF86MonBrightnessDown" = {
allow-when-locked = true;
action = dms-ipc "brightness" "decrement" "5" "";
};
}
// lib.attrsets.optionalAttrs cfg.enableNightMode {
"Mod+Alt+N" = {
allow-when-locked = true;
action = dms-ipc "night" "toggle";
hotkey-overlay.title = "Toggle Night Mode";
};
};
})
(lib.mkIf cfg.enableSpawn {
spawn-at-startup = [
{command = ["dms" "run"];}
];
})
];
home.packages =
[
pkgs.material-symbols
pkgs.inter
pkgs.fira-code
pkgs.ddcutil
pkgs.libsForQt5.qt5ct
pkgs.kdePackages.qt6ct
dms-cli.packages.${pkgs.system}.default
]
++ lib.optional cfg.enableSystemMonitoring dgop.packages.${pkgs.system}.dgop
++ lib.optionals cfg.enableClipboard [pkgs.cliphist pkgs.wl-clipboard]
++ lib.optionals cfg.enableVPN [pkgs.glib pkgs.networkmanager]
++ lib.optional cfg.enableBrightnessControl pkgs.brightnessctl
++ lib.optional cfg.enableNightMode pkgs.gammastep
++ lib.optional cfg.enableDynamicTheming pkgs.matugen
++ lib.optional cfg.enableAudioWavelength pkgs.cava
++ lib.optional cfg.enableCalendarEvents pkgs.khal;
};
imports = [./nix/default.nix];
_module.args.dmsPkgs = dmsPkgs;
};
homeModules.dankMaterialShell.niri = import ./nix/niri.nix;
};
}

97
nix/default.nix Normal file
View File

@@ -0,0 +1,97 @@
{
config,
pkgs,
lib,
dmsPkgs,
...
}: let
cfg = config.programs.dankMaterialShell;
in {
options.programs.dankMaterialShell = with lib.types; {
enable = lib.mkEnableOption "DankMaterialShell";
enableSystemd = lib.mkEnableOption "DankMaterialShell systemd startup";
enableSystemMonitoring = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use system monitoring widgets";
};
enableClipboard = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use the clipboard widget";
};
enableVPN = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to use the VPN widget";
};
enableBrightnessControl = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have brightness/backlight support";
};
enableNightMode = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have night mode support";
};
enableDynamicTheming = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have dynamic theming support";
};
enableAudioWavelength = lib.mkOption {
type = bool;
default = true;
description = "Add needed dependencies to have audio waveleng support";
};
enableCalendarEvents = lib.mkOption {
type = bool;
default = true;
description = "Add calendar events support via khal";
};
quickshell = {
package = lib.mkPackageOption pkgs "quickshell" {};
};
};
config = lib.mkIf cfg.enable
{
programs.quickshell = {
enable = true;
package = cfg.quickshell.package;
configs.dms = "${
dmsPkgs.dankMaterialShell
}/etc/xdg/quickshell/DankMaterialShell";
activeConfig = lib.mkIf cfg.enableSystemd "dms";
systemd = lib.mkIf cfg.enableSystemd {
enable = true;
target = "graphical-session.target";
};
};
home.packages =
[
pkgs.material-symbols
pkgs.inter
pkgs.fira-code
pkgs.ddcutil
pkgs.libsForQt5.qt5ct
pkgs.kdePackages.qt6ct
dmsPkgs.dmsCli
]
++ lib.optional cfg.enableSystemMonitoring dmsPkgs.dgop
++ lib.optionals cfg.enableClipboard [pkgs.cliphist pkgs.wl-clipboard]
++ lib.optionals cfg.enableVPN [pkgs.glib pkgs.networkmanager]
++ lib.optional cfg.enableBrightnessControl pkgs.brightnessctl
++ lib.optional cfg.enableNightMode pkgs.gammastep
++ lib.optional cfg.enableDynamicTheming pkgs.matugen
++ lib.optional cfg.enableAudioWavelength pkgs.cava
++ lib.optional cfg.enableCalendarEvents pkgs.khal;
};
}

101
nix/niri.nix Normal file
View File

@@ -0,0 +1,101 @@
{
config,
lib,
...
}: let
cfg = config.programs.dankMaterialShell;
in {
options.programs.dankMaterialShell = {
niri = {
enableKeybinds = lib.mkEnableOption "DankMaterialShell niri keybinds";
enableSpawn = lib.mkEnableOption "DankMaterialShell niri spawn-at-startup";
};
};
config = lib.mkIf cfg.enable {
programs.niri.settings = lib.mkMerge [
(lib.mkIf cfg.niri.enableKeybinds {
binds = with config.lib.niri.actions; let
dms-ipc = spawn "dms" "ipc";
in
{
"Mod+Space" = {
action = dms-ipc "spotlight" "toggle";
hotkey-overlay.title = "Toggle Application Launcher";
};
"Mod+N" = {
action = dms-ipc "notifications" "toggle";
hotkey-overlay.title = "Toggle Notification Center";
};
"Mod+Comma" = {
action = dms-ipc "settings" "toggle";
hotkey-overlay.title = "Toggle Settings";
};
"Mod+P" = {
action = dms-ipc "notepad" "toggle";
hotkey-overlay.title = "Toggle Notepad";
};
"Super+Alt+L" = {
action = dms-ipc "lock" "lock";
hotkey-overlay.title = "Toggle Lock Screen";
};
"Mod+X" = {
action = dms-ipc "powermenu" "toggle";
hotkey-overlay.title = "Toggle Power Menu";
};
"XF86AudioRaiseVolume" = {
allow-when-locked = true;
action = dms-ipc "audio" "increment" "3";
};
"XF86AudioLowerVolume" = {
allow-when-locked = true;
action = dms-ipc "audio" "decrement" "3";
};
"XF86AudioMute" = {
allow-when-locked = true;
action = dms-ipc "audio" "mute";
};
"XF86AudioMicMute" = {
allow-when-locked = true;
action = dms-ipc "audio" "micmute";
};
}
// lib.attrsets.optionalAttrs cfg.enableSystemMonitoring {
"Mod+M" = {
action = dms-ipc "processlist" "toggle";
hotkey-overlay.title = "Toggle Process List";
};
}
// lib.attrsets.optionalAttrs cfg.enableClipboard {
"Mod+V" = {
action = dms-ipc "clipboard" "toggle";
hotkey-overlay.title = "Toggle Clipboard Manager";
};
}
// lib.attrsets.optionalAttrs cfg.enableBrightnessControl {
"XF86MonBrightnessUp" = {
allow-when-locked = true;
action = dms-ipc "brightness" "increment" "5" "";
};
"XF86MonBrightnessDown" = {
allow-when-locked = true;
action = dms-ipc "brightness" "decrement" "5" "";
};
}
// lib.attrsets.optionalAttrs cfg.enableNightMode {
"Mod+Alt+N" = {
allow-when-locked = true;
action = dms-ipc "night" "toggle";
hotkey-overlay.title = "Toggle Night Mode";
};
};
})
(lib.mkIf cfg.niri.enableSpawn {
spawn-at-startup = [
{command = ["dms" "run"];}
];
})
];
};
}