-
-
Save samueldr/f82d2b131145ae5922556a4bf7246a1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ src, stdenv, fetchFromGitHub, bundix, cacert }: | |
stdenv.mkDerivation { | |
name = "lobsters-gemset.nix"; | |
inherit src; | |
installPhase = '' | |
HOME="$PWD/home"; | |
export SSL_CERT_FILE=${cacert.out}/etc/ssl/certs/ca-bundle.crt | |
mkdir -p "$HOME" | |
${bundix}/bin/bundix -l --gemset=$out | |
''; | |
outputHashAlgo = "sha256"; | |
outputHash = "0a4fgag3z4hjlsqrg48a196bn72kab71fgcsi9779xwjhiaqxcsj"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
pkgs ? (import <nixpkgs> {}) | |
}: | |
let | |
pp = x: builtins.trace x x; | |
inherit (pkgs) stdenv bash bundlerEnv ruby fetchFromGitHub writeScriptBin nix; | |
src = fetchFromGitHub { | |
owner = "lobsters"; | |
repo = "lobsters"; | |
rev = "3cc6ff7aeef68fea70dde828b9f91f4682c20afe"; | |
sha256 = "0bgyddlxayzbg50cnbswhjfbcs0l8s7qlvzi4hkdq1h1msa5kqvw"; | |
}; | |
store-less-prefetch = writeScriptBin "nix-prefetch-url" '' | |
#!${bash}/bin/bash | |
# HACK!! assumes --type sha256 is given | |
# FIXME: parse params. | |
shift | |
shift | |
# Third param as seen here: | |
# https://github.com/manveru/bundix/blob/4fdebde8d38dda80ff76b76b3c7f6fcad2afa22d/lib/bundix/source.rb#L32 | |
file="''${1#file://}" | |
exec ${nix.out}/bin/nix-hash --type sha256 --flat --base32 "$file" | |
# Oops, bundix already downloads 'em for us! | |
# No need for the following, but it would be neat | |
# to have in a store-less-prefetch. | |
#exec ${nix.out}/bin/nix-hash --type sha256 --flat --base32 <(curl --silent "$@") | |
''; | |
bundix = pkgs.bundix.overrideDerivation(oldAttrs: { | |
# Copied from <nixpkgs/pkgs/development/ruby-modules/bundix/default.nix> | |
preFixup = with pkgs /* eww */; '' | |
wrapProgram $out/bin/bundix \ | |
--prefix PATH : "${nix.out}/bin" \ | |
--prefix PATH : "${nix-prefetch-git.out}/bin" \ | |
--prefix PATH : "${bundler.out}/bin" \ | |
--prefix PATH : "${store-less-prefetch}/bin" \ | |
--set GEM_HOME "${bundler}/${bundler.ruby.gemPath}" \ | |
--set GEM_PATH "${bundler}/${bundler.ruby.gemPath}" | |
''; | |
}); | |
in | |
let | |
gems = bundlerEnv { | |
name = "lobsters-env"; | |
inherit ruby; | |
gemfile = "${src}/Gemfile"; | |
lockfile = "${src}/Gemfile.lock"; | |
gemset = pp "${pkgs.callPackage (import ./gemset.ifd.nix) {inherit src bundix;}}"; | |
}; | |
in stdenv.mkDerivation { | |
name = "lobsters"; | |
buildInputs = [gems ruby]; | |
inherit src; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment