nixpkgs/pkgs/by-name/oc/ocsinventory-agent/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

107 lines
2.8 KiB
Nix

{ lib
, stdenv
, perlPackages
, fetchFromGitHub
, makeWrapper
, shortenPerlShebang
, coreutils
, dmidecode
, findutils
, inetutils
, ipmitool
, iproute2
, lvm2
, nmap
, pciutils
, usbutils
, util-linux
, nixosTests
, testers
, ocsinventory-agent
, nix-update-script
}:
perlPackages.buildPerlPackage rec {
version = "2.10.1";
pname = "ocsinventory-agent";
src = fetchFromGitHub {
owner = "OCSInventory-NG";
repo = "UnixAgent";
rev = "refs/tags/v${version}-MAC";
hash = "sha256-aFzBrUsVttUhpYGEYd/yYuXmE90PGCiBmBsVjtHcHLg=";
};
nativeBuildInputs = [ makeWrapper ] ++ lib.optional stdenv.hostPlatform.isDarwin shortenPerlShebang;
buildInputs = with perlPackages; [
perl
DataUUID
IOCompress
IOSocketSSL
LWP
LWPProtocolHttps
NetIP
NetNetmask
NetSNMP
ParseEDID
ProcDaemon
ProcPIDFile
XMLSimple
] ++ lib.optionals stdenv.hostPlatform.isLinux (with perlPackages; [
NetCUPS # cups-filters is broken on darwin
]) ++ lib.optionals stdenv.hostPlatform.isDarwin (with perlPackages; [
MacSysProfile
]);
postInstall = let
runtimeDependencies = [
coreutils # uname, cut, df, stat, uptime
findutils # find
inetutils # ifconfig
ipmitool # ipmitool
nmap # nmap
pciutils # lspci
] ++ lib.optionals stdenv.hostPlatform.isLinux [
dmidecode # dmidecode
iproute2 # ip
lvm2 # pvs
usbutils # lsusb
util-linux # last, lsblk, mount
];
in lib.optionalString stdenv.hostPlatform.isDarwin ''
shortenPerlShebang $out/bin/ocsinventory-agent
'' + ''
wrapProgram $out/bin/ocsinventory-agent --prefix PATH : ${lib.makeBinPath runtimeDependencies}
'';
passthru = {
tests = {
inherit (nixosTests) ocsinventory-agent;
version = testers.testVersion {
package = ocsinventory-agent;
command = "ocsinventory-agent --version";
# upstream has not updated version in lib/Ocsinventory/Agent/Config.pm
version = "2.10.0";
};
};
updateScript = nix-update-script { };
};
meta = with lib; {
description = "OCS Inventory unified agent for Unix operating systems";
longDescription = ''
Open Computers and Software Inventory (OCS) is an application designed
to help a network or system administrator to keep track of the hardware and
software configurations of computers that are installed on the network.
'';
homepage = "https://ocsinventory-ng.org";
changelog = "https://github.com/OCSInventory-NG/UnixAgent/releases/tag/v${version}";
downloadPage = "https://github.com/OCSInventory-NG/UnixAgent/releases";
license = licenses.gpl2Only;
mainProgram = "ocsinventory-agent";
maintainers = with maintainers; [ totoroot anthonyroussel ];
platforms = platforms.unix;
};
}