-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
107 lines (101 loc) · 3.32 KB
/
flake.nix
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
description = "Run a command and wait for a sway/i3 window to appear";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachSystem
[
"x86_64-linux"
"aarch64-linux"
]
(system: {
packages.default = nixpkgs.legacyPackages.${system}.callPackage ./build.nix { };
})
// {
overlays.default = _final: prev: { sway-toolwait = prev.callPackage ./build.nix { }; };
homeManagerModules.default =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.sway;
mkToolwait =
{
command,
workspace,
waitFor,
timeout,
}:
''
${pkgs.sway-toolwait}/bin/sway-toolwait \
--workspace ${builtins.toString workspace} \
--command "${command}" \
--timeout ${builtins.toString timeout} \
${lib.optionalString (waitFor != "") "--waitfor ${waitFor}"}
'';
toolwaitScript = pkgs.writeShellScript "sway-toolwait" ''
${builtins.concatStringsSep "\n" (map mkToolwait cfg.toolwait)}
'';
in
{
options.wayland.windowManager.sway.toolwait = lib.mkOption {
type =
with lib.types;
listOf (submodule {
options = {
command = lib.mkOption {
type = lib.types.nonEmptyStr;
description = "Command to run.";
};
workspace = lib.mkOption {
type = lib.types.ints.unsigned;
description = "Workspace number on which to run the command.";
};
waitFor = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
app_id (wayland) or instance string (xwayland) to wait for.
Defaults to the attribute name.
'';
};
timeout = lib.mkOption {
type = lib.types.ints.unsigned;
default = 5;
description = "Maximum seconds to wait for a matching new windoe";
};
};
});
default = [ ];
example = lib.literalExpression ''
[
{
command = "''${pkgs.firefox}/bin/firefox";
workspace = 1;
waitFor = "firefox";
}
{
command = "''${pkgs.keepassxc}/bin/keepassxc";
workspace = 9;
waitFor = "org.keepassxc.KeePassXC";
}
]
'';
description = ''
Applications that should be launched synchronously on specific workspaces at startup.
'';
};
config.wayland.windowManager.sway.extraConfig = lib.mkIf (cfg.toolwait != { }) (
lib.mkAfter ''
exec ${toolwaitScript}
''
);
};
};
}