1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05: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,
dmsPkgs,
...
}: let
}:
let
cfg = config.programs.dankMaterialShell;
in {
in
{
qmlPath = "${dmsPkgs.dms-shell}/share/quickshell/dms";
packages =
[
packages = [
pkgs.material-symbols
pkgs.inter
pkgs.fira-code
@@ -22,8 +23,14 @@ in {
dmsPkgs.dms-shell
]
++ lib.optional cfg.enableSystemMonitoring dmsPkgs.dgop
++ lib.optionals cfg.enableClipboard [pkgs.cliphist pkgs.wl-clipboard]
++ lib.optionals cfg.enableVPN [pkgs.glib pkgs.networkmanager]
++ 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.enableColorPicker pkgs.hyprpicker
++ lib.optional cfg.enableDynamicTheming pkgs.matugen

View File

@@ -4,16 +4,24 @@
pkgs,
dmsPkgs,
...
}: let
}:
let
inherit (lib) types;
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";
greeterScript = pkgs.writeShellScriptBin "dms-greeter" ''
export PATH=$PATH:${lib.makeBinPath [cfg.quickshell.package config.programs.${cfg.compositor.name}.package]}
${lib.escapeShellArgs ([
export PATH=$PATH:${
lib.makeBinPath [
cfg.quickshell.package
config.programs.${cfg.compositor.name}.package
]
}
${
lib.escapeShellArgs (
[
"sh"
"${../../quickshell/Modules/Greetd/assets/dms-greeter}"
"--cache-dir"
@@ -26,19 +34,36 @@
++ lib.optionals (cfg.compositor.customConfig != "") [
"-C"
"${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;
in {
imports = let
in
{
imports =
let
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 = {
enable = lib.mkEnableOption "DankMaterialShell greeter";
compositor.name = lib.mkOption {
type = types.enum ["niri" "hyprland" "sway" "scroll"];
type = types.enum [
"niri"
"hyprland"
"sway"
];
description = "Compositor to run greeter in";
};
compositor.customConfig = lib.mkOption {
@@ -48,7 +73,7 @@ in {
};
configFiles = lib.mkOption {
type = types.listOf types.path;
default = [];
default = [ ];
description = "Config files to copy into data directory";
example = [
"/home/user/.config/DankMaterialShell/settings.json"
@@ -80,7 +105,7 @@ in {
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = (config.users.users.${user} or {}) != {};
assertion = (config.users.users.${user} or { }) != { };
message = ''
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" = {
${cacheDir}.d = {
user = user;
inherit user;
group =
if config.users.users.${user}.group != ""
then config.users.users.${user}.group
else "greeter";
if config.users.users.${user}.group != "" then config.users.users.${user}.group else "greeter";
mode = "0750";
};
};
systemd.services.greetd.preStart = ''
cd ${cacheDir}
${lib.concatStringsSep "\n" (lib.map (f: ''
${lib.concatStringsSep "\n" (
lib.map (f: ''
if [ -f "${f}" ]; then
cp "${f}" .
fi
'')
cfg.configFiles)}
'') cfg.configFiles
)}
if [ -f session.json ]; then
if cp "$(${jq} -r '.wallpaperPath' session.json)" wallpaper.jpg; then

View File

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

View File

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

View File

@@ -4,25 +4,33 @@
lib,
dmsPkgs,
...
} @ args: let
}@args:
let
cfg = config.programs.dankMaterialShell;
common = import ./common.nix {inherit config pkgs lib dmsPkgs;};
in {
common = import ./common.nix {
inherit
config
pkgs
lib
dmsPkgs
;
};
in
{
imports = [
(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";
systemd.user.services.dms = lib.mkIf cfg.systemd.enable {
description = "DankMaterialShell";
path = lib.mkForce [];
path = lib.mkForce [ ];
partOf = ["graphical-session.target"];
after = ["graphical-session.target"];
wantedBy = ["graphical-session.target"];
partOf = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
restartTriggers = lib.optional cfg.systemd.restartIfChanged common.qmlPath;
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,
dmsPkgs,
...
}: let
}:
let
inherit (lib) types;
in {
in
{
options.programs.dankMaterialShell = {
enable = lib.mkEnableOption "DankMaterialShell";

View File

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