gpt4 book ai didi

ruby - 使用 Nix 在本地构建 GitHub 页面

转载 作者:太空宇宙 更新时间:2023-11-03 16:15:14 25 4
gpt4 key购买 nike

我在 NixOS 上,我想在本地构建一些 GitHub 页面。

GitHub seems to indicate我应该创建一个 Gemfile 包含:

gem "github-pages", group: :jekyll_plugins

Nixpkgs manual section on Ruby 之后,我做了:

$ cat > Gemfile
source 'https://rubygems.org'
gem "github-pages", group: :jekyll_plugins
$ $(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic

导致在 Nokogiri 上构建失败:

An error occurred while installing nokogiri (1.8.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.1'` succeeds before bundling.

构建失败如下:

zlib is missing; necessary for building libxml2

我已经确认问题出在通过运行构建 Nokogiri 时:

gem install nokogiri -v '1.8.1'

在各种环境中(使用 nix-shell -p zlibnix-shell -p zlibStaticnix-shell -p zlib libxml2 , nix-shell -p zlib pkgconfig 等)。

从谷歌上搜索,Nokogiri似乎是一个非常常见的依赖项(例如Rails依赖它),所以我想大多数人都克服了我遇到的困难。我错过了什么?

最佳答案

短路径

如果您真正需要的只是构建一个 github 页面,您只需要使用 nix-shell -p jekyll 输入一个 shell,然后使用 jekyll build 因为现在 jekyll 是打包为应用

长路径 当您希望在同一个 Gemfile 中包含 jekyll 和其他 gem 时使用

您可以在此处找到详细说明:Building a Jekyll Environment with NixOS (尽管实际上没有什么特定于 NixOS)

我认为这是 --magic 标志的问题(或者我没有得到它的真正用法)并且它没有使用某些 gems 中的特殊配置nixpkgs.

因此,为了避免出现该标志,您可以(post above 中的完整说明):

  1. 像您一样创建一个没有 'group' 指令的裸 Gemfile

  2. 在一个带有 bundler 的 shell 中调用 bundler lock 来获取 Gemfile.lock

  3. 不带参数调用bundix获取gemset.nix

  4. 创建一个在 buildInputs 中具有 bundlerEnv 的派生,如手册中所述。

    博客的 default.nix 加分,因为它会在您键入 nix-shell 时启动 jekyll 本地服务器

关于ruby - 使用 Nix 在本地构建 GitHub 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47249294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com