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
|
{
lib,
stdenv,
buildGo126Module,
makeBinaryWrapper,
xdg-dbus-proxy,
pkg-config,
libffi,
libseccomp,
acl,
wayland,
wayland-protocols,
wayland-scanner,
xorg,
# for sharefs
fuse3,
# for passthru.buildInputs
go_1_26,
clang,
# for check
util-linux,
nettools,
glibc, # for ldd
withStatic ? stdenv.hostPlatform.isStatic,
}:
buildGo126Module rec {
pname = "hakurei";
version = "0.4.3";
srcFiltered = builtins.path {
name = "${pname}-src";
path = lib.cleanSource ./.;
filter = path: type: !(type == "regular" && (lib.hasSuffix ".nix" path || lib.hasSuffix ".py" path)) && !(type == "directory" && lib.hasSuffix "/test" path) && !(type == "directory" && lib.hasSuffix "/cmd/hsu" path);
};
vendorHash = null;
src = stdenv.mkDerivation {
name = "${pname}-src-full";
inherit version;
enableParallelBuilding = true;
src = srcFiltered;
buildInputs = [
wayland
wayland-protocols
];
nativeBuildInputs = [
go_1_26
pkg-config
wayland-scanner
];
buildPhase = "GOCACHE=$(mktemp -d) go generate ./...";
installPhase = "cp -r . $out";
};
ldflags =
lib.attrsets.foldlAttrs
(
ldflags: name: value:
ldflags ++ [ "-X hakurei.app/internal/info.${name}=${value}" ]
)
(
[ "-s -w" ]
++ lib.optionals withStatic [
"-linkmode external"
"-extldflags \"-static\""
]
)
{
buildVersion = "v${version}";
hakureiPath = "${placeholder "out"}/libexec/hakurei";
hsuPath = "/run/wrappers/bin/hsu";
};
env = {
# use clang instead of gcc
CC = "clang -O3 -Werror";
};
buildInputs = [
libffi
libseccomp
fuse3
acl
wayland
]
++ (with xorg; [
libxcb
libXau
libXdmcp
]);
nativeBuildInputs = [
pkg-config
makeBinaryWrapper
# for container example
nettools
];
postInstall =
let
appPackages = [
glibc
xdg-dbus-proxy
];
in
''
install -D --target-directory=$out/share/zsh/site-functions cmd/dist/comp/*
mkdir "$out/libexec"
mv "$out"/bin/* "$out/libexec/"
makeBinaryWrapper "$out/libexec/hakurei" "$out/bin/hakurei" \
--inherit-argv0 --prefix PATH : ${lib.makeBinPath appPackages}
'';
passthru = {
go = go_1_26;
targetPkgs = [
go_1_26
clang
xorg.xorgproto
util-linux
# for go generate
wayland-protocols
wayland-scanner
]
++ buildInputs
++ nativeBuildInputs;
};
}
|