aboutsummaryrefslogtreecommitdiff
path: root/module/tasker.nix
blob: 8b51d9462efebda5562c0ff04c3e83b4d3458d50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ pkgs, config, ... }:

let
  taskivations = pkgs.lib.mapAttrsToList (name: conf: let
    command = pkgs.writeTextFile {
      name        = "tasker_cmd_" + name;
      executable  = true;
      destination = "/bin/tasker_cmd_" + name;
      text = pkgs.lib.attrByPath [ conf.type ] "" {
        launcher = ''
          #!/bin/sh
          pushd ${conf.directory}
            exec ${conf.command}
          popd
        '';
        terminal = ''
          #!/bin/sh
          exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} ${conf.command}
        '';
        local-shell = ''
          #!/bin/sh
          exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} nix-shell --command fish
        '';
        local-editor = ''
          #!/bin/sh
          pushd ${conf.directory}
            exec nix-shell --run 'nvim-qt --no-ext-tabline'
          popd
        '';
        environment = ''
          #!/bin/sh
          exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} nix-shell \
               ${builtins.unsafeDiscardStringContext conf.environment.drvPath} --command fish
        '';
      };
    };

    shortcut = pkgs.writeTextFile {
      name        = "tasker_shortcut_" + name;
      executable  = false;
      destination = "/share/applications/tasker_shortcut_" + name + ".desktop";
      text = ''
        [Desktop Entry]
        Type=Application
        Name=${conf.description}
        GenericName=Tasker
        Exec=${command}/bin/tasker_cmd_${name}
        Terminal=false
      '';
    };

  in pkgs.symlinkJoin {
    name = "tasker_task_" + name;
    paths = [ shortcut ];
  }) config.custom.tasks;

in {
  home.packages = taskivations;
}