nix/nix/modules/home/autostart/default.nix
Ameya Shenoy 2b3213c3f8 feat: init
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2024-11-11 01:52:48 +05:30

32 lines
1.2 KiB
Nix

{ config, lib, ... }:
{
options.snowflake.home.autostart = {
enable = lib.mkEnableOption "enable autostart module";
pkgs = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = "packages to autostart";
};
};
config = lib.mkIf config.snowflake.home.autostart.enable {
home.file = builtins.listToAttrs (map (pkg: {
name = ".config/autostart/" + pkg.pname + ".desktop";
value = if pkg ? desktopItem then {
# Application has a desktopItem entry.
# Assume that it was made with makeDesktopEntry, which exposes a
# text attribute with the contents of the .desktop file
text = pkg.desktopItem.text;
} else if pkg.pname == "wezterm" then {
# custom handling for wezterm since for its desktop file
source = (pkg + "/share/applications/" + "org.wezfurlong.wezterm"
+ ".desktop");
} else {
# Application does *not* have a desktopItem entry. Try to find a
# matching .desktop name in /share/apaplications
source = (pkg + "/share/applications/" + pkg.pname + ".desktop");
};
}) config.snowflake.home.autostart.pkgs);
};
}