Hello,
I got tired of running into ruby version and dependency errors every year or so when building my Jekyll-based blog on MacOS (most dependencies via homebrew), so I thought this sounded like a perfect fit for my first useful project with nix.
I thought a flake would be the best way to make sure everything is totally reproducible, so I put things together into this flake which I I’ve been running happily via nix develop
for the last couple of months:
{
description = "Reproducible setup for n8henrie.com via GitHub Pages";
inputs = {
# ruby 2.7.3
# https://pages.github.com/versions/
# https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=ruby
nixpkgs.url = "https://github.com/NixOS/nixpkgs/archive/860b56be91fb874d48e23a950815969a7b832fbc.tar.gz";
};
outputs = { self, nixpkgs }:
let
system = "aarch64-darwin";
pkgs = nixpkgs.legacyPackages.${system};
gems = pkgs.bundlerEnv {
ruby = pkgs.ruby;
name = "n8henrie.com";
gemdir = ./.;
gemConfig.nokogiri = attrs: {
buildInputs = [ pkgs.zlib ];
};
};
in
{
devShell.${system} =
let
pkgs = import nixpkgs { inherit system; };
in
with pkgs;
mkShell {
buildInputs = [
bundix
gems
libffi
pkgconfig
ruby
];
shellHook = ''
export LANG="en_US.UTF-8"
make develop
'';
};
};
}
Unfortunately yesterday I tried to work on a new blog post (in part about setting up a nixos VM on my M1 Mac) and ran into errors, without changing anything in my flake (the dirty git repo was from the new blog post itself):
$ nix develop
warning: Git tree '/Users/n8henrie/git/n8henrie.com' is dirty
error: builder for '/nix/store/g73www98mimm1xs1zy4lbdbmcinjlv2x-ruby2.7.3-nokogiri-1.13.8.drv' failed with exit code 1;
last 10 log lines:
> from extconf.rb:774:in `<main>'
>
> To see why this extension failed to compile, please check the mkmf.log which can be found here:
>
> /nix/store/brhgiv7z1xhv2w3ghgc4vkb2scgy5pvl-ruby2.7.3-nokogiri-1.13.8/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/nokogiri-1.13.8/mkmf.log
>
> extconf failed, exit code 1
>
> Gem files will remain installed in /nix/store/brhgiv7z1xhv2w3ghgc4vkb2scgy5pvl-ruby2.7.3-nokogiri-1.13.8/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.8 for inspection.
> Results logged to /nix/store/brhgiv7z1xhv2w3ghgc4vkb2scgy5pvl-ruby2.7.3-nokogiri-1.13.8/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/nokogiri-1.13.8/gem_make.out
For full logs, run 'nix log /nix/store/g73www98mimm1xs1zy4lbdbmcinjlv2x-ruby2.7.3-nokogiri-1.13.8.drv'.
error: 1 dependencies of derivation '/nix/store/yybx749z1v3gby0c2kay06gff30s6s5g-n8henrie.com.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ki4v28h21m2nzx1cdin3al1izhb5ghb7-nix-shell-env.drv' failed to build
Reading through mkmf.log
, this looks like the error:
error: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused -command-line-argument'? [-Werror,-Wunknown-warning-option]
Searching for related issues, I see a few jekyll issues on nixpkgs, some questionably related issues on bundix, but nothing that looks like this error specifically.
This looks to be the same error: Unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future' · Issue #1258 · sparklemotion/nokogiri · GitHub but looks like the root cause is changes to clang and Xcode (which there was an XCode update recently)… but I thought nix was the solution to these kinds of “dependencies changing underneath me” errors, right? I thought “something must be polluting my nix environment, otherwise how could this happen?” so I tried nix develop -i
– same error. Then I remembered how even nix develop -i
was not really as pure as nix-shell --pure
, so I converted the flake into a default.nix
and ran it in nix-shell --pure
… same issue.
So am I totally mistaken about nix and reproducibility? I thought that the entire dependency chain would be built into the nix store and using a flake with a pinned nixpks should give me something that was virtually guaranteed to work consistently. Instead, I was only able to use it a few times before I’m left feeling like my old approach was much simpler and no less resistant to breakage. What did I misunderstand here? I assume the issue is something about MacOS?