From 45228e6dea9c4c43b2d75abed9c34ec074f309b4 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 22 Apr 2025 10:52:15 +0800 Subject: [PATCH] nixos/xdg/autostart-entries: init --- modules/nixos/default.nix | 1 + modules/nixos/xdg/autostart-entries.nix | 40 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 modules/nixos/xdg/autostart-entries.nix diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 6bf4f54e..758144eb 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -15,6 +15,7 @@ ./services/wezterm-mux-server.nix ./services/vouch-proxy.nix ./services/yt-dlp.nix + ./xdg/autostart-entries.nix ./xdg/mime-desktop-specific.nix ./virtualisation/oci-containers ]; diff --git a/modules/nixos/xdg/autostart-entries.nix b/modules/nixos/xdg/autostart-entries.nix new file mode 100644 index 00000000..2cb69e8a --- /dev/null +++ b/modules/nixos/xdg/autostart-entries.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.xdg.autostart; + + xdgDesktopEntrySubmodule = { name, ... }: { + freeformType = with lib.types; attrsOf anything; + }; +in +{ + options.xdg.autostart.entries = lib.mkOption { + type = with lib.types; attrsOf (submodule xdgDesktopEntrySubmodule); + default = { }; + description = '' + A set of XDG autostart entries to be exported to the environment. + ''; + example = lib.literalExpression '' + { + kando = { + name = "kando"; + desktopName = "Kando"; + exec = lib.getExe pkgs.kando; + icon = "kando"; + genericName = "Pie Menu"; + }; + } + ''; + }; + + config = lib.mkIf (cfg.entries != { }) { + environment.systemPackages = + let + mkXDGAutostartFile = _: v: + pkgs.makeDesktopItem (v // { + destination = "/etc/xdg/autostart"; + }); + in + lib.mapAttrsToList mkXDGAutostartFile cfg.entries; + }; +}