Repository navigation
Expand file tree
/
Copy pathchecks.nix
More file actions
159 lines (154 loc) · 5.56 KB
/
Copy pathchecks.nix
File metadata and controls
159 lines (154 loc) · 5.56 KB
1
2
3
4
5
6<
8000
/div>
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
159
{ self, pkgs }:
let
inherit (pkgs) lib;
hex = self.packages.${pkgs.stdenv.hostPlatform.system}.hex;
shell = self.devShells.${pkgs.stdenv.hostPlatform.system}.default;
home =
settings:
(self.inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
self.homeManagerModules.hex
{
home.username = "hex-test";
home.homeDirectory = "/home/hex-test";
home.stateVersion = "26.05";
programs.hex = settings;
}
];
}).config;
enabled = home {
enable = true;
autostart = true;
};
manual = home { enable = true; };
disabled = home { enable = false; };
declared = home {
enable = true;
shortcut = "control+option+space";
model = "parakeet_v3";
installModel = true;
settings = {
sound_effect_volume = 0.4;
microphone = null;
"transcription.language" = "de";
};
};
declaredSettings = (pkgs.formats.json { }).generate "hex-settings.json" {
dictation_hotkey = "control+option+space";
"transcription.model" = "parakeet_v3";
"transcription.language" = "de";
sound_effect_volume = 0.4;
microphone = null;
};
custom = home {
enable = true;
autostart = true;
package = pkgs.hello;
systemdTarget = "sway-session.target";
};
system =
(self.inputs.nixpkgs.lib.nixosSystem {
system = pkgs.stdenv.hostPlatform.system;
modules = [
self.nixosModules.hex
{
programs.hex.enable = true;
system.stateVersion = "26.05";
}
];
}).config;
in
{
package = pkgs.runCommand "hex-package-check" { } ''
export HOME="$TMPDIR/home"
mkdir -p "$HOME"
${lib.getExe hex} --version
${lib.getExe hex} model status | grep '^missing[[:spa
8000
ce:]]'
touch "$out"
'';
shell-environment =
assert lib.all (name: shell.${name} == hex.${name}) [
"BLA_VENDOR"
"OPENSSL_NO_VENDOR"
];
# OpenBLAS ordering belongs to build.rs, not an injected Nix-only workaround.
assert !(hex ? RUSTFLAGS) && !(shell ? RUSTFLAGS);
assert lib.all
(package: builtins.elem "${lib.getLib package}/lib" (lib.splitString ":" shell.LD_LIBRARY_PATH))
[
pkgs.vulkan-loader
pkgs.wayland
pkgs.libxkbcommon
];
assert lib.all (package: builtins.elem (lib.getDev package) shell.nativeBuildInputs) [
pkgs.curl
pkgs.wl-clipboard
pkgs.wtype
];
pkgs.runCommand "hex-shell-environment-check" { } ''
test -d ${shell.ALSA_PLUGIN_DIR}
touch "$out"
'';
modules =
assert builtins.elem hex system.environment.systemPackages;
assert builtins.elem hex enabled.home.packages;
assert !(builtins.elem hex disabled.home.packages);
assert manual.systemd.user.services.hex.Install.WantedBy == [ ];
assert !(disabled.systemd.user.services ? hex);
assert enabled.systemd.user.services.hex.Service.ExecStart == [ "${lib.getExe hex} service" ];
assert enabled.systemd.user.services.hex.Service.Restart == "on-failure";
assert enabled.systemd.user.services.hex.Service.Type == "notify";
assert enabled.systemd.user.services.hex.Service.NotifyAccess == "main";
assert builtins.elem "HEX_APPLICATION_SUPPORT_DIR=${enabled.xdg.dataHome}/hex"
enabled.systemd.user.services.hex.Service.Environment;
assert custom.systemd.user.services.hex.Service.ExecStart == [ "${lib.getExe pkgs.hello} service" ];
assert lib.all (name: custom.systemd.user.services.hex.Unit.${name} == [ "sway-session.target" ]) [
"After"
"PartOf"
];
assert custom.systemd.user.services.hex.Install.WantedBy == [ "sway-session.target" ];
assert !(enabled.home.activation ? hexSettings);
assert !(enabled.systemd.user.services ? hex-model);
assert lib.hasInfix (builtins.unsafeDiscardStringContext "settings apply ${declaredSettings}") (
builtins.unsafeDiscardStringContext declared.home.activation.hexSettings.data
);
assert lib.elem "reloadSystemd" declared.home.activation.hexSettings.after;
assert declared.systemd.user.services.hex-model.Service.Type == "exec";
assert declared.systemd.user.services.hex-model.Install.WantedBy == [ "default.target" ];
pkgs.runCommand "hex-module-check" { } ''
bash -n ${enabled.systemd.user.services.hex.Service.ExecStartPre}
bash -n ${toString declared.systemd.user.services.hex-model.Service.ExecStart}
touch "$out"
'';
session-readiness =
let
xprop = pkgs.writeShellScriptBin "xprop" ''
printf '%s\n' "''${HEX_TEST_XPROP:-}"
'';
sleep = pkgs.writeShellScriptBin "sleep" "exit 0";
in
pkgs.runCommand "hex-session-readiness-check" { } ''
run() {
env -i PATH=${
lib.makeBinPath [
xprop
sleep
pkgs.gnugrep
]
} "$@" \
${pkgs.bash}/bin/bash -euo pipefail ${./wait-for-session.sh}
}
if run; then exit 1; fi
if run DISPLAY=:1 HEX_TEST_XPROP='_NET_SUPPORTING_WM_CHECK: not found.'; then exit 1; fi
if run DISPLAY=:1 HEX_TEST_XPROP='_NET_SUPPORTING_WM_CHECK(WINDOW): window id # 0x0'; then exit 1; fi
run DISPLAY=:1 HEX_TEST_XPROP='_NET_SUPPORTING_WM_CHECK(WINDOW): window id # 0xa00001'
if run WAYLAND_DISPLAY=wayland-test XDG_RUNTIME_DIR="$TMPDIR"; then exit 1; fi
${pkgs.python3}/bin/python -c \
'import socket, sys; sock = socket.socket(socket.AF_UNIX); sock.bind(sys.argv[1])' \
"$TMPDIR/wayland-test"
run WAYLAND_DISPLAY=wayland-test XDG_RUNTIME_DIR="$TMPDIR"
run WAYLAND_DISPLAY="$TMPDIR/wayland-test"
touch "$out"
'';
}