Packaging/Ruby: Difference between revisions

imported>Angristan
Added gnumake, can be useful for many gems
F0x (talk | contribs)
Add example for setting gemConfig for bundlerEnv, extending from defaultGemConfig.
 
(10 intermediate revisions by 8 users not shown)
Line 1: Line 1:
See [https://nixos.org/manual/nixpkgs/stable/#packaging-applications Packaging Ruby programs] in the nixpkgs manual
Ruby projects are generally packaged with [https://github.com/manveru/bundix bundix]. This guide will show how to package a ruby project
Ruby projects are generally packaged with [https://github.com/manveru/bundix bundix]. This guide will show how to package a ruby project
See


== Building '''BeEF''' ==
== Building '''BeEF''' ==
Line 20: Line 26:
     libxml2
     libxml2
     libxslt
     libxslt
     pkgconfig
     pkg-config
     bundix
     bundix
     gnumake
     gnumake
Line 30: Line 36:
<syntaxHighlight lang=console>
<syntaxHighlight lang=console>
$ nix-shell
$ nix-shell
# generate Gemfile.lock
$ bundle lock      # generates Gemfile.lock
$ bundle install
$ bundix              # generates gemset.nix
# generate gemset.nix
$ bundix
</syntaxHighlight>
</syntaxHighlight>


Line 58: Line 62:
     cat > $bin <<EOF
     cat > $bin <<EOF
#!/bin/sh -e
#!/bin/sh -e
exec ${gems}/bin/bundle exec ${ruby}/bin/ruby $i "\$@"
exec ${gems}/bin/bundle exec ${ruby}/bin/ruby $out/share/beef/beef "\$@"
EOF
EOF
     chmod +x $bin
     chmod +x $bin
Line 88: Line 92:
}
}
</syntaxHighlight>
</syntaxHighlight>
=== Override gemConfig locally ===
<syntaxhighlight lang="nix">
gems = bundlerEnv {
    name = "beef-env";
    inherit ruby;
    gemdir  = ./.;
    gemConfig = pkgs.defaultGemConfig // {
        do_sqlite3 = attrs: {
            buildInputs = [ sqlite ];
        };
    };
};
</syntaxhighlight>




Line 111: Line 128:
   };
   };
</syntaxHighlight>
</syntaxHighlight>
== Using Bundler 2 ==
Bundler 2 comes included with Ruby, so instead of importing <code>ruby.devEnv</code> import Ruby and Bundix separately.




=== set the local gemConfig ===
[[Category:Development]]
'''TODO''': also merge with the <code>defaultGemConfig</code> somehow
[[Category:Ruby]]