2021-12-11 22:13:36 +00:00
{ lib , stdenv , fetchFromGitHub , fuse , bison , flex , openssl , python3 , ncurses , readline ,
2021-01-17 09:17:16 +00:00
autoconf , automake , libtool , pkg-config , zlib , libaio , libxml2 , acl , sqlite ,
2021-06-03 02:39:30 +00:00
liburcu , liburing , attr , makeWrapper , coreutils , gnused , gnugrep , which ,
2020-11-24 15:29:28 +00:00
openssh , gawk , findutils , util-linux , lvm2 , btrfs-progs , e2fsprogs , xfsprogs , systemd ,
2021-12-30 13:44:54 +00:00
rsync , glibc , rpcsvc-proto , libtirpc , gperftools , nixosTests
2015-06-14 08:23:42 +00:00
} :
2017-05-14 17:18:07 +00:00
let
2020-12-19 19:14:20 +00:00
# NOTE: On each glusterfs release, it should be checked if gluster added
# new, or changed, Python scripts whose PYTHONPATH has to be set in
# `postFixup` below, and whose runtime deps need to go into
# `nativeBuildInputs`.
# The command
# find /nix/store/...-glusterfs-.../ -name '*.py' -executable
# can help with finding new Python scripts.
2019-08-16 21:27:30 +00:00
2012-12-04 17:54:03 +00:00
buildInputs = [
2022-08-15 03:40:21 +00:00
fuse openssl ncurses readline
zlib libaio libxml2
acl sqlite liburcu attr util-linux libtirpc gperftools
2021-06-03 02:39:30 +00:00
liburing
2019-08-16 21:27:30 +00:00
( python3 . withPackages ( pkgs : [
2017-05-11 14:56:07 +00:00
pkgs . flask
pkgs . prettytable
pkgs . requests
2017-09-08 01:46:59 +00:00
pkgs . pyxattr
2017-05-11 14:56:07 +00:00
] ) )
2019-08-16 21:27:30 +00:00
# NOTE: `python3` has to be *AFTER* the above `python3.withPackages`,
2017-05-11 14:56:07 +00:00
# to ensure that the packages are available but the `toPythonPath`
# shell function used in `postFixup` is also still available.
2019-08-16 21:27:30 +00:00
python3
2009-08-31 09:52:01 +00:00
] ;
2015-07-01 06:54:42 +00:00
# Some of the headers reference acl
propagatedBuildInputs = [
acl
] ;
2017-05-11 14:56:07 +00:00
# Packages from which GlusterFS calls binaries at run-time from PATH,
# with comments on which commands are known to be called by it.
runtimePATHdeps = [
attr # getfattr setfattr
btrfs-progs # btrfs
coreutils # lots of commands in bash scripts
e2fsprogs # tune2fs
findutils # find
gawk # awk
glibc # getent
gnugrep # grep
gnused # sed
lvm2 # lvs
openssh # ssh
rsync # rsync, e.g. for geo-replication
systemd # systemctl
2020-11-24 15:29:28 +00:00
util-linux # mount umount
2017-05-11 14:56:07 +00:00
which # which
xfsprogs # xfs_info
] ;
2020-12-19 19:14:20 +00:00
in stdenv . mkDerivation rec {
pname = " g l u s t e r f s " ;
2023-04-10 22:02:29 +00:00
version = " 1 1 . 0 " ;
2020-12-19 19:14:20 +00:00
src = fetchFromGitHub {
owner = " g l u s t e r " ;
repo = pname ;
rev = " v ${ version } " ;
2023-04-10 22:02:29 +00:00
sha256 = " s h a 2 5 6 - K 2 w 8 Y q p o L z k z U u o O u I 7 i t f C 8 1 s J P U f 6 e l O L 8 L C r x K A I = " ;
2020-12-19 19:14:20 +00:00
} ;
2015-07-01 06:54:42 +00:00
inherit buildInputs propagatedBuildInputs ;
2014-12-18 10:20:03 +00:00
2022-07-16 22:27:33 +00:00
patches = [
# Upstream invokes `openssl version -d` to derive the canonical system path
# for certificates, which resolves to a nix store path, so this patch
# statically sets the configure.ac value. There's probably a less-brittle
# way to do this! (this will likely fail on a version bump)
# References:
# - https://github.com/gluster/glusterfs/issues/3234
# - https://github.com/gluster/glusterfs/commit/a7dc43f533ad4b8ff68bf57704fefc614da65493
./ssl_cert_path.patch
] ;
2019-08-16 21:27:30 +00:00
postPatch = ''
sed - e ' /chmod u+s/d ' - i contrib/fuse-util/Makefile.am
2020-05-09 18:32:35 +00:00
substituteInPlace libglusterfs/src/glusterfs/lvm-defaults.h \
- - replace ' /sbin / ' ' $ { lvm2 } /bin / '
substituteInPlace libglusterfs/src/glusterfs/compat.h \
2020-11-24 15:29:28 +00:00
- - replace ' /bin/umount ' ' $ { util-linux } /bin/umount '
2020-05-09 18:32:35 +00:00
substituteInPlace contrib/fuse-lib/mount-gluster-compat.h \
2020-11-24 15:29:28 +00:00
- - replace ' /bin/mount ' ' $ { util-linux } /bin/mount '
2019-08-16 21:27:30 +00:00
'' ;
2020-05-09 18:34:23 +00:00
# Note that the VERSION file is something that is present in release tarballs
# but not in git tags (at least not as of writing in v3.10.1).
# That's why we have to create it.
# Without this, gluster (at least 3.10.1) will fail very late and cryptically,
# for example when setting up geo-replication, with a message like
# Staging of operation 'Volume Geo-replication Create' failed on localhost : Unable to fetch master volume details. Please check the master cluster and master volume.
# What happens here is that the gverify.sh script tries to compare the versions,
# but fails when the version is empty.
# See upstream GlusterFS bug https://bugzilla.redhat.com/show_bug.cgi?id=1452705
preConfigure = ''
2021-12-30 12:03:46 +00:00
patchShebangs build-aux/pkg-version
2020-12-19 19:14:20 +00:00
echo " v ${ version } " > VERSION
2014-06-23 14:12:10 +00:00
./autogen.sh
2019-08-16 21:27:30 +00:00
export PYTHON = $ { python3 } /bin/python
2021-10-23 21:23:45 +00:00
'' ;
2014-12-18 10:20:03 +00:00
2009-08-31 09:52:01 +00:00
configureFlags = [
2021-01-24 09:19:10 +00:00
" - - l o c a l s t a t e d i r = / v a r "
2021-10-23 21:23:45 +00:00
] ;
2014-12-18 10:20:03 +00:00
2022-08-15 03:40:21 +00:00
nativeBuildInputs = [ autoconf automake libtool pkg-config bison flex makeWrapper rpcsvc-proto ] ;
2020-08-15 21:54:24 +00:00
2019-10-27 13:03:25 +00:00
makeFlags = [ " D E S T D I R = $ ( o u t ) " ] ;
2014-12-18 10:20:03 +00:00
2017-05-11 16:28:46 +00:00
enableParallelBuilding = true ;
2014-12-18 10:20:03 +00:00
postInstall = ''
cp - r $ out / $ out /* $ o u t
rm - r $ out/nix
2020-12-19 19:14:20 +00:00
'' ;
2017-05-11 14:56:07 +00:00
postFixup = ''
# glusterd invokes `gluster` and other utilities when telling other glusterd nodes to run commands.
# For example for `peer_georep-sshkey` key generation, so `$out/bin` is needed in the PATH.
# It also invokes bash scripts like `gverify.sh`.
# It also invokes executable Python scripts in `$out/libexec/glusterfs`, which is why we set up PYTHONPATH accordingly.
# We set up the paths for the main entry point executables.
2021-01-15 09:19:50 +00:00
GLUSTER_PATH = " ${ lib . makeBinPath runtimePATHdeps } : $ o u t / b i n "
2017-05-11 14:56:07 +00:00
GLUSTER_PYTHONPATH = " $ ( t o P y t h o n P a t h $ o u t ) : $ o u t / l i b e x e c / g l u s t e r f s "
GLUSTER_LD_LIBRARY_PATH = " $ o u t / l i b "
wrapProgram $ out/bin/glusterd - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/bin/gluster - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/sbin/mount.glusterfs - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
# Set Python environment for the Python based utilities.
# It would be nice if there was a better way to do this, automatically for all of them.
# Also, this is brittle: If we forget a dependency or gluster adds a new one, things will break deep inside gluster.
# We should better try to get an explicit list of Python dependencies from gluster and ensure all of them are in the PYTHONPATH of all these python scripts.
# But at the time of writing (gluster 3.10), gluster only provides this in form of a gluster.spec file for RPM creation,
# and even that one is not complete (for example it doesn't mention the `flask` dependency).
wrapProgram $ out/bin/gluster-eventsapi - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/bin/gluster-georep-sshkey - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/bin/gluster-mountbroker - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/bin/glusterfind - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
# Note that we only wrap the symlinks in $out/bin, not the actual executable scripts in $out/libexec/glusterfs.
# This is because those scripts use `__file__` in their program logic
# (see https://github.com/gluster/glusterfs/blob/v3.10.1/extras/cliutils/cliutils.py#L116)
# which would break if we changed the file name (which is what `wrapProgram` does).
# Luckily, `libexec` scripts are never supposed to be invoked straight from PATH,
# instead they are invoked directly from `gluster` or `glusterd`, which is why it is
# sufficient to set PYTHONPATH for those executables.
2017-09-08 02:19:59 +00:00
#
# Exceptions to these rules are the `glusterfind` `brickfind.py` and `changelog.py`
# crawlers, which are directly invoked on other gluster nodes using a remote SSH command
# issues by `glusterfind`.
2017-05-11 14:56:07 +00:00
wrapProgram $ out/share/glusterfs/scripts/eventsdash.py - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
2017-09-08 02:19:59 +00:00
wrapProgram $ out/libexec/glusterfs/glusterfind/brickfind.py - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
wrapProgram $ out/libexec/glusterfs/glusterfind/changelog.py - - set PATH " $ G L U S T E R _ P A T H " - - set PYTHONPATH " $ G L U S T E R _ P Y T H O N P A T H " - - set LD_LIBRARY_PATH " $ G L U S T E R _ L D _ L I B R A R Y _ P A T H "
2020-12-19 19:14:20 +00:00
'' ;
2017-05-11 14:56:07 +00:00
doInstallCheck = true ;
# Below we run Python programs. That generates .pyc/.pyo files.
# By default they are indeterministic because such files contain time stamps
# (see https://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html).
# So we use the same environment variables as in
# https://github.com/NixOS/nixpkgs/blob/249b34aadca7038207492f29142a3456d0cecec3/pkgs/development/interpreters/python/mk-python-derivation.nix#L61
# to make these files deterministic.
# A general solution to this problem might be brought by #25707.
DETERMINISTIC_BUILD = 1 ;
PYTHONHASHSEED = 0 ;
installCheckPhase = ''
# Tests that the above programs work without import errors.
# For testing it manually in a shell you may want to substitute `$out` with `$(dirname $(readlink -f $(which gluster)))/../`.
$ out/bin/glusterd - - help
# $out/bin/gluster help # can't do this because even `gluster help` tries to write to `/var/log/glusterfs/cli.log`
$ out/bin/gluster-eventsapi - - help
$ out/bin/gluster-georep-sshkey - - help
$ out/bin/gluster-mountbroker - - help
$ out/bin/glusterfind - - help
# gfid_to_path.py doesn't accept --help, and it requires different arguments
# (a dir as single argument) than the usage prints when stdin is not a TTY.
# The `echo ""` is just so that stdin is not a TTY even if you try this line
# on a real TTY for testing purposes.
echo " " | ( mkdir - p nix-test-dir-for-gfid_to_path && touch b && $ out/libexec/glusterfs/gfind_missing_files/gfid_to_path.py nix-test-dir-for-gfid_to_path )
$ out/share/glusterfs/scripts/eventsdash.py - - help
2019-08-16 21:27:30 +00:00
# this gets falsely loaded as module by glusterfind
rm - r $ out/bin/conf.py
2021-10-23 21:23:45 +00:00
'' ;
2014-12-18 10:20:03 +00:00
2021-12-30 13:44:54 +00:00
passthru . tests = {
glusterfs = nixosTests . glusterfs ;
} ;
2021-01-11 07:54:33 +00:00
meta = with lib ; {
2009-08-31 09:52:01 +00:00
description = " D i s t r i b u t e d s t o r a g e s y s t e m " ;
2020-03-22 14:13:49 +00:00
homepage = " h t t p s : / / w w w . g l u s t e r . o r g " ;
2018-08-20 18:24:02 +00:00
license = licenses . lgpl3Plus ; # dual licese: choice of lgpl3Plus or gpl2
maintainers = [ maintainers . raskin ] ;
platforms = with platforms ; linux ++ freebsd ;
2009-08-31 09:52:01 +00:00
} ;
}