evdev-proto: init at 6.0

FreeBSD implements Linux's evdev API, but doesn't come with headers
for it.  Instead, the Linux headers are just modified to be suitable
for FreeBSD, via a port called evdev-proto.  I don't want to copy the
complicated sed expressions from the port into Nixpkgs, so instead we
just build and install the port inside a Nix derivation.
This commit is contained in:
Alyssa Ross 2023-01-14 18:53:47 +00:00
parent eaf77e7b0b
commit 079e593d72
No known key found for this signature in database
GPG Key ID: F9DBED4859B271C0
3 changed files with 72 additions and 1 deletions

View File

@ -2,7 +2,7 @@
, makeScopeWithSplicing, generateSplicesForMkScope
, buildPackages
, bsdSetupHook, makeSetupHook
, fetchgit, fetchurl, coreutils, groff, mandoc, byacc, flex, which, m4, gawk, substituteAll, runtimeShell
, fetchgit, fetchzip, coreutils, groff, mandoc, byacc, flex, which, m4, gawk, substituteAll, runtimeShell
, zlib, expat, libmd
, runCommand, writeShellScript, writeText, symlinkJoin
}:
@ -75,6 +75,11 @@ in makeScopeWithSplicing
in {
inherit freebsdSrc;
ports = fetchzip {
url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
};
# Why do we have splicing and yet do `nativeBuildInputs = with self; ...`?
# See note in ../netbsd/default.nix.

View File

@ -0,0 +1,64 @@
{ lib, stdenv, linuxHeaders, freebsd, runCommandCC, buildPackages }:
stdenv.mkDerivation {
pname = "evdev-proto";
inherit (linuxHeaders) version;
src = freebsd.ports;
sourceRoot = "source/devel/evdev-proto";
useTempPrefix = true;
nativeBuildInputs = [ freebsd.makeMinimal ];
ARCH = freebsd.makeMinimal.MACHINE_ARCH;
OPSYS = "FreeBSD";
_OSRELEASE = "${lib.versions.majorMinor freebsd.makeMinimal.version}-RELEASE";
AWK = "awk";
CHMOD = "chmod";
FIND = "find";
MKDIR = "mkdir -p";
PKG_BIN = "${buildPackages.pkg}/bin/pkg";
RM = "rm -f";
SED = "${buildPackages.freebsd.sed}/bin/sed";
SETENV = "env";
SH = "sh";
TOUCH = "touch";
XARGS = "xargs";
ABI_FILE = runCommandCC "abifile" {} "$CC -shared -o $out";
CLEAN_FETCH_ENV = true;
INSTALL_AS_USER = true;
NO_CHECKSUM = true;
NO_MTREE = true;
SRC_BASE = freebsd.freebsdSrc;
preUnpack = ''
export MAKE_JOBS_NUMBER="$NIX_BUILD_CORES"
export DISTDIR="$PWD/distfiles"
export PKG_DBDIR="$PWD/pkg"
export PREFIX="$prefix"
mkdir -p "$DISTDIR/evdev-proto"
tar -C "$DISTDIR/evdev-proto" \
-xf ${linuxHeaders.src} \
--strip-components 4 \
linux-${linuxHeaders.version}/include/uapi/linux
'';
makeFlags = [ "DIST_SUBDIR=evdev-proto" ];
postInstall = ''
mv $prefix $out
'';
meta = with lib; {
description = "Input event device header files for FreeBSD";
maintainers = with maintainers; [ qyliss ];
platforms = platforms.freebsd;
license = licenses.gpl2Only;
};
}

View File

@ -25422,6 +25422,8 @@ with pkgs;
erofs-utils = callPackage ../os-specific/linux/erofs-utils { };
evdev-proto = callPackage ../os-specific/bsd/freebsd/evdev-proto { };
fscryptctl = callPackage ../os-specific/linux/fscryptctl { };
# unstable until the first 1.x release
fscrypt-experimental = callPackage ../os-specific/linux/fscrypt { };