1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-14 17:52:10 -04:00

nix: switch to standard nixpkgs rfc formatting (#962)

This commit is contained in:
Marcus Ramberg
2025-12-10 08:55:45 +01:00
committed by GitHub
parent 8615950bd6
commit 98769ecd88
8 changed files with 664 additions and 580 deletions

View File

@@ -1 +0,0 @@
indentation = "FourSpaces"

View File

@@ -4,13 +4,14 @@
pkgs, pkgs,
dmsPkgs, dmsPkgs,
... ...
}: let }:
let
cfg = config.programs.dankMaterialShell; cfg = config.programs.dankMaterialShell;
in { in
{
qmlPath = "${dmsPkgs.dms-shell}/share/quickshell/dms"; qmlPath = "${dmsPkgs.dms-shell}/share/quickshell/dms";
packages = packages = [
[
pkgs.material-symbols pkgs.material-symbols
pkgs.inter pkgs.inter
pkgs.fira-code pkgs.fira-code
@@ -22,8 +23,14 @@ in {
dmsPkgs.dms-shell dmsPkgs.dms-shell
] ]
++ lib.optional cfg.enableSystemMonitoring dmsPkgs.dgop ++ lib.optional cfg.enableSystemMonitoring dmsPkgs.dgop
++ lib.optionals cfg.enableClipboard [pkgs.cliphist pkgs.wl-clipboard] ++ lib.optionals cfg.enableClipboard [
++ lib.optionals cfg.enableVPN [pkgs.glib pkgs.networkmanager] pkgs.cliphist
pkgs.wl-clipboard
]
++ lib.optionals cfg.enableVPN [
pkgs.glib
pkgs.networkmanager
]
++ lib.optional cfg.enableBrightnessControl pkgs.brightnessctl ++ lib.optional cfg.enableBrightnessControl pkgs.brightnessctl
++ lib.optional cfg.enableColorPicker pkgs.hyprpicker ++ lib.optional cfg.enableColorPicker pkgs.hyprpicker
++ lib.optional cfg.enableDynamicTheming pkgs.matugen ++ lib.optional cfg.enableDynamicTheming pkgs.matugen

View File

@@ -4,16 +4,24 @@
pkgs, pkgs,
dmsPkgs, dmsPkgs,
... ...
}: let }:
let
inherit (lib) types; inherit (lib) types;
cfg = config.programs.dankMaterialShell.greeter; cfg = config.programs.dankMaterialShell.greeter;
user = config.services.greetd.settings.default_session.user; inherit (config.services.greetd.settings.default_session) user;
cacheDir = "/var/lib/dms-greeter"; cacheDir = "/var/lib/dms-greeter";
greeterScript = pkgs.writeShellScriptBin "dms-greeter" '' greeterScript = pkgs.writeShellScriptBin "dms-greeter" ''
export PATH=$PATH:${lib.makeBinPath [cfg.quickshell.package config.programs.${cfg.compositor.name}.package]} export PATH=$PATH:${
${lib.escapeShellArgs ([ lib.makeBinPath [
cfg.quickshell.package
config.programs.${cfg.compositor.name}.package
]
}
${
lib.escapeShellArgs (
[
"sh" "sh"
"${../../quickshell/Modules/Greetd/assets/dms-greeter}" "${../../quickshell/Modules/Greetd/assets/dms-greeter}"
"--cache-dir" "--cache-dir"
@@ -26,19 +34,36 @@
++ lib.optionals (cfg.compositor.customConfig != "") [ ++ lib.optionals (cfg.compositor.customConfig != "") [
"-C" "-C"
"${pkgs.writeText "dmsgreeter-compositor-config" cfg.compositor.customConfig}" "${pkgs.writeText "dmsgreeter-compositor-config" cfg.compositor.customConfig}"
])} ${lib.optionalString cfg.logs.save "> ${cfg.logs.path} 2>&1"} ]
)
} ${lib.optionalString cfg.logs.save "> ${cfg.logs.path} 2>&1"}
''; '';
jq = lib.getExe pkgs.jq; jq = lib.getExe pkgs.jq;
in { in
imports = let {
imports =
let
msg = "The option 'programs.dankMaterialShell.greeter.compositor.extraConfig' is deprecated. Please use 'programs.dankMaterialShell.greeter.compositor.customConfig' instead."; msg = "The option 'programs.dankMaterialShell.greeter.compositor.extraConfig' is deprecated. Please use 'programs.dankMaterialShell.greeter.compositor.customConfig' instead.";
in [(lib.mkRemovedOptionModule ["programs" "dankMaterialShell" "greeter" "compositor" "extraConfig"] msg)]; in
[
(lib.mkRemovedOptionModule [
"programs"
"dankMaterialShell"
"greeter"
"compositor"
"extraConfig"
] msg)
];
options.programs.dankMaterialShell.greeter = { options.programs.dankMaterialShell.greeter = {
enable = lib.mkEnableOption "DankMaterialShell greeter"; enable = lib.mkEnableOption "DankMaterialShell greeter";
compositor.name = lib.mkOption { compositor.name = lib.mkOption {
type = types.enum ["niri" "hyprland" "sway" "scroll"]; type = types.enum [
"niri"
"hyprland"
"sway"
];
description = "Compositor to run greeter in"; description = "Compositor to run greeter in";
}; };
compositor.customConfig = lib.mkOption { compositor.customConfig = lib.mkOption {
@@ -48,7 +73,7 @@ in {
}; };
configFiles = lib.mkOption { configFiles = lib.mkOption {
type = types.listOf types.path; type = types.listOf types.path;
default = []; default = [ ];
description = "Config files to copy into data directory"; description = "Config files to copy into data directory";
example = [ example = [
"/home/user/.config/DankMaterialShell/settings.json" "/home/user/.config/DankMaterialShell/settings.json"
@@ -80,7 +105,7 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = (config.users.users.${user} or {}) != {}; assertion = (config.users.users.${user} or { }) != { };
message = '' message = ''
dmsgreeter: user set for greetd default_session ${user} does not exist. Please create it before referencing it. dmsgreeter: user set for greetd default_session ${user} does not exist. Please create it before referencing it.
''; '';
@@ -97,22 +122,21 @@ in {
]; ];
systemd.tmpfiles.settings."10-dmsgreeter" = { systemd.tmpfiles.settings."10-dmsgreeter" = {
${cacheDir}.d = { ${cacheDir}.d = {
user = user; inherit user;
group = group =
if config.users.users.${user}.group != "" if config.users.users.${user}.group != "" then config.users.users.${user}.group else "greeter";
then config.users.users.${user}.group
else "greeter";
mode = "0750"; mode = "0750";
}; };
}; };
systemd.services.greetd.preStart = '' systemd.services.greetd.preStart = ''
cd ${cacheDir} cd ${cacheDir}
${lib.concatStringsSep "\n" (lib.map (f: '' ${lib.concatStringsSep "\n" (
lib.map (f: ''
if [ -f "${f}" ]; then if [ -f "${f}" ]; then
cp "${f}" . cp "${f}" .
fi fi
'') '') cfg.configFiles
cfg.configFiles)} )}
if [ -f session.json ]; then if [ -f session.json ]; then
if cp "$(${jq} -r '.wallpaperPath' session.json)" wallpaper.jpg; then if cp "$(${jq} -r '.wallpaperPath' session.json)" wallpaper.jpg; then

View File

@@ -4,33 +4,52 @@
lib, lib,
dmsPkgs, dmsPkgs,
... ...
} @ args: let }@args:
let
cfg = config.programs.dankMaterialShell; cfg = config.programs.dankMaterialShell;
jsonFormat = pkgs.formats.json {}; jsonFormat = pkgs.formats.json { };
common = import ./common.nix {inherit config pkgs lib dmsPkgs;}; common = import ./common.nix {
in { inherit
config
pkgs
lib
dmsPkgs
;
};
in
{
imports = [ imports = [
(import ./options.nix args) (import ./options.nix args)
(lib.mkRemovedOptionModule ["programs" "dankMaterialShell" "enableNightMode"] "Night mode is now always available.") (lib.mkRemovedOptionModule [
(lib.mkRenamedOptionModule ["programs" "dankMaterialShell" "enableSystemd"] ["programs" "dankMaterialShell" "systemd" "enable"]) "programs"
"dankMaterialShell"
"enableNightMode"
] "Night mode is now always available.")
(lib.mkRenamedOptionModule
[ "programs" "dankMaterialShell" "enableSystemd" ]
[ "programs" "dankMaterialShell" "systemd" "enable" ]
)
]; ];
options.programs.dankMaterialShell = with lib.types; { options.programs.dankMaterialShell = with lib.types; {
default = { default = {
settings = lib.mkOption { settings = lib.mkOption {
type = jsonFormat.type; type = jsonFormat.type;
default = {}; default = { };
description = "The default settings are only read if the settings.json file don't exist"; description = "The default settings are only read if the settings.json file don't exist";
}; };
session = lib.mkOption { session = lib.mkOption {
type = jsonFormat.type; type = jsonFormat.type;
default = {}; default = { };
description = "The default session are only read if the session.json file don't exist"; description = "The default session are only read if the session.json file don't exist";
}; };
}; };
plugins = lib.mkOption { plugins = lib.mkOption {
type = attrsOf (types.submodule ({config, ...}: { type = attrsOf (
types.submodule (
{ config, ... }:
{
options = { options = {
enable = lib.mkOption { enable = lib.mkOption {
type = types.bool; type = types.bool;
@@ -42,17 +61,18 @@ in {
description = "Source to link to DMS plugins directory"; description = "Source to link to DMS plugins directory";
}; };
}; };
})); }
default = {}; )
);
default = { };
description = "DMS Plugins to install"; description = "DMS Plugins to install";
}; };
}; };
config = lib.mkIf cfg.enable config = lib.mkIf cfg.enable {
{
programs.quickshell = { programs.quickshell = {
enable = true; enable = true;
package = cfg.quickshell.package; inherit (cfg.quickshell) package;
configs.dms = common.qmlPath; configs.dms = common.qmlPath;
}; };
@@ -60,8 +80,8 @@ in {
systemd.user.services.dms = lib.mkIf cfg.systemd.enable { systemd.user.services.dms = lib.mkIf cfg.systemd.enable {
Unit = { Unit = {
Description = "DankMaterialShell"; Description = "DankMaterialShell";
PartOf = [config.wayland.systemd.target]; PartOf = [ config.wayland.systemd.target ];
After = [config.wayland.systemd.target]; After = [ config.wayland.systemd.target ];
X-Restart-Triggers = lib.optional cfg.systemd.restartIfChanged common.qmlPath; X-Restart-Triggers = lib.optional cfg.systemd.restartIfChanged common.qmlPath;
}; };
@@ -70,10 +90,10 @@ in {
Restart = "on-failure"; Restart = "on-failure";
}; };
Install.WantedBy = [config.wayland.systemd.target]; Install.WantedBy = [ config.wayland.systemd.target ];
}; };
xdg.stateFile."DankMaterialShell/default-session.json" = lib.mkIf (cfg.default.session != {}) { xdg.stateFile."DankMaterialShell/default-session.json" = lib.mkIf (cfg.default.session != { }) {
source = jsonFormat.generate "default-session.json" cfg.default.session; source = jsonFormat.generate "default-session.json" cfg.default.session;
}; };
@@ -83,7 +103,7 @@ in {
value.source = plugin.src; value.source = plugin.src;
}) (lib.filterAttrs (n: v: v.enable) cfg.plugins)) }) (lib.filterAttrs (n: v: v.enable) cfg.plugins))
{ {
"DankMaterialShell/default-settings.json" = lib.mkIf (cfg.default.settings != {}) { "DankMaterialShell/default-settings.json" = lib.mkIf (cfg.default.settings != { }) {
source = jsonFormat.generate "default-settings.json" cfg.default.settings; source = jsonFormat.generate "default-settings.json" cfg.default.settings;
}; };
} }

View File

@@ -2,9 +2,11 @@
config, config,
lib, lib,
... ...
}: let }:
let
cfg = config.programs.dankMaterialShell; cfg = config.programs.dankMaterialShell;
in { in
{
options.programs.dankMaterialShell = { options.programs.dankMaterialShell = {
niri = { niri = {
enableKeybinds = lib.mkEnableOption "DankMaterialShell niri keybinds"; enableKeybinds = lib.mkEnableOption "DankMaterialShell niri keybinds";
@@ -15,7 +17,9 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.niri.settings = lib.mkMerge [ programs.niri.settings = lib.mkMerge [
(lib.mkIf cfg.niri.enableKeybinds { (lib.mkIf cfg.niri.enableKeybinds {
binds = with config.lib.niri.actions; let binds =
with config.lib.niri.actions;
let
dms-ipc = spawn "dms" "ipc"; dms-ipc = spawn "dms" "ipc";
in in
{ {
@@ -90,13 +94,22 @@ in {
}) })
(lib.mkIf cfg.niri.enableSpawn { (lib.mkIf cfg.niri.enableSpawn {
spawn-at-startup = spawn-at-startup = [
[ {
{command = ["dms" "run"];} command = [
"dms"
"run"
];
}
] ]
++ lib.optionals cfg.enableClipboard [ ++ lib.optionals cfg.enableClipboard [
{ {
command = ["wl-paste" "--watch" "cliphist" "store"]; command = [
"wl-paste"
"--watch"
"cliphist"
"store"
];
} }
]; ];
}) })

View File

@@ -4,25 +4,33 @@
lib, lib,
dmsPkgs, dmsPkgs,
... ...
} @ args: let }@args:
let
cfg = config.programs.dankMaterialShell; cfg = config.programs.dankMaterialShell;
common = import ./common.nix {inherit config pkgs lib dmsPkgs;}; common = import ./common.nix {
in { inherit
config
pkgs
lib
dmsPkgs
;
};
in
{
imports = [ imports = [
(import ./options.nix args) (import ./options.nix args)
]; ];
config = lib.mkIf cfg.enable config = lib.mkIf cfg.enable {
{
environment.etc."xdg/quickshell/dms".source = "${dmsPkgs.dms-shell}/share/quickshell/dms"; environment.etc."xdg/quickshell/dms".source = "${dmsPkgs.dms-shell}/share/quickshell/dms";
systemd.user.services.dms = lib.mkIf cfg.systemd.enable { systemd.user.services.dms = lib.mkIf cfg.systemd.enable {
description = "DankMaterialShell"; description = "DankMaterialShell";
path = lib.mkForce []; path = lib.mkForce [ ];
partOf = ["graphical-session.target"]; partOf = [ "graphical-session.target" ];
after = ["graphical-session.target"]; after = [ "graphical-session.target" ];
wantedBy = ["graphical-session.target"]; wantedBy = [ "graphical-session.target" ];
restartTriggers = lib.optional cfg.systemd.restartIfChanged common.qmlPath; restartTriggers = lib.optional cfg.systemd.restartIfChanged common.qmlPath;
serviceConfig = { serviceConfig = {
@@ -31,6 +39,6 @@ in {
}; };
}; };
environment.systemPackages = [cfg.quickshell.package] ++ common.packages; environment.systemPackages = [ cfg.quickshell.package ] ++ common.packages;
}; };
} }

View File

@@ -2,9 +2,11 @@
lib, lib,
dmsPkgs, dmsPkgs,
... ...
}: let }:
let
inherit (lib) types; inherit (lib) types;
in { in
{
options.programs.dankMaterialShell = { options.programs.dankMaterialShell = {
enable = lib.mkEnableOption "DankMaterialShell"; enable = lib.mkEnableOption "DankMaterialShell";

View File

@@ -13,33 +13,40 @@
}; };
}; };
outputs = { outputs =
{
self, self,
nixpkgs, nixpkgs,
dgop, dgop,
quickshell, quickshell,
... ...
}: let }:
forEachSystem = fn: let
nixpkgs.lib.genAttrs ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"] ( forEachSystem =
fn:
nixpkgs.lib.genAttrs [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ] (
system: fn system nixpkgs.legacyPackages.${system} system: fn system nixpkgs.legacyPackages.${system}
); );
buildDmsPkgs = pkgs: { buildDmsPkgs = pkgs: {
dms-shell = self.packages.${pkgs.stdenv.hostPlatform.system}.default; dms-shell = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
dgop = dgop.packages.${pkgs.stdenv.hostPlatform.system}.dgop; inherit (dgop.packages.${pkgs.stdenv.hostPlatform.system}) dgop;
quickshell = quickshell.packages.${pkgs.stdenv.hostPlatform.system}.default; quickshell = quickshell.packages.${pkgs.stdenv.hostPlatform.system}.default;
}; };
mkModuleWithDmsPkgs = path: args @ {pkgs, ...}: { mkModuleWithDmsPkgs =
path:
args@{ pkgs, ... }:
{
imports = [ imports = [
(import path (args // {dmsPkgs = buildDmsPkgs pkgs;})) (import path (args // { dmsPkgs = buildDmsPkgs pkgs; }))
]; ];
}; };
in { in
formatter = forEachSystem (_: pkgs: pkgs.alejandra); {
packages = forEachSystem ( packages = forEachSystem (
system: pkgs: let system: pkgs:
mkDate = longDate: let
mkDate =
longDate:
pkgs.lib.concatStringsSep "-" [ pkgs.lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate) (builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate) (builtins.substring 4 2 longDate)
@@ -51,17 +58,19 @@
+ mkDate (self.lastModifiedDate or "19700101") + mkDate (self.lastModifiedDate or "19700101")
+ "_" + "_"
+ (self.shortRev or "dirty"); + (self.shortRev or "dirty");
in { in
{
dms-shell = pkgs.buildGoModule ( dms-shell = pkgs.buildGoModule (
let let
rootSrc = ./.; rootSrc = ./.;
in { in
{
inherit version; inherit version;
pname = "dms-shell"; pname = "dms-shell";
src = ./core; src = ./core;
vendorHash = "sha256-2PCqiW4frxME8IlmwWH5ktznhd/G1bah5Ae4dp0HPTQ="; vendorHash = "sha256-2PCqiW4frxME8IlmwWH5ktznhd/G1bah5Ae4dp0HPTQ=";
subPackages = ["cmd/dms"]; subPackages = [ "cmd/dms" ];
ldflags = [ ldflags = [
"-s" "-s"
@@ -132,9 +141,9 @@
nixosModules.greeter = mkModuleWithDmsPkgs ./distro/nix/greeter.nix; nixosModules.greeter = mkModuleWithDmsPkgs ./distro/nix/greeter.nix;
devShells = forEachSystem ( devShells = forEachSystem (
system: pkgs: let system: pkgs:
qmlPkgs = let
[ qmlPkgs = [
quickshell.packages.${system}.default quickshell.packages.${system}.default
] ]
++ (with pkgs.kdePackages; [ ++ (with pkgs.kdePackages; [
@@ -143,9 +152,11 @@
sonnet sonnet
qtmultimedia qtmultimedia
]); ]);
in { in
{
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = with pkgs; buildInputs =
with pkgs;
[ [
go_1_24 go_1_24
gopls gopls