mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #1498 from bokicoder/main
refactor(nix): improve and cleanup
This commit is contained in:
+59
-72
@@ -179,82 +179,69 @@ in
|
||||
or filepath, to be written to ~/.config/noctalia/plugins/plugin-name/settings.json.
|
||||
'';
|
||||
};
|
||||
|
||||
app2unit.package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.app2unit;
|
||||
description = ''
|
||||
The app2unit package to use when appLauncher.useApp2Unit is enabled.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
systemd.user.services.noctalia-shell = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description = "Noctalia Shell - Wayland desktop shell";
|
||||
Documentation = "https://docs.noctalia.dev/docs";
|
||||
PartOf = [ config.wayland.systemd.target ];
|
||||
After = [ config.wayland.systemd.target ];
|
||||
X-Restart-Triggers =
|
||||
lib.optional (cfg.settings != { }) config.xdg.configFile."noctalia/settings.json".source
|
||||
++ lib.optional (cfg.colors != { }) config.xdg.configFile."noctalia/colors.json".source
|
||||
++ lib.optional (cfg.plugins != { }) config.xdg.configFile."noctalia/plugins.json".source
|
||||
++ lib.optional (
|
||||
cfg.user-templates != { }
|
||||
) config.xdg.configFile."noctalia/user-templates.toml".source
|
||||
++ lib.mapAttrsToList (
|
||||
name: value: config.xdg.configFile."noctalia/plugins/${name}/settings.json".source
|
||||
) cfg.pluginSettings;
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ config.wayland.systemd.target ];
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.user.services.noctalia-shell = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description = "Noctalia Shell - Wayland desktop shell";
|
||||
Documentation = "https://docs.noctalia.dev";
|
||||
PartOf = [ config.wayland.systemd.target ];
|
||||
After = [ config.wayland.systemd.target ];
|
||||
X-Restart-Triggers =
|
||||
lib.optional (cfg.settings != { }) config.xdg.configFile."noctalia/settings.json".source
|
||||
++ lib.optional (cfg.colors != { }) config.xdg.configFile."noctalia/colors.json".source
|
||||
++ lib.optional (cfg.plugins != { }) config.xdg.configFile."noctalia/plugins.json".source
|
||||
++ lib.optional (
|
||||
cfg.user-templates != { }
|
||||
) config.xdg.configFile."noctalia/user-templates.toml".source
|
||||
++ lib.mapAttrsToList (
|
||||
name: value: config.xdg.configFile."noctalia/plugins/${name}/settings.json".source
|
||||
) cfg.pluginSettings;
|
||||
};
|
||||
|
||||
home.packages =
|
||||
lib.optional useApp2Unit cfg.app2unit.package ++ lib.optional (cfg.package != null) cfg.package;
|
||||
Service = {
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
xdg.configFile = {
|
||||
"noctalia/settings.json" = lib.mkIf (cfg.settings != { }) {
|
||||
source = generateJson "settings" cfg.settings;
|
||||
};
|
||||
"noctalia/colors.json" = lib.mkIf (cfg.colors != { }) {
|
||||
source = generateJson "colors" cfg.colors;
|
||||
};
|
||||
"noctalia/plugins.json" = lib.mkIf (cfg.plugins != { }) {
|
||||
source = generateJson "plugins" cfg.plugins;
|
||||
};
|
||||
"noctalia/user-templates.toml" = lib.mkIf (cfg.user-templates != { }) {
|
||||
source =
|
||||
if lib.isString cfg.user-templates then
|
||||
pkgs.writeText "noctalia-user-templates.toml" cfg.user-templates
|
||||
else if builtins.isPath cfg.user-templates || lib.isStorePath cfg.user-templates then
|
||||
cfg.user-templates
|
||||
else
|
||||
tomlFormat.generate "noctalia-user-templates.toml" cfg.user-templates;
|
||||
};
|
||||
}
|
||||
// lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "noctalia/plugins/${name}/settings.json" {
|
||||
source = generateJson "${name}-settings" value;
|
||||
}
|
||||
) cfg.pluginSettings;
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !cfg.systemd.enable || cfg.package != null;
|
||||
message = "noctalia-shell: The package option must not be null when systemd service is enabled.";
|
||||
}
|
||||
];
|
||||
Install.WantedBy = [ config.wayland.systemd.target ];
|
||||
};
|
||||
|
||||
home.packages = lib.optional (cfg.package != null) cfg.package;
|
||||
|
||||
xdg.configFile = {
|
||||
"noctalia/settings.json" = lib.mkIf (cfg.settings != { }) {
|
||||
source = generateJson "settings" cfg.settings;
|
||||
};
|
||||
"noctalia/colors.json" = lib.mkIf (cfg.colors != { }) {
|
||||
source = generateJson "colors" cfg.colors;
|
||||
};
|
||||
"noctalia/plugins.json" = lib.mkIf (cfg.plugins != { }) {
|
||||
source = generateJson "plugins" cfg.plugins;
|
||||
};
|
||||
"noctalia/user-templates.toml" = lib.mkIf (cfg.user-templates != { }) {
|
||||
source =
|
||||
if lib.isString cfg.user-templates then
|
||||
pkgs.writeText "noctalia-user-templates.toml" cfg.user-templates
|
||||
else if builtins.isPath cfg.user-templates || lib.isStorePath cfg.user-templates then
|
||||
cfg.user-templates
|
||||
else
|
||||
tomlFormat.generate "noctalia-user-templates.toml" cfg.user-templates;
|
||||
};
|
||||
}
|
||||
// lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "noctalia/plugins/${name}/settings.json" {
|
||||
source = generateJson "${name}-settings" value;
|
||||
}
|
||||
) cfg.pluginSettings;
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !cfg.systemd.enable || cfg.package != null;
|
||||
message = "noctalia-shell: The package option must not be null when systemd service is enabled.";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ in
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.user.services.noctalia-shell = {
|
||||
description = "Noctalia Shell - Wayland desktop shell";
|
||||
documentation = [ "https://docs.noctalia.dev/docs" ];
|
||||
documentation = [ "https://docs.noctalia.dev" ];
|
||||
after = [ cfg.target ];
|
||||
partOf = [ cfg.target ];
|
||||
wantedBy = [ cfg.target ];
|
||||
|
||||
+14
-13
@@ -1,6 +1,19 @@
|
||||
{
|
||||
version ? "dirty",
|
||||
pamConfig ? "login",
|
||||
extraPackages ? [ ],
|
||||
runtimeDeps ? [
|
||||
brightnessctl
|
||||
cava
|
||||
cliphist
|
||||
ddcutil
|
||||
wlsunset
|
||||
wl-clipboard
|
||||
imagemagick
|
||||
wget
|
||||
(python3.withPackages (pp: lib.optional calendarSupport pp.pygobject3))
|
||||
],
|
||||
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
# build
|
||||
@@ -47,18 +60,6 @@ let
|
||||
]);
|
||||
};
|
||||
|
||||
runtimeDeps = [
|
||||
brightnessctl
|
||||
cava
|
||||
cliphist
|
||||
ddcutil
|
||||
wlsunset
|
||||
wl-clipboard
|
||||
imagemagick
|
||||
wget
|
||||
(python3.withPackages (pp: lib.optional calendarSupport pp.pygobject3))
|
||||
];
|
||||
|
||||
giTypelibPath = lib.makeSearchPath "lib/girepository-1.0" [
|
||||
evolution-data-server
|
||||
libical
|
||||
@@ -90,7 +91,7 @@ stdenvNoCC.mkDerivation {
|
||||
preFixup = ''
|
||||
qtWrapperArgs+=(
|
||||
--set NOCTALIA_PAM_CONFIG ${pamConfig}
|
||||
--prefix PATH : ${lib.makeBinPath runtimeDeps}
|
||||
--prefix PATH : ${lib.makeBinPath (runtimeDeps ++ extraPackages)}
|
||||
--add-flags "-p $out/share/noctalia-shell"
|
||||
${lib.optionalString calendarSupport "--prefix GI_TYPELIB_PATH : ${giTypelibPath}"}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user