summaryrefslogtreecommitdiff
path: root/pkgs/development/ruby-modules/bundler-update-script/default.nix
blob: e248851bf7d8a8b07d9c12b8db11e1d3b0278d14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  runtimeShell,
  lib,
  writeScript,
  bundix,
  bundler,
  coreutils,
  git,
  nix,
  nixfmt,
}:

attrPath:

let
  updateScript = writeScript "bundler-update-script" ''
    #!${runtimeShell}
    PATH=${
      lib.makeBinPath [
        bundler
        bundix
        coreutils
        git
        nix
        nixfmt
      ]
    }
    set -o errexit
    set -o nounset
    set -o pipefail

    attrPath=$1

    toplevel=$(git rev-parse --show-toplevel)
    position=$(nix --extra-experimental-features nix-command eval -f "$toplevel" --raw "$attrPath.meta.position")
    gemdir=$(dirname "$position")

    cd "$gemdir"

    rm -f gemset.nix Gemfile.lock
    export BUNDLE_FORCE_RUBY_PLATFORM=1
    bundler lock --update
    bundix
    nixfmt gemset.nix
  '';
in
[
  updateScript
  attrPath
]