build: 添加 Nix flake 支持 - #151
Conversation
|
Hello i have failed to reproduce this on my system NIxOS 26.05 x86-linux 你好,我无法在我的 NixOS 26.05 x86-linux 系统上复现此构建。 |
|
NixOS用户如果想现在用的话可以尝试https://github.com/ccicnce113424/nix-packages ,可以作为flake,也可以从nur里面拉 |
aef527b to
33857ed
Compare
|
坏了,被抢先了() |
88de0c4 to
1aed849
Compare
refactor: 从 package.json 获取 flake 的包版本
1aed849 to
a11564a
Compare
|
这个 flake 已根据 @ccicnce113424 的工作进行了调整。即使他们在 nixpkgs 中的 PR 最终被合并,我仍希望保留这个 flake,作为一种为 Nix 打包项目最新 commit 的方式。 @MasterZack69 报告的问题应该也已经解决了,因为之前用于处理 bindgen 的临时 workaround 已经被正确的解决方案所替代。目前正在等待他确认问题是否已经修复。 The flake has been updated to build on the good work by @ccicnce113424. Even if their PR in nixpkgs gets merged, If possible, I’d still like to keep this flake as a way to package the latest commit of the project for Nix. The issue reported by @MasterZack69 should also be resolved, as the previous hacky workaround for bindgen has been replaced with the proper solution. I’m waiting for him to confirm that the issue is fixed. |
|
除非能够自动从Cargo.lock和pnpm-lock.yaml中自动获得依赖,否则只要发生依赖变动,旧的FOD hash就会失效。如果不能实现这两点,只会增加麻烦。 |
我用新的 flake.nix 编译了,但问题依然存在,还是报一样的错。 |
| exec = "splayer-next %U"; | ||
| terminal = false; | ||
| type = "Application"; | ||
| icon = "SPlayer-Next"; |
There was a problem hiding this comment.
上面把图标安装到了$out/share/icons/hicolor/$_icons/apps/splayer-next.png,是全小写的splayer-next,但是此处图标写成了SPlayer-Next,大小写不匹配会导致找不到正确图标
| pkgs.python3 | ||
| pkgs.makeWrapper | ||
| pkgs.copyDesktopItems | ||
| pkgs.pkg-config |
There was a problem hiding this comment.
现在的问题是在项目根目录直接执行nix build ".#splayer-next"或者nix run ".#splayer-next"都是可以正常运行的,但是如果把该flake引入系统配置再进行nixos-rebuild那么在wayland环境中splayer-next会找不到libstdc++.so.6进而无法正常显示窗口。在这里加入pkgs.autoPatchelfHook可以解决这个问题,即使是在系统配置中引入也可以正常启动运行。
There was a problem hiding this comment.
I hope this can be resolved. @MasterZack69The problem
我可以确认添加 pkgs.autoPatchelfHook 后,应用能够正常构建并启动。
There was a problem hiding this comment.
现在的问题是在项目根目录直接执行
nix build ".#splayer-next"或者nix run ".#splayer-next"都是可以正常运行的,但是如果把该flake引入系统配置再进行nixos-rebuild那么在wayland环境中splayer-next会找不到libstdc++.so.6进而无法正常显示窗口。在这里加入pkgs.autoPatchelfHook可以解决这个问题,即使是在系统配置中引入也可以正常启动运行。
我曾短暂地将 pkgs.autoPatchelfHook 添加到 buildInputs 中,这解决了 MasterZack69 遇到的问题。不过,在发现 ccince113424 的 package.nix 中并没有它之后,我又把它移除了。
There was a problem hiding this comment.
我的LLM智能体告诉我nixpkgs版的111行rm -rf prebuilds很重要,因为better-sqlite3自带了预编译二进制,但这些预编译二进制不携带RUNPATH所以在NixOS的非标准路径中找不到libstdc++.so.6。
patchelf会注入RUNPATH从而防止报错因此加入pkgs.autoPatchelfHook可以解决问题;
直接删除预编译二进制会强制使用新编译的原生模块而不是预编译的二进制,因此携带了正确的RUNPATH而不会报错,因此rm -rf prebuilds也可以解决问题。
很抱歉在这里复读LLM内容,我只是觉得这些内容能帮上忙。
改动类型
是否包含破坏性变更
改动说明
这个 flake 基于 nixpkgs 中现有的 SPlayer 打包方案。
这个 PR 添加了一个用于打包该应用的 Nix flake,使 Nix 用户能够轻松地在自己的 flake 中引用并构建该应用。
此外,这个 PR 还更新了这是我的误解,lockfile 已恢复到之前的版本。pnpm-lock.yaml,因为fetchPnpmDeps要求使用最新的 lockfile,否则 flake 将无法构建。fetchPnpmDeps还要求提供依赖关系图的哈希值,这意味着每当依赖关系图发生变化时,都需要相应更新 flake。因此,我愿意在依赖关系发生变化导致 flake 失效时负责更新它。测试情况
这个 flake 已在 NixOS 26.11.20260801.148bab9(Zokor)x86-64 Linux 上进行了测试。构建成功生成了应用程序,包括可执行文件、桌面文件、图标以及其他所需资源。生成的可执行文件能够正常启动 SPlayer-Next,在测试期间未遇到任何崩溃。
自查清单
pnpm format,并确认pnpm typecheck、pnpm lint通过pnpm build:native验证;未手写native/*/index.d.tsdev分支提交免责声明
我不懂中文,因此需要使用 LLM 帮助我翻译 PR 模板。我先用英文回答了模板中的问题,然后使用 LLM 将其翻译成中文。由于我无法核实翻译的准确性,因此我同时附上了英文原文和中文翻译,以便他人可以独立核实我所提供的信息。
Disclaimer
I do not understand Chinese, so I had to use an LLM to translate the PR template. I wrote my responses to the questions in English and then used an LLM to translate them into Chinese. Since I am unable to verify the accuracy of the translation, I am including the English text alongside the Chinese translation so that the information I provided can be independently verified.
Change Type
Does this include breaking changes?
Description
This flake is based on the existing SPlayer packaging recipe in nixpkgs.
This PR adds a Nix flake that packages the application, allowing Nix users to easily include and build it in their own flakes.
This PR also updatesThis was a misconception on my part, lockfile was restored to its previous version.pnpm-lock.yaml, asfetchPnpmDepsrequires an up-to-date lockfile and the flake fails to build without it.fetchPnpmDepsalso requires a hash of the dependency graph, meaning the flake will need to be updated whenever the dependency graph changes. Therefore, I volunteer to update the flake whenever this happens.Testing
The flake was tested on NixOS 26.11.20260801.148bab9 (Zokor) on x86-64 Linux. It successfully builds the application, including the executable, desktop entry, icons, and other required resources. The resulting executable launches SPlayer-Next successfully, and I have not encountered any crashes during my testing.
Checklist
pnpm formatand confirmed thatpnpm typecheckandpnpm lintpasspnpm build:native; I have not manually writtennative/*/index.d.tsdevbranch