--- /dev/null
+{ lib, writeText, poetry2nix, python, pythonPackages,
+ gobject-introspection, libblockdev, libbytesize, fetchFromGitHub,
+ pkg-config, parted, systemd,
+ with_dmraid ? false,
+ with_fs_btrfs ? false,
+ with_fs_fat ? false,
+ with_fs_f2fs ? false,
+ with_fs_hfs_plus ? false,
+ with_fs_jfs ? false,
+ with_fs_nfs ? false,
+ with_fs_nfsv4 ? false,
+ with_fs_ntfs ? false,
+ with_fs_reiserfs ? false,
+ with_fs_xfs ? false,
+ with_luks ? false,
+ with_lvm ? false,
+ with_mdadm ? false,
+ with_multipath ? false,
+ with_optical ? false,
+ with_iscsi ? false,
+ dmraid, multipath_tools, lvm2, eject, kmod, utillinux, lsof,
+ openiscsi, coreutils, dosfstools, e2fsprogs, jfsutils, btrfs-progs,
+ xfsprogs, f2fs-tools, hfsprogs, nfs-utils, ntfs3g, ntfsprogs,
+ reiserfsprogs, devicemapper, cryptsetup, mdadm
+}@args:
+let
+ # FIXME: blivet/tasks/fsmount.py links to /sbin
+ additionalPackages =
+ lib.optionals with_dmraid [ dmraid ]
+ ++ lib.optionals with_fs_btrfs [ btrfs-progs ]
+ ++ lib.optionals with_fs_fat [ dosfstools ]
+ ++ lib.optionals with_fs_f2fs [ f2fs-tools ]
+ ++ lib.optionals with_fs_hfs_plus [ hfsprogs ]
+ ++ lib.optionals with_fs_jfs [ jfsutils ]
+ ++ lib.optionals with_fs_nfs [ nfs-utils ]
+ ++ lib.optionals with_fs_ntfs [ ntfs3g ntfsprogs ]
+ ++ lib.optionals with_fs_reiserfs [ reiserfsprogs ]
+ ++ lib.optionals with_fs_xfs [ xfsprogs.bin ]
+ ++ lib.optionals with_luks [ devicemapper cryptsetup ]
+ ++ lib.optionals with_lvm [ lvm2 ]
+ ++ lib.optionals with_mdadm [ mdadm ]
+ ++ lib.optionals with_multipath [ multipath_tools ]
+ ++ lib.optionals with_optical [ eject ]
+ ++ lib.optionals with_iscsi [ openiscsi ];
+in
+# nix-shell -E "with import <nixpkgs> {}; pkgs.mkShell { buildInputs = [ python3 python3Packages.blivet3 ]; }"
+# nix-shell -E "with import <nixpkgs> {}; pkgs.mkShell { buildInputs = [ (python3.withPackages(p: [ p.blivet3 ])) ]; }"
+poetry2nix.mkPoetryApplication {
+ inherit python;
+ propagatedBuildInputs = [
+ gobject-introspection
+ (pythonPackages.toPythonModule libblockdev)
+ (pythonPackages.toPythonModule libbytesize)
+ ];
+ src = fetchFromGitHub {
+ owner = "storaged-project";
+ repo = "blivet";
+ rev = "blivet-3.3.0";
+ sha256 = "0ynxm37cxxr2sf2hj18hrdxs1qfw6dgdagkvv5f6g4fmp51m7c3c";
+ };
+ overrides = poetry2nix.overrides.withDefaults (self: super: {
+ pyparted = super.pyparted.overridePythonAttrs (old: {
+ buildInputs = old.buildInputs ++ [ parted ];
+ nativeBuildInputs = old.nativeBuildInputs ++ [ pkg-config ];
+ });
+ selinux = super.selinux.overridePythonAttrs (old: {
+ buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
+ nativeBuildInputs = old.nativeBuildInputs ++ [ pkg-config ];
+ });
+ });
+ patches = [ ./fix_path.patch ];
+ postPatch = let
+ runtimePaths = lib.makeBinPath ([
+ systemd utillinux kmod e2fsprogs mdadm lsof coreutils
+ ] ++ additionalPackages);
+ libraryPath = builtins.concatStringsSep " " (map (v: "-rpath ${v}/lib -L ${v}/lib") [ systemd.lib ]);
+ giLibraryPath = lib.makeSearchPath "lib/girepository-1.0" [libblockdev gobject-introspection];
+ addGiPath = writeText "add-gi-path" ''
+ import os
+ newGiPath = "${giLibraryPath}"
+ if newGiPath not in os.environ.get("GI_TYPELIB_PATH", ""):
+ os.environ["GI_TYPELIB_PATH"] = os.environ.get("GI_TYPELIB_PATH", "") + ":" + newGiPath
+ '';
+ addPath = writeText "add-path" ''
+ import os
+ newPath = "${runtimePaths}"
+ newLibraryPath = "${libraryPath}"
+ if newPath not in os.environ.get("PATH", ""):
+ os.environ["PATH"] = os.environ.get("PATH", "") + ":" + newPath
+ os.environ["NIX_LDFLAGS"] = os.environ.get("NIX_LDFLAGS", "") + " " + newLibraryPath
+ '';
+ in
+ ''
+ prepend() {
+ mv "$1" "$1.bak"
+ cat ${addPath} "$1.bak" > $1
+ rm -f "$1.bak"
+ }
+ prepend "blivet/__init__.py"
+ prepend "blivet/iscsi.py"
+ prepend "blivet/tasks/availability.py"
+ prepend "blivet/util.py"
+ prepend "blivet/udev.py"
+ prependGi() {
+ mv "$1" "$1.bak"
+ cat ${addGiPath} "$1.bak" > $1
+ rm -f "$1.bak"
+ }
+ grep -rl require_version blivet/ | while read i; do prependGi "$i"; done
+ sed -i -e "s@/lib/modules@/run/booted-system/kernel-modules/lib/modules/@" blivet/tasks/fsmount.py
+ '';
+ postInstall = let
+ in ''
+ rm -rf $out/lib/python*/site-packages/{etc,usr}
+ '';
+ pyproject = ./pyproject.toml;
+ poetrylock = ./poetry.lock;
+}
--- /dev/null
+[[package]]
+name = "distro"
+version = "1.5.0"
+description = "Distro - an OS platform information API"
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "pycairo"
+version = "1.19.1"
+description = "Python interface for cairo"
+category = "main"
+optional = false
+python-versions = ">=3.5, <4"
+
+[[package]]
+name = "pygobject"
+version = "3.36.1"
+description = "Python bindings for GObject Introspection"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+
+[package.dependencies]
+pycairo = ">=1.11.1"
+
+[[package]]
+name = "pyparted"
+version = "3.11.6"
+description = "Python bindings for GNU parted"
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "pyudev"
+version = "0.22.0"
+description = "A libudev binding"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+six = "*"
+
+[[package]]
+name = "selinux"
+version = "0.2.1"
+description = "shim selinux module"
+category = "main"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
+
+[package.dependencies]
+distro = ">=1.3.0"
+setuptools = ">=39.0"
+
+[[package]]
+name = "six"
+version = "1.15.0"
+description = "Python 2 and 3 compatibility utilities"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
+
+[metadata]
+lock-version = "1.0"
+python-versions = "^3.8"
+content-hash = "636edb46b1deb0f6d5db636b0bc6639205335c9915480b156a417067137548f8"
+
+[metadata.files]
+distro = [
+ {file = "distro-1.5.0-py2.py3-none-any.whl", hash = "sha256:df74eed763e18d10d0da624258524ae80486432cd17392d9c3d96f5e83cd2799"},
+ {file = "distro-1.5.0.tar.gz", hash = "sha256:0e58756ae38fbd8fc3020d54badb8eae17c5b9dcbed388b17bb55b8a5928df92"},
+]
+pycairo = [
+ {file = "pycairo-1.19.1.tar.gz", hash = "sha256:2c143183280feb67f5beb4e543fd49990c28e7df427301ede04fc550d3562e84"},
+]
+pygobject = [
+ {file = "PyGObject-3.36.1.tar.gz", hash = "sha256:012a589aec687bfa809a1ff9f5cd775dc7f6fcec1a6bc7fe88e1002a68f8ba34"},
+]
+pyparted = [
+ {file = "pyparted-3.11.6.tar.gz", hash = "sha256:727ccdf308c194069aa9797f7a6a973bc95b2e407cdf5d58d6c8bc4c9dec92dc"},
+]
+pyudev = [
+ {file = "pyudev-0.22.0.tar.gz", hash = "sha256:69bb1beb7ac52855b6d1b9fe909eefb0017f38d917cba9939602c6880035b276"},
+]
+selinux = [
+ {file = "selinux-0.2.1-py2.py3-none-any.whl", hash = "sha256:820adcf1b4451c9cc7759848797703263ba0eb6a4cad76d73548a9e0d57b7926"},
+ {file = "selinux-0.2.1.tar.gz", hash = "sha256:d435f514e834e3fdc0941f6a29d086b80b2ea51b28112aee6254bd104ee42a74"},
+]
+six = [
+ {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
+ {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
+]