about summary refs log tree commit diff
path: root/pkgs/applications/radio/rtl-sdr/default.nix
blob: f0bbba9b0a3ba059f2472f91c8c3bc012b877f9d (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ lib
, stdenv
, fetchFromGitea
, fetchFromGitHub
, cmake
, pkg-config
, libusb1
}:
let
  generic = { version, pname, src, meta }:
    stdenv.mkDerivation {
      inherit version pname src;
      nativeBuildInputs = [ pkg-config cmake ];
      propagatedBuildInputs = [ libusb1 ];

      cmakeFlags = lib.optionals stdenv.isLinux [
        "-DINSTALL_UDEV_RULES=ON"
        "-DWITH_RPC=ON"
      ];

      postPatch = ''
        substituteInPlace CMakeLists.txt \
          --replace '/etc/udev/rules.d' "$out/etc/udev/rules.d" \
          --replace "VERSION_INFO_PATCH_VERSION git" "VERSION_INFO_PATCH_VERSION ${lib.versions.patch version}"

        substituteInPlace rtl-sdr.rules \
          --replace 'MODE:="0666"' 'ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev"'
      '';

      meta = with lib; {
        inherit (meta) longDescription homepage;
        description = "Software to turn the RTL2832U into a SDR receiver";
        license = licenses.gpl2Plus;
        maintainers = with maintainers; [ bjornfor skovati Tungsten842 ];
        platforms = platforms.unix;
        mainProgram = "rtl_sdr";
      };
    };
in
{
  rtl-sdr-osmocom = generic rec {
    pname = "rtl-sdr-osmocom";
    version = "2.0.1";

    src = fetchFromGitea {
      domain = "gitea.osmocom.org";
      owner = "sdr";
      repo = "rtl-sdr";
      rev = "v${version}";
      hash = "sha256-+RYSCn+wAkb9e7NRI5kLY8a6OXtJu7QcSUht1R6wDX0=";
    };
    meta = {
      longDescription = "Rtl-sdr library by the Osmocom project";
      homepage = "https://gitea.osmocom.org/sdr/rtl-sdr";
    };
  };

  rtl-sdr-librtlsdr = generic rec {
    pname = "rtl-sdr-librtlsdr";
    version = "0.9.0";

    src = fetchFromGitHub {
      owner = "librtlsdr";
      repo = "librtlsdr";
      rev = "v${version}";
      hash = "sha256-I1rbywQ0ZBw26wZdtMBkfpj7+kv09XKrrcoDuhIkRmw=";
    };
    meta = {
      longDescription = ''
        Fork of the rtl-sdr library by the Osmocom project. A list of differences
        can be found here: https://github.com/librtlsdr/librtlsdr/blob/master/README_improvements.md
      '';
      homepage = "https://github.com/librtlsdr/librtlsdr";
    };
  };

  rtl-sdr-blog = generic rec {
    pname = "rtl-sdr-blog";
    version = "1.3.5";

    src = fetchFromGitHub {
      owner = "rtlsdrblog";
      repo = "rtl-sdr-blog";
      rev = version;
      hash = "sha256-7FpT+BoQ2U8KiKwX4NfEwrO3lMBti7RX8uKtT5dFH8M=";
    };
    meta = {
      longDescription = ''
        Fork of the rtl-sdr library by the Osmocom project. A list of differences
        can be found here: https://github.com/rtlsdrblog/rtl-sdr-blog/blob/master/README
      '';
      homepage = "https://github.com/rtlsdrblog/rtl-sdr-blog";
    };
  };

}