-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
158 lines (142 loc) · 4.93 KB
/
Copy pathflake.nix
File metadata and controls
158 lines (142 loc) · 4.93 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
description = "Glyphlow - A keyboard-driven UI navigator for macOS";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
version = "0.3.1";
systems = [ "aarch64-darwin" ];
forEachSystem = flake-utils.lib.eachSystem systems;
in
forEachSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Prebuilt binary derivation
glyphlow-bin = pkgs.stdenv.mkDerivation {
pname = "glyphlow";
inherit version;
src = pkgs.fetchurl {
url = "https://github.com/blindFS/Glyphlow/releases/download/v${version}/glyphlow.tar.gz";
hash = "sha256-LXhOGv97atBih1+5P1WJEZ8EKq1iDImu3ccL97r5mws=";
};
nativeBuildInputs = [ pkgs.installShellFiles ];
sourceRoot = ".";
installPhase = ''
install -Dm755 glyphlow $out/bin/glyphlow
'';
meta = with pkgs.lib; {
description = "A keyboard-driven UI navigator for macOS";
longDescription = ''
Glyphlow is a keyboard-driven UI navigator for macOS.
Note: You must manually grant Accessibility permissions to the glyphlow binary
in System Settings > Privacy & Security > Accessibility for it to function.
'';
homepage = "https://github.com/blindFS/Glyphlow";
license = licenses.mit;
platforms = [ "aarch64-darwin" ];
};
};
in
{
packages.default = glyphlow-bin;
packages.glyphlow = glyphlow-bin;
apps.default = flake-utils.lib.mkApp { drv = glyphlow-bin; };
}
)
// {
# Nix-darwin module
darwinModules.glyphlow =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.glyphlow;
tomlFormat = pkgs.formats.toml { };
in
{
options.services.glyphlow = {
enable = lib.mkEnableOption "Glyphlow service";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.glyphlow;
description = "The glyphlow package to use.";
};
settings = lib.mkOption {
type = tomlFormat.type;
default = { };
description = "Configuration written to $XDG_CONFIG_HOME/glyphlow/config.toml.";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
# Since Glyphlow needs to be a LaunchAgent (runs as user, interacts with UI)
launchd.user.agents.glyphlow = {
serviceConfig = {
ProgramArguments = [ "${cfg.package}/bin/glyphlow" ];
KeepAlive = false;
RunAtLoad = true;
ProcessType = "Interactive";
};
};
# Optionally manage config file at $XDG_CONFIG_HOME/glyphlow/config.toml
# However, nix-darwin doesn't have a great way to manage user-specific config files directly
# unless we use something like home-manager or environment.etc (which is system-wide).
# Most users use home-manager for this.
};
};
# Home-manager module
homeManagerModules.glyphlow =
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.glyphlow;
tomlFormat = pkgs.formats.toml { };
in
{
options.programs.glyphlow = {
enable = lib.mkEnableOption "Glyphlow";
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${pkgs.stdenv.hostPlatform.system}.glyphlow;
description = "The glyphlow package to use.";
};
settings = lib.mkOption {
type = tomlFormat.type;
default = { };
description = "Configuration written to $XDG_CONFIG_HOME/glyphlow/config.toml.";
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."glyphlow/config.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "glyphlow-config" cfg.settings;
};
# On macOS, home-manager can also manage launchd agents if using the macos module
launchd.agents.glyphlow = lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
config = {
ProgramArguments = [ "${cfg.package}/bin/glyphlow" ];
KeepAlive = true;
RunAtLoad = true;
ProcessType = "Interactive";
};
};
};
};
};
}