Skip to content

Commit

Permalink
Merge pull request #16 from sagittaros/separate-bundix
Browse files Browse the repository at this point in the history
Separate bundix
  • Loading branch information
inscapist authored Mar 20, 2023
2 parents 3dff193 + e9689da commit 8b9e80e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 44 deletions.
4 changes: 1 addition & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bundix:

{ stdenv, lib, buildEnv, ruby, makeBinaryWrapper, defaultGemConfig, buildRubyGem
, ... }@pkgs:

Expand All @@ -18,7 +16,7 @@ let
bundler = pkgs.bundler.override { inherit ruby; };

requirements = (pkgs // {
inherit my name ruby bundler bundix gempaths gemConfig groups document
inherit my name ruby bundler gempaths gemConfig groups document
extraRubySetup;
gemset = if builtins.typeOf gemset == "set" then
gemset
Expand Down
40 changes: 17 additions & 23 deletions examples/simple-app/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,58 @@
description = "A simple ruby app demo";

nixConfig = {
substituters = "https://cache.nixos.org https://nixpkgs-ruby.cachix.org";
trusted-public-keys =
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
extra-substituters = "https://nixpkgs-ruby.cachix.org";
extra-trusted-public-keys =
"nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
};

inputs = {
nixpkgs.url = "nixpkgs";
ruby-nix.url = "github:sagittaros/ruby-nix";
# a fork that supports platform dependant gem
bundix = {
url = "github:sagittaros/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
fu.url = "github:numtide/flake-utils";
bob-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
bob-ruby.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, fu, ruby-nix, bob-ruby }:
outputs = { self, nixpkgs, fu, ruby-nix, bundix, bob-ruby }:
with fu.lib;
eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ bob-ruby.overlays.default ];
# You can now refer to packages like:
# pkgs."ruby-3"
# pkgs."ruby-2.7"
# pkgs."ruby-3.0.1"
# See available versions here:
# https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
};
rubyNix = ruby-nix.lib pkgs;

# TODO generate gemset.nix with bundix
gemset =
if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };

# NOTE If you want to override gem build config, see
# If you want to override gem build config, see
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix
# gemConfig = {
# cbc-wrapper = _: { buildInputs = [ pkgs.cbc ]; };
# gpgme = _: { buildInputs = [ pkgs.pkg-config ]; };
# };
gemConfig = { };

in rec {
devmode = ruby-nix.presets.devmode;
finalGemset = devmode // gemset;
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-3.2";

bundixcli = bundix.packages.${system}.default;
in rec {
inherit (rubyNix {
inherit gemset ruby;
name = "my-rails-app";
gemset = finalGemset;
ruby = pkgs."ruby-3.2";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env ruby;
env;

devShells = rec {
default = dev;
dev = pkgs.mkShell {
# NOTE ordering is important here, the head in $PATH always take precedence
buildInputs = [ ruby env ]
buildInputs = [ env bundixcli ]
++ (with pkgs; [ nodejs-19_x yarn rufo ]);
};
};
Expand Down
16 changes: 4 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
{
description = "Nix function(s) for creating ruby environments";

inputs = {
nixpkgs.url = "nixpkgs";
inputs = { nixpkgs.url = "nixpkgs"; };

# a fork that supports platform dependant gem
bundix = {
url = "github:sagittaros/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, bundix }: {
lib = import ./. bundix;
outputs = { self, nixpkgs }: {
lib = import ./.;

# preset gemsets
presets = { devmode = import ./presets/devmode/gemset.nix; };
Expand All @@ -32,6 +24,6 @@
system = "x86_64-linux";
overlays = [ (import ./modules/overlays/ruby-overlay.nix) ];
};
in import ./shell.nix { inherit pkgs bundix; };
in import ./shell.nix pkgs;
};
}
6 changes: 2 additions & 4 deletions modules/ruby-env/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{ stdenv, lib, my, bundix, buildEnv, name, ... }@args:
{ stdenv, lib, my, buildEnv, name, ... }@args:

let
rubyEnv = import ./ruby-env.nix args;

extras = [ bundix ];

# useful for development
env = buildEnv {
inherit name;
paths = [ rubyEnv (lib.lowPrio rubyEnv.ruby) ] ++ extras;
paths = [ rubyEnv (lib.lowPrio rubyEnv.ruby) ];
pathsToLink = [ "/" ];
passthru = { ruby = rubyEnv.ruby; };
meta = { platforms = rubyEnv.meta.platforms; };
Expand Down
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs, bundix }:
pkgs:
let
rubyNix = (import ./default.nix bundix) pkgs;
rubyNix = import ./default.nix pkgs;
inherit (rubyNix {
name = "rubynix-test";
gemset = ./tests/tiny_app/gemset.nix;
Expand Down

0 comments on commit 8b9e80e

Please sign in to comment.