Skip to content

Commit

Permalink
nix: Switch to ruby-nix dev shell
Browse files Browse the repository at this point in the history
Creates a fully reproducible development shell with Gem versions derived
from Gemfile.lock.
  • Loading branch information
antoineco committed Sep 6, 2024
1 parent 56390fe commit d0d234a
Show file tree
Hide file tree
Showing 4 changed files with 1,399 additions and 16 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exclude:
- LICENSE*.txt
- CNAME
- flake.*
- gemset.nix

plugins:
- jekyll-feed
Expand Down
55 changes: 49 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 43 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,63 @@
description = "GitHub Pages";

inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; # nixos-unstable

inputs.ruby-nix = {
url = "github:inscapist/ruby-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

inputs.bundix = {
url = "github:inscapist/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};

inputs.flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.*.tar.gz";

outputs = { self, nixpkgs, flake-schemas }:
outputs = { self, nixpkgs, ruby-nix, bundix, flake-schemas }:
let
allSystems = [
"x86_64-linux"
"aarch64-darwin"
];

forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
# Current 'ruby' package version: 3.3.4
# Should match https://github.com/actions/jekyll-build-pages/blob/v1.0.13/Dockerfile
pkgs = import nixpkgs { inherit system; };
});
in
{
inherit (flake-schemas) schemas;

devShells = forAllSystems ({ pkgs }: {
default = with pkgs; mkShell {
packages = [
ruby
rubyPackages.github-pages
rubyPackages.webrick # https://github.com/jekyll/jekyll/pull/8524
];
};
});
devShells = forAllSystems ({ pkgs }:
let
ruby-env = (ruby-nix.lib pkgs {
name = "github-pages";
gemset = ./gemset.nix;
}).env;

bundix-cli = bundix.packages.${pkgs.system}.default;

bundleLock = pkgs.writeShellScriptBin "bundle-lock" ''
export BUNDLE_PATH=vendor/bundle
bundle lock
'';
bundleUpdate = pkgs.writeShellScriptBin "bundle-update" ''
export BUNDLE_PATH=vendor/bundle
bundle lock --update
'';
in
{
default = pkgs.mkShell {
buildInputs = [
ruby-env
bundix-cli
bundleLock
bundleUpdate
];
};
}
);
};
}
Loading

0 comments on commit d0d234a

Please sign in to comment.