diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 62c4961e2077..6c1990d0ffa2 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -23008,6 +23008,12 @@ githubId = 2049686; name = "Sebastián Estrella"; }; + seven_bear = { + name = "Edmond Freeman"; + email = "edmondfreeman7@gmail.com"; + github = "yueneiqi"; + githubId = 26707756; + }; seylerius = { name = "Sable Seyler"; email = "sable@seyleri.us"; diff --git a/pkgs/by-name/co/collectl/0001-scripts-external-executable-calls.patch b/pkgs/by-name/co/collectl/0001-scripts-external-executable-calls.patch new file mode 100644 index 000000000000..bfd75ba0627b --- /dev/null +++ b/pkgs/by-name/co/collectl/0001-scripts-external-executable-calls.patch @@ -0,0 +1,444 @@ +Processing diff for: collectl.conf +--- a/collectl.conf 2025-08-14 08:42:24.434419733 +0000 ++++ b/collectl.conf 2025-08-16 07:56:13.806350456 +0000 +@@ -43,7 +43,7 @@ + #Ps = /bin/ps + #Rpm = /bin/rpm + #Lspci = /sbin/lspci +-#Lctl = /usr/sbin/lctl ++#Lctl = /usr/sbin/lctl # disabled since collectl 4.0.4 + + # I n f i n i b a n d S u p p o r t + +@@ -55,10 +55,11 @@ + # variable below. PQuery for OFED, PCounter for get_pcounter calls and + # VStat for ALL non-ofed access of any kind. + # can disable either by commenting out the reference to VStat/PQuery below. +-PQuery = /usr/sbin/perfquery:/usr/bin/perfquery:/usr/local/ofed/bin/perfquery +-PCounter = /usr/mellanox/bin/get_pcounter +-VStat = /usr/mellanox/bin/vstat:/usr/bin/vstat +-OfedInfo = /usr/bin/ofed_info:/usr/local/ofed/bin/ofed_info ++# Disable the Infiniband support by default ++# PQuery = /usr/sbin/perfquery:/usr/bin/perfquery:/usr/local/ofed/bin/perfquery ++# PCounter = /usr/mellanox/bin/get_pcounter ++# VStat = /usr/mellanox/bin/vstat:/usr/bin/vstat ++# OfedInfo = /usr/bin/ofed_info:/usr/local/ofed/bin/ofed_info + + # D e f a u l t s + +@@ -116,7 +117,7 @@ + # size, comment out the Resize line and uncomment TermHeight, setting it to + # what you want. + #TermHeight = 24 +-Resize=/usr/bin/resize:/usr/X11R6/bin/resize ++Resize=@resize@ + + # To turn off Time:HiRes/glibc incompatibility checking, the following + # should be enabled and set to 0 +@@ -125,7 +126,7 @@ + # These control environmental monitoring and to use it you MUST have ipmitool + # installed (see http://ipmitool.sourceforge.net/). If not in the path shown + # below, you must change it. +-Ipmitool = /usr/bin/ipmitool:/usr/local/bin/ipmitool:/opt/hptc/sbin/ipmitool ++Ipmitool = @ipmitool@ + IpmiCache = /var/run/collectl-ipmicache + IpmiTypes = fan,temp,current + +Processing diff for: collectl +--- a/collectl 2025-08-14 08:42:24.434419733 +0000 ++++ b/collectl 2025-08-16 09:25:20.238548613 +0000 +@@ -69,14 +69,14 @@ + use IO::Select; + use Cwd 'abs_path'; + +-$Cat= '/bin/cat'; +-$Grep= '/bin/grep'; +-$Egrep= '/bin/egrep'; +-$Ps= '/bin/ps'; +-$Rpm= '/bin/rpm'; +-$Lspci= '/sbin/lspci'; +-$Lctl= '/usr/sbin/lctl'; +-$Dmidecode= '/usr/sbin/dmidecode'; ++$Cat= '@cat@'; ++$Grep= '@grep@'; ++$Egrep= '@egrep@'; ++$Ps= '@ps@'; ++$Rpm= '@rpm@'; ++$Lspci= '@lspci@'; ++$Lctl= '/usr/sbin/lctl'; # disabled since collectl 4.0.4 ++$Dmidecode= '@dmidecode@'; + + %TopProcTypes=qw(vsz '' rss '' syst '' usrt '' time '' accum '' rkb '' wkb '' iokb '' + rkbc '' wkbc '' iokbc '' ioall '' rsys '' wsys '' iosys '' +@@ -108,7 +108,7 @@ + $syslogFlag=(eval {require "Sys/Syslog.pm" or die}) ? 1 : 0; + + # Always nice to know if we're root +-$rootFlag=(!$PcFlag && `whoami`=~/root/) ? 1 : 0; ++$rootFlag=(!$PcFlag && `@whoami@`=~/root/) ? 1 : 0; + $SrcArch= $Config{"archname"}; + + $Version= '4.3.20'; +@@ -126,15 +126,15 @@ + # we're in the background. We also need to know if STDOUT connected to a terminal. + if (!$PcFlag) + { +- $MyDir=`pwd`; +- $Cat= 'cat'; ++ $MyDir=`@pwd@`; ++ $Cat= '@cat@'; + $Sep= '/'; + $backFlag=(getpgrp()!=tcgetpgrp(0)) ? 1 : 0; + $termFlag= (-t STDOUT) ? 1 : 0; + } + else + { +- $MyDir=`cd`; ++ $MyDir=`@cd@`; + $Cat= 'type'; + $Sep= '\\'; + $backFlag=0; +@@ -148,7 +148,7 @@ + # which was recorded with the data file and WILL override in playback mode. + # We also need our host name before calling initRecord() so we can log it at + # startup as well as for naming the logfile. +-$myHost=($PcFlag) ? `hostname` : `/bin/hostname`; ++$myHost=($PcFlag) ? `@hostname@` : `@hostname@`; + $myHost=(split(/\./, $myHost))[0]; + chomp $myHost; + $Host=$myHost; +@@ -509,12 +509,12 @@ + + if ($runasUser!~/^\d+$/) + { +- $runasUid=(split(/:/, `grep ^$runasUser: /etc/passwd`))[2]; ++ $runasUid=(split(/:/, `@grep@ ^$runasUser: /etc/passwd`))[2]; + error("can't find '$runasUser' in /etc/passwd. Consider UID.") if !defined($runasUid); + } + if (defined($runasGroup) && $runasGroup!~/^\d+$/) + { +- $runasGid=(split(/:/, `grep ^$runasGroup: /etc/group`))[2]; ++ $runasGid=(split(/:/, `@grep@ ^$runasGroup: /etc/group`))[2]; + error("can't find '$runasGroup' in /etc/group. Consider GID.") if !defined($runasGid); + } + $runasUid=$runasUser if $runasUser=~/^\d+/; +@@ -1167,19 +1167,19 @@ + if (!$PcFlag) + { + # This matches THIS host, but in playback mode will be reset to the target +- $Kernel=`uname -r`; ++ $Kernel=`@uname@ -r`; + chomp $Kernel; + error("collectl no longer supports 2.4 kernels") if $Kernel=~/^2\.4/; + +- $LocalTimeZone=`date +%z`; ++ $LocalTimeZone=`@date@ +%z`; + chomp $LocalTimeZone; + + # Some distros put lspci in /usr/sbin and others in /usr/bin, so take one last look in + # those before complaining, but only if in record mode AND only if looking at interconnects + if (!-e $Lspci && $playback eq '' && $subsys=~/x/i) + { +- $Lspci=(-e '/usr/sbin/lspci') ? '/usr/sbin/lspci' : '/usr/bin/lspci'; +- if (!-e "/usr/sbin/lspci" && !-e "/usr/bin/lspci") ++ $Lspci='@lspci@'; ++ if (!-e "@lspci@") + { + pushmsg('W', "-sx disabled because 'lspci' not in $Lspci or '/usr/sbin' or '/usr/bin'"); + pushmsg('W', "If somewhere else, move it or define in collectl.conf"); +@@ -1274,7 +1274,7 @@ + # it further on so not to worry, but at least record a warning. + $pid=`$Cat $PidFile`; + chomp $pid; +- @ps=`ps axo pid,command`; ++ @ps=`@ps@ axo pid,command`; + foreach my $line (@ps) + { + $line=~s/^\s+//; # trim leading whitespace for short pids +@@ -1551,14 +1551,14 @@ + } + + # if -N, set priority to 20 +-`renice 20 $$` if $niceFlag; ++`@renice@ 20 $$` if $niceFlag; + + # Couldn't find anywhere else to put this one... + error("-sT only works with -P for now (too much data)") + if $TFlag && !$plotFlag; + + # get parent pid so we can check later to see it still there +-$stat=`cat /proc/$$/stat`; ++$stat=`@cat@ /proc/$$/stat`; + $myPpid=(split(/\s+/, $stat))[3]; + + ############################### +@@ -2311,7 +2311,7 @@ + printBriefCounters('T'); + } + +- `stty echo` if !$PcFlag && $termFlag && !$backFlag; # in brief mode, we turned it off ++ `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; # in brief mode, we turned it off + my $temp=(!$msgFlag) ? ' Try again with -m.' : ''; + print "No files selected contain the selected data.$temp\n" if !$numProcessed; + exit(0); +@@ -2453,7 +2453,7 @@ + open STDIN, '/dev/null' or logmsg("F", "Can't read /dev/null: $!"); + open STDOUT, '>/dev/null' or logmsg("F", "Can't write to /dev/null: $!"); + open STDERR, '>/dev/null' or logmsg("F", "Can't write to /dev/null: $!"); +- `echo $$ > $PidFile`; ++ `@echo@ $$ > $PidFile`; + + # Now that we're set up to start, if '--runas' has been sprecified we need to do a + # few things that require privs before actually changing our UID. Also note the +@@ -2469,8 +2469,8 @@ + $logname=(-d $filename) ? $filename : dirname($filename); + $logname.="/$myHost-collectl-$yymm.log"; + +- `chown $runasUid $logname`; +- `chgrp $runasGid $logname` if defined($runasGid); ++ `@chown@ $runasUid $logname`; ++ `@chgrp@ $runasGid $logname` if defined($runasGid); + + # now we can change our process's ownership taking care to do the group first + # since we won't be able to change anything once we change our UID. +@@ -3244,7 +3244,7 @@ + # close logs cleanly and turn echo back on because when 'brief' we turned it off. + closeLogs($subsys); + unlink $PidFile if $daemonFlag; +-`stty echo` if !$PcFlag && $termFlag && !$backFlag; ++`@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; + + # clean up when in pure top mode + if ($numTop && !$topVertFlag) +@@ -4350,7 +4350,7 @@ + if (!-e $temp) + { + logmsg('W', "Creating directory '$temp'"); +- `mkdir $temp`; ++ `@mkdir@ $temp`; + } + + # track number of times same file processed, primarily for options 'a/c'. in +@@ -5363,7 +5363,7 @@ + + # build up the search list being extra neat and leaving + # off possible duplicate /etc +- $configFile="$BinDir/$ConfigFile;$etcDir/$ConfigFile"; ++ $configFile="$BinDir/../etc/$ConfigFile;$etcDir/$ConfigFile"; + $configFile.=";/etc/$ConfigFile" if $etcDir ne '/etc'; + } + print "Config File Search Path: $configFile\n" if $debug & 1; +@@ -5789,7 +5789,7 @@ + # what gets stored in /proc/XXX/stat and to make sure we look at the same + # values dynamically as well as staticly, we better pull cmd from the stat + # file itself. +- @ps=`ps axo pid,ppid,uid,comm,user`; ++ @ps=`@ps@ axo pid,ppid,uid,comm,user`; + my $firstFilePass=1; + foreach $process (@ps) + { +@@ -6228,7 +6228,7 @@ + $briefFlag=0; + $verboseFlag=1; + intervalPrint(time); +- `stty echo` if !$PcFlag && $termFlag && !$backFlag; ++ `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; + } + + sub error +@@ -6241,7 +6241,7 @@ + # printText() will try to send error over socket and we want it local. + $sockFlag=0 if $serverFlag; + +- `stty echo` if !$PcFlag && $termFlag && !$backFlag; ++ `@stty@ echo` if !$PcFlag && $termFlag && !$backFlag; + logmsg("F", "Error: $text") if $daemonFlag; + + # we can only call printText() when formatit loaded. +Processing diff for: colmux +--- a/colmux 2025-08-14 08:42:24.438419919 +0000 ++++ b/colmux 2025-08-15 07:38:22.003168089 +0000 +@@ -78,7 +78,7 @@ + my $License="colmux may be copied only under the terms of either the Artistic License\n"; + $License.= "or the GNU General Public License, which may be found in the source kit"; + +-my $Ping='/bin/ping'; ++my $Ping='@ping@'; + my $ResizePath='/usr/bin/resize:/usr/X11R6/bin/resize'; + my $Route='/sbin/route'; + my $Ifconfig='/sbin/ifconfig'; +@@ -235,7 +235,7 @@ + $Collectl="sudo $Collectl" if $sudoFlag; + + # ok if host not in known_hosts and when not debugging be sure to turn off motd +-my $Ssh='/usr/bin/ssh -o StrictHostKeyChecking=no -o BatchMode=yes'; ++my $Ssh='@ssh@ -o StrictHostKeyChecking=no -o BatchMode=yes'; + $Ssh.=" -o ServerAliveInterval=$keepalive" if $keepalive ne ''; + $Ssh.=" -q" unless $debug; + +@@ -357,7 +357,7 @@ + # See if any host specs contain 'username@' & reset 'localhost' and + # adjust maximum hostname length if necessary. + my $hostlen=$hostWidth; +-my $myhost=`hostname`; ++my $myhost=`@hostname@`; + chomp $myhost; + + my (%usernames, %sshswitch, %aliases); +@@ -510,7 +510,7 @@ + $line=~s/^\s+//; # can have leading space + my $pid=(split(/\s+/, $line))[0]; + print "Killing ssh with pid: $pid\n" if $debug & 1; +- `kill $pid`; ++ `@kill@ $pid`; + } + sleep 1; # wait a tad for ssh in thread to exit + close PS; +@@ -983,7 +983,7 @@ + $line=~s/^\s+//; + my $pid=(split(/\s+/, $line))[0]; + print "Killing ssh with pid: $pid\n" if $debug & 1; +- `kill $pid`; ++ `@kill@ $pid`; + } + } + +@@ -1179,7 +1179,7 @@ + foreach my $host (keys %files) + { + print "Killing pid $files{$host}->{pid} for '$host'\n" if $debug & 1; +- `kill -9 $files{$host}->{pid}`; ++ `@kill@ -9 $files{$host}->{pid}`; + #close $files{$host}->{fd} or error("Failed to close playback file for '$host'"); + } + +Processing diff for: formatit.ph +--- a/formatit.ph 2025-08-14 08:42:24.438419919 +0000 ++++ b/formatit.ph 2025-08-15 07:18:19.548190580 +0000 +@@ -20,19 +20,19 @@ + $rawPFlag=0; # always 0 when no files involved + + # In some case, we need to know if we're root. +- $rootFlag=`whoami`; ++ $rootFlag=`@whoami@`; + $rootFlag=($rootFlag=~/root/) ? 1 : 0; + + # be sure to remove domain portion if present. also note we keep the hostname in + # two formats, one in it's unaltered form (at least needed by lustre directory + # parsing) as well as all lc because it displays nicer. +- $Host=`hostname`; ++ $Host=`@hostname@`; + chomp $Host; + $Host=(split(/\./, $Host))[0]; + $HostLC=lc($Host); + + # when was system booted? +- $uptime=(split(/\s+/, `cat /proc/uptime`))[0]; ++ $uptime=(split(/\s+/, `@cat@ /proc/uptime`))[0]; + $boottime=time-$uptime; + + $Distro=cat('/etc/redhat-release') if -e '/etc/redhat-release'; +@@ -83,11 +83,11 @@ + if ($subsys=~/y/i && $slabinfoFlag || $slubinfoFlag) + { + $message=''; +- $message='/proc/slabinfo' if $slabinfoFlag && !(eval {`cat /proc/slabinfo 2>/dev/null` or die}); +- $message='/sys/slab' if $slubinfoFlag && !(eval {`cat /proc/slubinfo 2>/dev/null` or die}); ++ $message='/proc/slabinfo' if $slabinfoFlag && !(eval {`@cat@ /proc/slabinfo 2>/dev/null` or die}); ++ $message='/sys/slab' if $slubinfoFlag && !(eval {`@cat@ /proc/slubinfo 2>/dev/null` or die}); + if ($message ne '') + { +- my $whoami=`whoami`; ++ my $whoami=`@whoami@`; + chomp $whoami; + disableSubsys('y', "/proc/slabinfo is not readable by $whoami"); + $interval=~s/(^\d*):\d+/$1:/ if $subsys!~/z/i; # remove int2 if not needed or we'll get error +@@ -132,7 +132,7 @@ + + for (my $i=1; $i<$NumCpus; $i++) + { +- my $online=`cat /sys/devices/system/cpu/cpu$i/online`; ++ my $online=`@cat@ /sys/devices/system/cpu/cpu$i/online`; + chomp $online; + + $cpuEnabled[$i]=$online; +@@ -266,7 +266,7 @@ + $ibSpeed='??'; + if (-e '/sys/class/infiniband') + { +- $line=`cat /sys/class/infiniband/*/ports/1/rate 2>&1`; ++ $line=`@cat@ /sys/class/infiniband/*/ports/1/rate 2>&1`; + if ($line=~/\s*(\d+)\s+(\S)/) + { + $ibSpeed=$1; +@@ -669,7 +669,7 @@ + { + # Get Luster and SFS Versions before looking at any data structures in the + # 'lustreCheck' routines because things change over time +- $temp=`cat /proc/fs/lustre/version | grep lustre 2>/dev/null`; ++ $temp=`@cat@ /proc/fs/lustre/version | grep lustre 2>/dev/null`; + $temp=~/lustre: (\d+.*)/; + $cfsVersion=$1; + $sfsVersion=''; +@@ -716,7 +716,7 @@ + # The first step is to build up a hash of the sizes of all the + # existing partitions. Since we're only doing this once, a 'cat's + # overhead should be minimal +- @partitions=`cat /proc/partitions`; ++ @partitions=`@cat@ /proc/partitions`; + foreach $part (@partitions) + { + # ignore blank lines and header +@@ -778,7 +778,7 @@ + $temp=`head -n 1 /proc/slabinfo`; + $temp=~/(\d+\.\d+)/; + $SlabVersion=$1; +- $NumSlabs=`cat /proc/slabinfo | wc -l`*1; ++ $NumSlabs=`@cat@ /proc/slabinfo | wc -l`*1; + chomp $NumSlabs; + $NumSlabs-=2; + +@@ -4127,7 +4127,7 @@ + $netSpeeds{$netName}='??'; + if ($line ne '') + { +- $speed=`cat $line 2>&1`; ++ $speed=`@cat@ $line 2>&1`; + chomp $speed; + $line=~/.*\/(\S+)\/speed/; + my $netName=$1; +Processing diff for: graphite.ph +--- a/graphite.ph 2025-08-14 08:42:24.442420106 +0000 ++++ b/graphite.ph 2025-08-14 08:44:07.351625049 +0000 +@@ -117,7 +117,7 @@ + # behavior for -f logs matches that of -A + $rawtooFlag=1 if $filename ne '' && !$plotFlag; + +- $graphiteMyHost=(!$graphiteFqdnFlag) ? `hostname` : `hostname -f`; ++ $graphiteMyHost=(!$graphiteFqdnFlag) ? `@hostname@` : `@hostname@ -f`; + chomp $graphiteMyHost; + $graphiteMyHost =~ s/\./$graphiteEscape/g if $graphiteEscape ne ''; + +Processing diff for: vmsum.ph +--- a/vmsum.ph 2025-08-14 08:42:24.442420106 +0000 ++++ b/vmsum.ph 2025-08-14 08:44:24.184414112 +0000 +@@ -20,8 +20,8 @@ + my $oneMB=1024*1024; + my ($debug, $helpFlag, $instMin, $versionFlag, $zeroFlag); + +-my $Ssh= '/usr/bin/ssh'; +-my $Ping='/bin/ping'; ++my $Ssh= '@ssh@'; ++my $Ping='@ping@'; + my $PingTimeout=1; + + # these control writing the vm text file +@@ -32,7 +32,7 @@ + + my $lexprFlag=0; + my $noNetMsg=''; # if not null, problem with n/w stats (very rare) +-my $hostname=`hostname`; ++my $hostname=`@hostname@`; + chomp $hostname; + + sub vmsumInit diff --git a/pkgs/by-name/co/collectl/0002-fix-install-script.patch b/pkgs/by-name/co/collectl/0002-fix-install-script.patch new file mode 100644 index 000000000000..9cff661782ef --- /dev/null +++ b/pkgs/by-name/co/collectl/0002-fix-install-script.patch @@ -0,0 +1,133 @@ +--- a/INSTALL 2025-08-14 08:46:43.845548078 +0000 ++++ b/INSTALL 2025-08-14 08:50:33.771706783 +0000 +@@ -1,28 +1,29 @@ + #!/bin/sh + +-DESTDIR=${DESTDIR:="/"} ++# Use Nix output directory instead of system paths ++DESTDIR=${out} + +-BINDIR=$DESTDIR/usr/bin +-DOCDIR=$DESTDIR/usr/share/doc/collectl +-SHRDIR=$DESTDIR/usr/share/collectl +-MANDIR=$DESTDIR/usr/share/man/man1 +-SYSDDIR=$DESTDIR/usr/lib/systemd/system +-ETCDIR=$DESTDIR/etc +-INITDIR=$ETCDIR/init.d ++BINDIR=$out/bin ++DOCDIR=$out/share/doc/collectl ++SHRDIR=$out/share/collectl ++MANDIR=$out/share/man/man1 ++SYSDDIR=$out/lib/systemd/system ++ETCDIR=$out/etc ++INITDIR=$out/etc/init.d + + mkdir -p $BINDIR + mkdir -p $DOCDIR + mkdir -p $SHRDIR + mkdir -p $ETCDIR + mkdir -p $MANDIR +-mkdir -p $INITDIR ++# Skip init.d creation for Nix + mkdir -p $SHRDIR/util + mkdir -p $DESTDIR/var/log/collectl + + cp collectl colmux $BINDIR + cp collectl.conf $ETCDIR + cp man1/* $MANDIR +-cp initd/* $INITDIR ++# Skip init scripts for Nix + + cp docs/* $DOCDIR + cp GPL ARTISTIC COPYING $DOCDIR +@@ -42,87 +43,12 @@ + # Force in case redoing the install and files already zipped + gzip -f $MANDIR/collectl* + +-chmod 755 $INITDIR/collectl* ++# Skip chmod on init scripts for Nix + chmod 444 $ETCDIR/collectl.conf + chmod 755 $BINDIR/collectl + chmod 444 $DOCDIR/ARTISTIC $DOCDIR/COPYING $DOCDIR/GPL + chmod 444 $SHRDIR/*ph + chmod 755 $SHRDIR/util/* + +-# remove any stale versions in case the names/numbers used have changed. +-# on new ROCKS installion 'rm' isn't there yet! [thanks roy] +-if [ -x /bin/rm ] ; then +- /bin/rm -f $INITDIR/rc*.d/*collectl +- /bin/rm -f $ETCDIR/rc.d/rc*.d/*collectl +-fi +- +-# only if systemd is supported +-if [ -d $SYSDDIR ]; then +- cp service/collectl.service $SYSDDIR +-fi +- +-# Try and decide which distro this is based on distro specific files. +-distro=1 +-if [ -f /sbin/yast ]; then +- distro=2 +- mv -f $INITDIR/collectl-suse $INITDIR/collectl +- rm -f $INITDIR/collectl-debian +- rm -f $INITDIR/collectl-generic +-fi +- +-# debian +-if [ -f /usr/sbin/update-rc.d ]; then +- distro=3 +- mv -f $INITDIR/collectl-debian $INITDIR/collectl +- rm -f $INITDIR/collectl-suse +- rm -f $INITDIR/collectl-generic +- +- # only if we're installing under / +- [ "$DESTDIR" = "/" ] && update-rc.d collectl defaults +-fi +- +-# redhat +-if [ -f /etc/redhat-release ]; then +- distro=4 +- rm -f $INITDIR/collectl-suse +- rm -f $INITDIR/collectl-debian +- rm -f $INITDIR/collectl-generic +- if [ -f /usr/sbin/chkconfig ]; then +- [ "$DESTDIR" = "/" ] && chkconfig --add collectl +- fi +-# Not needed for RHEL8 and higher +-fi +- +-# gentoo +-if [ -f $ETCDIR/gentoo-release ]; then +- distro=5 +- mv -f $INITDIR/collectl-generic $INITDIR/collectl +- rm -f $INITDIR/collectl-suse +- rm -f $INITDIR/collectl-debian +- [ "$DESTDIR" = "/" ] && rc-update -a collectl default +-fi +- +-# Generic Distros +-# If /etc/init.d doesn't exist and/or there's no way to use chkconfig or +-# rc-update you're going to have to add some custom code below... +-if [ ${distro} = 1 ]; then +- +- mv -f $INITDIR/collectl-generic $INITDIR/collectl +- rm -f $INITDIR/collectl-suse +- rm -f $INITDIR/collectl-debian +- +- # If in not installing under / there's nothing extra do +- [ $DESTDIR != "/" ] && exit 0 +- +- # figure out how to handle reboots +- if [ -f /sbin/chkconfig ]; then +- chkconfig --add collectl +- elif [ -f /sbin/rc-update ]; then +- rc-update -a collectl default +-# RHEL9 has no chkconfig +- elif [ -f /usr/bin/systemctl ]; then +- systemctl enable collectl +- else +- echo "could not figure out how to enable restarting across reboots" +- fi +-fi ++# Skip all distro-specific service installation for Nix ++# Nix manages services differently through NixOS modules diff --git a/pkgs/by-name/co/collectl/package.nix b/pkgs/by-name/co/collectl/package.nix new file mode 100644 index 000000000000..df630fdd4d7d --- /dev/null +++ b/pkgs/by-name/co/collectl/package.nix @@ -0,0 +1,126 @@ +{ + callPackage, + lib, + stdenv, + fetchFromGitHub, + replaceVars, + + # Runtime dependencies + coreutils, + dmidecode, + gnugrep, + inetutils, + openssh, + pciutils, + perl, + procps, + rpm, + util-linux, + xterm, + + # Dependencies + ipmitool, +}: + +let + inherit (lib) getExe getExe' genAttrs; + + # Define tool dependencies for script patches + scriptDeps = + let + mkTools = pkg: tools: genAttrs tools (tool: getExe' pkg tool); + in + # Tools from various packages + (mkTools coreutils [ + "cat" + "whoami" + "pwd" + "uname" + "date" + "mkdir" + "chown" + "chgrp" + "echo" + "kill" + "cd" + "stty" + ]) + // (mkTools util-linux [ "renice" ]) + // (mkTools gnugrep [ + "grep" + "egrep" + ]) + // (mkTools inetutils [ + "hostname" + "ping" + ]) + // (mkTools procps [ "ps" ]) + // (mkTools pciutils [ "lspci" ]) + // (mkTools xterm [ "resize" ]) + // (mkTools dmidecode [ "dmidecode" ]) + // (mkTools rpm [ "rpm" ]) + // { + # Single-tool packages + ssh = getExe openssh; + ipmitool = getExe ipmitool; + }; +in + +stdenv.mkDerivation (finalAttrs: { + pname = "collectl"; + version = "4.3.20.1"; + + src = fetchFromGitHub { + owner = "sharkcz"; + repo = "collectl"; + rev = finalAttrs.version; + hash = "sha256-OJGCuxWvoId1cQ5Ugiav5/T/NzddwhM+gG3s0BnYYz0="; + }; + + strictDeps = true; + + patches = [ + (replaceVars ./0001-scripts-external-executable-calls.patch scriptDeps) + ./0002-fix-install-script.patch + ]; + + buildInputs = [ + perl + dmidecode + ipmitool + ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + bash ./INSTALL + + runHook postInstall + ''; + + passthru.tests.run = callPackage ./test.nix { }; + + meta = { + description = "Performance monitoring tool for Linux systems"; + longDescription = '' + Collectl is a light-weight performance monitoring tool capable of reporting + interactively as well as logging to disk. It reports statistics on cpu, disk, + infiniband, lustre, memory, network, nfs, process, quadrics, slabs and more + in easy to read format. + + The `--config` option allows specifying a custom configuration file path, + overriding the default configuration file in the package's etc directory. + ''; + homepage = "https://github.com/sharkcz/collectl"; + downloadPage = "https://github.com/sharkcz/collectl/releases"; + license = with lib.licenses; [ + artistic1 + gpl1Plus + ]; + maintainers = with lib.maintainers; [ seven_bear ]; + platforms = lib.platforms.linux; + mainProgram = "collectl"; + }; +}) diff --git a/pkgs/by-name/co/collectl/test.nix b/pkgs/by-name/co/collectl/test.nix new file mode 100644 index 000000000000..b2bf2fdfd3bf --- /dev/null +++ b/pkgs/by-name/co/collectl/test.nix @@ -0,0 +1,44 @@ +{ + runCommand, + collectl, + coreutils, +}: + +runCommand "collectl-test" + { + nativeBuildInputs = [ + collectl + coreutils + ]; + meta.timeout = 60; + } + '' + # Test basic functionality - limit to 5 seconds to avoid hanging + timeout 5s collectl -c1 >/dev/null || true + + # Test that explicit config file option still works with original config + timeout 5s collectl --config ${collectl}/etc/collectl.conf -c1 >/dev/null || true + + # Test custom config file path override + custom_config_path=$(mktemp) + cp ${collectl}/etc/collectl.conf "$custom_config_path" + + # Test that collectl uses the custom config file path + config_output=$(timeout 5s collectl --config "$custom_config_path" -c1 -d1 2>&1 | grep -i "Config File Search Path:" | head -1) + expected_output="Config File Search Path: $custom_config_path" + + if [ "$config_output" = "$expected_output" ]; then + echo "✓ Custom config file path test passed" + else + echo "✗ Custom config file path test failed" + echo "Expected: $expected_output" + echo "Got: $config_output" + exit 1 + fi + + # Cleanup + rm -f "$custom_config_path" + + # Signal success + touch $out + ''