aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--custom.nix30
-rw-r--r--gui/pkgs/tasker.nix25
-rw-r--r--tasks/default.nix19
3 files changed, 47 insertions, 27 deletions
diff --git a/custom.nix b/custom.nix
index acc8f0e..4928f2a 100644
--- a/custom.nix
+++ b/custom.nix
@@ -1,14 +1,34 @@
{ pkgs, ... }:
-{
+let
+ mkOption = pkgs.lib.mkOption;
+ types = pkgs.lib.types;
+in {
options.custom = {
- hidpi = pkgs.lib.mkOption {
- type = pkgs.lib.types.bool;
+ hidpi = mkOption {
+ type = types.bool;
description = "Configure UI for high DPI displays";
};
- tasks = pkgs.lib.mkOption {
- type = pkgs.lib.types.attrs;
+ tasks = mkOption {
+ type = types.attrsOf (types.submodule {
+ options = {
+ description = mkOption {
+ type = types.uniq types.string;
+ };
+ directory = mkOption {
+ type = types.str;
+ default = "~/";
+ };
+ type = mkOption {
+ type = types.enum [ "launcher" "terminal" ];
+ default = "launcher";
+ };
+ command = mkOption {
+ type = types.str;
+ };
+ };
+ });
};
};
}
diff --git a/gui/pkgs/tasker.nix b/gui/pkgs/tasker.nix
index b3cf61b..bc87ee9 100644
--- a/gui/pkgs/tasker.nix
+++ b/gui/pkgs/tasker.nix
@@ -1,19 +1,22 @@
{ pkgs, tasks, ... }:
-pkgs.lib.mapAttrsToList (name: value: let
+pkgs.lib.mapAttrsToList (name: conf: let
command = pkgs.writeTextFile {
name = "tasker_cmd_" + name;
executable = true;
destination = "/bin/tasker_cmd_" + name;
- text = if value.terminal then ''
- #!/bin/sh
- exec ${pkgs.kitty}/bin/kitty -d ${value.directory} ${value.command}
- '' else ''
- #!/bin/sh
- pushd ${value.directory}
- exec ${value.command}
- popd
- '';
+ text = pkgs.lib.attrByPath [ conf.type ] "" {
+ terminal = ''
+ #!/bin/sh
+ exec ${pkgs.kitty}/bin/kitty -d ${conf.directory} ${conf.command}
+ '';
+ launcher = ''
+ #!/bin/sh
+ pushd ${conf.directory}
+ exec ${conf.command}
+ popd
+ '';
+ };
};
shortcut = pkgs.writeTextFile {
name = "tasker_shortcut_" + name;
@@ -22,7 +25,7 @@ pkgs.lib.mapAttrsToList (name: value: let
text = ''
[Desktop Entry]
Type=Application
- Name=${value.description}
+ Name=${conf.description}
GenericName=Tasker
Exec=${command}/bin/tasker_cmd_${name}
Terminal=false
diff --git a/tasks/default.nix b/tasks/default.nix
index 9fbee61..e851c24 100644
--- a/tasks/default.nix
+++ b/tasks/default.nix
@@ -1,35 +1,32 @@
-{ ... }:
+{ pkgs ? import <nixpkgs> { }, ... }:
{
custom.tasks = {
- "bsc_edit" = {
+ bsc_edit = {
description = "Grid refinement BSc thesis editor";
directory = "~/university/documents/bachelor/arbeit";
- terminal = false;
command = "nix-shell --run 'nvim-qt --no-ext-tabline'";
};
- "bsc_shell" = {
+ bsc_shell = {
description = "Grid refinement BSc thesis shell";
+ type = "terminal";
directory = "~/university/documents/bachelor/arbeit";
- terminal = true;
command = "nix-shell --command fish";
};
- "bsc_view" = {
+ bsc_view = {
description = "Grid refinement BSc thesis PDF";
directory = "~/university/documents/bachelor/arbeit";
- terminal = false;
command = "evince build/main.pdf";
};
- "olb_edit" = {
+ olb_edit = {
description = "OpenLB editor";
directory = "~/projects/contrib/openlb";
- terminal = false;
command = "nix-shell --run 'nvim-qt --no-ext-tabline'";
};
- "olb_shell" = {
+ olb_shell = {
description = "OpenLB shell";
+ type = "terminal";
directory = "~/projects/contrib/openlb";
- terminal = true;
command = "nix-shell --command fish";
};
};