summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/blivet/default.nix
blob: dd433a46b892bb696829370dba42a60a0951f397 (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
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
97
98
99
100
101
102
103
104
105
{
  lib,
  pkgs,
  python,
  buildPythonPackage,
  fetchFromGitHub,
  pygobject3,
  libblockdev,
  bytesize,
  pyudev,
  dbus-python,
  util-linux,
  kmod,
  libndctl,
  nvme-cli,
  dosfstools,
  e2fsprogs,
  hfsprogs,
  xfsprogs,
  f2fs-tools,
  ntfs3g,
  btrfs-progs,
  reiserfsprogs,
  mdadm,
  lvm2,
  gfs2-utils,
  cryptsetup,
  multipath-tools,
  dracut,
  stratisd,
}:

let
  libblockdevPython = (libblockdev.override { python3 = python; }).python;
in
buildPythonPackage rec {
  pname = "blivet";
  version = "3.12.1";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "storaged-project";
    repo = "blivet";
    tag = "blivet-${version}";
    hash = "sha256-ppX2rd1rFkRhca7F56JVQUDEQzW7Cg8ifV60URs2IMY=";
  };

  postPatch = ''
    find blivet -name '*.py' | while IFS= read -r i ; do
      substituteInPlace "$i" \
        --replace \
          'gi.require_version("BlockDev",' \
          'import gi.repository
    gi.require_version("GIRepository", "3.0")
    from gi.repository import GIRepository
    GIRepository.Repository.dup_default().prepend_search_path("${libblockdev}/lib/girepository-1.0")
    gi.require_version("BlockDev",'
    done
  '';

  propagatedBuildInputs = [
    pygobject3
    libblockdevPython
    bytesize
    pyudev
    dbus-python
    util-linux
    kmod
    libndctl
    nvme-cli
    pkgs.systemd
    dosfstools
    e2fsprogs
    hfsprogs
    xfsprogs
    f2fs-tools
    ntfs3g
    btrfs-progs
    reiserfsprogs
    mdadm
    lvm2
    gfs2-utils
    cryptsetup
    multipath-tools
    dracut
    stratisd
  ];

  pythonImportsCheck = [ "blivet" ];

  # Even unit tests require a system D-Bus.
  # TODO: Write a NixOS VM test?
  doCheck = false;

  meta = {
    description = "Python module for system storage configuration";
    homepage = "https://github.com/storaged-project/blivet";
    license = [
      lib.licenses.gpl2Plus
      lib.licenses.lgpl2Plus
    ];
    maintainers = with lib.maintainers; [ cybershadow ];
    platforms = lib.platforms.linux;
  };
}