hjem/collection: add autostart module
This commit is contained in:
parent
2719bbada1
commit
6129318685
1 changed files with 45 additions and 0 deletions
45
shared/modules/hjem/collection/autostart.nix
Normal file
45
shared/modules/hjem/collection/autostart.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkOption;
|
||||||
|
inherit (lib.types) listOf package;
|
||||||
|
cfg = config.autostart;
|
||||||
|
|
||||||
|
# stolen from https://github.com/nix-community/home-manager/issues/3447#issuecomment-1328294558
|
||||||
|
mkAutostartEntries = 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
|
||||||
|
inherit (pkg.desktopItem) text;
|
||||||
|
}
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
cfg.programs);
|
||||||
|
in {
|
||||||
|
options.autostart = {
|
||||||
|
programs = mkOption {
|
||||||
|
type = listOf package;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
A list of packages that will be started automatically,
|
||||||
|
according to the Desktop Application Autostart
|
||||||
|
Specification.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf (cfg.programs != []) {
|
||||||
|
files = mkAutostartEntries;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue