1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/misc/xdg-autostart.nix

60 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
literalExpression
mkEnableOption
mkIf
mkOption
types
;
cfg = config.xdg.autostart;
linkedDesktopEntries = pkgs.runCommandLocal "xdg-autostart-entries" { } ''
mkdir -p $out
${lib.concatMapStringsSep "\n" (e: "ln -s ${e} $out") cfg.entries}
'';
in
{
meta.maintainers = with lib.maintainers; [ Scrumplex ];
options.xdg.autostart = {
enable = mkEnableOption "creation of XDG autostart entries";
readOnly = mkOption {
type = lib.types.bool;
description = ''
Make `XDG_CONFIG_HOME/autostart` a symlink to a readonly directory so that
programs cannot install arbitrary autostart services.
'';
default = false;
example = true;
};
entries = mkOption {
type = with types; listOf path;
description = ''
Paths to desktop files that should be linked to `XDG_CONFIG_HOME/autostart`
'';
default = [ ];
example = literalExpression ''
[
"''${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop"
]
'';
};
};
config = mkIf (cfg.enable && cfg.entries != [ ]) {
xdg.configFile.autostart = {
source = linkedDesktopEntries;
recursive = !cfg.readOnly;
};
};
}