TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: NixSH, run Bash/Python or any scripts with the power of Nix

2 点作者 Rucadi大约 1 年前
Hello HN!<p>I had to work with a codebase that was full of magic environment variables and tons of bash scripts, which was and still is a nightmare.<p>I decided to try and make a solution using NIX, which ended being far more easy to work with and I think that brings a lot of value.<p>This is: <a href="https:&#x2F;&#x2F;github.com&#x2F;Rucadi&#x2F;nixsh">https:&#x2F;&#x2F;github.com&#x2F;Rucadi&#x2F;nixsh</a><p>Some examples can be found on the readme but a more advanced example can be seen here: <a href="https:&#x2F;&#x2F;github.com&#x2F;Rucadi&#x2F;nixsh&#x2F;blob&#x2F;master&#x2F;examples&#x2F;nixsh&#x2F;cpp_script&#x2F;cpp.nixsh">https:&#x2F;&#x2F;github.com&#x2F;Rucadi&#x2F;nixsh&#x2F;blob&#x2F;master&#x2F;examples&#x2F;nixsh&#x2F;c...</a><p>Here&#x27;s a glimpse of what the solution offers:<p>- Precise control over environment variables, ensuring only the necessary ones are accessible when executing any script.<p>- Ability to set default values for environment variables<p>- Ability to dynamically manipulate environment variables directly from NIX expressions.<p>- Using nix to eliminate the need for manual installation of dependencies before script execution.<p>- Integration of disparate components like bash scripts and programs in C++, Rust, or Python, facilitating cohesive scripting.<p>- Leveraging NIX as a preprocessor for any file, for example, you can generate code using nix, and compile it before the execution runs automatically.<p>- Compile-Time checking of existence of files and envars<p>- Full interoperability, since you end up executing bash&#x2F;python in the end, with the benefit that nixsh will already have cleaned your environment :)<p>The current implementation involves parsing NIX code using tools like awk and sed to strategically inject components where needed. While this proof of concept serves its purpose.<p>I think it&#x27;s a cool program and I think that I will use from now on, I&#x27;m 100% open to contributions if you feel like it :)

暂无评论

暂无评论