Skip to content

Commit 5dd7ac6

Browse files
author
Your Name
committed
Supported Nix Flake
1 parent c8164f1 commit 5dd7ac6

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
result

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
description = "Tablet mode detection and setup scripts for linux";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }: {
9+
10+
packages.x86_64-linux.linux_detect_tablet_mode = nixpkgs.legacyPackages."x86_64-linux".callPackage ./package.nix { };
11+
12+
packages.x86_64-linux.default = self.packages.x86_64-linux.linux_detect_tablet_mode;
13+
14+
};
15+
}

package.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
lib,
3+
stdenv,
4+
libinput,
5+
makeWrapper # 提供wrapProgram工具
6+
}:
7+
stdenv.mkDerivation rec {
8+
pname = "linux_detect_tablet_mode";
9+
version = "unstable";
10+
11+
src = ./.;
12+
13+
# 依赖:libinput(提供命令)和makeWrapper(提供wrapProgram)
14+
buildInputs = [ libinput ];
15+
nativeBuildInputs = [ makeWrapper ]; # 构建时需要makeWrapper
16+
17+
installPhase = ''
18+
mkdir -p $out/bin
19+
cp "$src/watch_tablet" "$out/bin/"
20+
chmod +x "$out/bin/watch_tablet"
21+
22+
# 关键:用wrapProgram包装脚本,强制将libinput的bin目录添加到PATH
23+
wrapProgram "$out/bin/watch_tablet" \
24+
--prefix PATH : "${libinput}/bin" # 显式添加libinput的bin路径
25+
'';
26+
27+
meta = with lib; {
28+
description = "Tablet mode detection and setup scripts for linux";
29+
license = licenses.mit;
30+
mainProgram = "watch_tablet";
31+
platforms = platforms.x86_64-linux;
32+
};
33+
}
34+

0 commit comments

Comments
 (0)