1 { lib, stdenv, fetchFromGitHub, ruby, bundlerEnv }:
4 # To create Gemfile.lock and gemset.nix
5 # > nix-shell -p bundix bundler zlib
15 stdenv.mkDerivation rec {
18 # The package has no releases so let's use the latest commit
19 version = "unstable-2021-01-12";
21 src = fetchFromGitHub {
24 rev = "be15f5f897f8a919dd639009873147dca2a9cea0";
25 sha256 = "0gqkqfrqnrsy6avg372xwqj22yz8g6r2hnzbw6197b1rf7zr1il7";
31 substituteInPlace $script --replace "#{File.dirname(__FILE__)}/lib" "$out/lib/polar"
34 buildInputs = [ gems ruby ];
36 # See: https://nixos.wiki/wiki/Packaging/Ruby
38 # Put library content under lib/polar and the raw scripts under share/polar.
39 # Then, wrap the scripts so that they use the correct ruby environment and put
40 # these wrapped executables under bin.
42 install -Dm644 -t $out/etc/udev/rules.d ./pkg/99-polar.rules
43 mkdir -p $out/{bin,lib/polar,share/polar}
44 cp -r lib/* $out/lib/polar/
45 for script in ./polar_*
47 raw="$out/share/polar/$script"
48 bin="$out/bin/$script"
52 exec ${gems}/bin/bundle exec ${ruby}/bin/ruby "$raw" "\$@"
59 description = "Command-line tools to interact with Polar watches";
61 A set of command line tools written in Ruby to interact with Polar watches
62 and decode raw data files.
64 Udev rules can be added as:
66 services.udev.packages = [ pkgs.polar ]
68 homepage = "https://github.com/cmaion/polar";
69 license = licenses.gpl3Only;
70 maintainers = with maintainers; [ jluttine ];
71 platforms = platforms.linux;