I want to do local development of a GitHub Pages site. GitHub Pages serves your site using Jekyll, which is written in Ruby. The exact dependencies are listed at
Given this, is there a simple shell.nix automatically giving a local development environment matching the environment GitHub Pages runs on?
At the very least, if one gives up on automatically keeping up with the Ruby version used by GitHub Pages, then Ruby together with pages-gem should suffice. It is however not clear to me how to accomplish this.
As far as I can see, those approaches generate a shell.nix (and additional files) fixing a development environment on whatever is specified by the current version of pages-gem. Thus when pages-gem is updated this development environment would become outdated. And in any case, ideally one should not need to deal with the large auto-generated Gemfile.lock and gemset.nix files since basically the desired development environment is fully specified by the two lines in the Gemfile file.
Thanks! I had to add ruby to buildInputs but then this worked like a charm. On MacOS this seems to require XCode development tools. Any way around this? (The approaches I mentioned above works on MacOS without XCode development tools installed.)
(I would still be interested in a “more pure” nix-shell solution.)
This worked for me until recently. I used nix-shell -p jekyll bundler followed by bundle exec jekyll serve but now I get the following error:
/home/wswinks/.local/share/gem/ruby/3.1.0/gems/sass-embedded-1.77.8/lib/sass/compiler/connection.rb:61: warning: Could not start dynamically linked executable: /home/wswinks/.local/share/gem/ruby/3.1.0/gems/sass-embedded-1.77.8/ext/sass/dart-sass/src/dart
/home/wswinks/.local/share/gem/ruby/3.1.0/gems/sass-embedded-1.77.8/lib/sass/compiler/connection.rb:61: warning: NixOS cannot run dynamically linked executables intended for generic
/home/wswinks/.local/share/gem/ruby/3.1.0/gems/sass-embedded-1.77.8/lib/sass/compiler/connection.rb:61: warning: linux environments out of the box. For more information, see:
/home/wswinks/.local/share/gem/ruby/3.1.0/gems/sass-embedded-1.77.8/lib/sass/compiler/connection.rb:61: warning: https://nix.dev/permalink/stub-ld
Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/jekyll-theme-chirpy.scss':
Broken pipe
------------------------------------------------
Jekyll 4.3.3 Please append `--trace` to the `serve` command
for any additional information or backtrace.
------------------------------------------------
Apparently Jekyll uses now Dart SASS instead of SASS which can also be seen in the output. Do the warnings have to do something with this error? The connection.rb files contains:
# frozen_string_literal: true
require 'open3'
require_relative '../../../ext/sass/cli'
module Sass
class Compiler
# The stdio based {Connection} between the {Dispatcher} and the compiler.
#
# It runs the `sass --embedded` command.
class Connection
def initialize
@mutex = Mutex.new
@stdin, @stdout, @stderr, @wait_thread = begin
Open3.popen3(*CLI::COMMAND, '--embedded', chdir: __dir__)
rescue Errno::ENOENT
require_relative '../elf'
raise if ELF::INTERPRETER.nil?
Open3.popen3(ELF::INTERPRETER, *CLI::COMMAND, '--embedded', chdir: __dir__)
end
@stdin.binmode
# # https://dart.dev/tools/dart-devtools
# if 'dart' == File.basename(CLI::COMMAND.first, '.exe') && CLI::COMMAND.include?('--observe')
# Kernel.warn(@stdout.readline, uplevel: 0)
# Kernel.warn(@stdout.readline, uplevel: 0)
# end
@stdout.binmode
@wait_thread.name = "sass-embedded-process-waiter-#{id}"
end
def id
@wait_thread.pid
end
def listen(dispatcher)
Thread.new do
Thread.current.name = "sass-embedded-process-stdout-poller-#{id}"
loop do
length = Varint.read(@stdout)
id = Varint.read(@stdout)
proto = @stdout.read(length - Varint.length(id))
dispatcher.receive_proto(id, proto)
end
rescue IOError, Errno::EBADF, Errno::EPROTO => e
dispatcher.error(e)
@mutex.synchronize do
@stdout.close
end
end
Thread.new do
Thread.current.name = "sass-embedded-process-stderr-poller-#{id}"
loop do
Kernel.warn(@stderr.readline, uplevel: 0)
end
rescue IOError, Errno::EBADF
@mutex.synchronize do
@stderr.close
end
end
end
def close
@mutex.synchronize do
@stdin.close
@wait_thread.join
@stdout.close
@stderr.close
end
end
def closed?
@mutex.synchronize do
@stdin.closed? && !@wait_thread.alive?
end
end
def write(id, proto)
buffer = []
Varint.write(buffer, Varint.length(id) + proto.length)
Varint.write(buffer, id)
@mutex.synchronize do
@stdin.write(buffer.pack('C*'), proto)
end
end
end
private_constant :Connection
end
end
At the moment I don’t know how to resolve this issue. Does anybody have suggestions on how to trouble shoot this?