2023-09-19 09:28:30 +00:00
|
|
|
{ addOpenGLRunpath
|
|
|
|
, cmake
|
2023-11-21 00:21:33 +00:00
|
|
|
, allowedPatternsPath ? callPackage ./closure.nix { inherit allowedPatterns; }
|
2023-09-19 09:28:30 +00:00
|
|
|
, allowedPatterns ? rec {
|
2023-11-11 02:40:44 +00:00
|
|
|
# This config is just an example.
|
|
|
|
# When the hook observes either of the following requiredSystemFeatures:
|
2023-11-11 14:02:54 +00:00
|
|
|
nvidia-gpu.onFeatures = [ "gpu" "nvidia-gpu" "opengl" "cuda" ];
|
2023-11-11 02:40:44 +00:00
|
|
|
# It exposes these paths in the sandbox:
|
|
|
|
nvidia-gpu.paths = [
|
2023-09-19 09:28:30 +00:00
|
|
|
addOpenGLRunpath.driverLink
|
|
|
|
"/dev/dri"
|
|
|
|
"/dev/nvidia*"
|
|
|
|
];
|
2023-11-11 19:43:04 +00:00
|
|
|
nvidia-gpu.unsafeFollowSymlinks = true;
|
2023-09-19 09:28:30 +00:00
|
|
|
}
|
|
|
|
, buildPackages
|
2023-11-21 00:21:33 +00:00
|
|
|
, callPackage
|
2023-11-21 16:03:58 +00:00
|
|
|
, extraWrapperArgs ? [ ]
|
2023-09-19 09:28:30 +00:00
|
|
|
, formats
|
|
|
|
, lib
|
2023-11-21 16:03:58 +00:00
|
|
|
, makeWrapper
|
2023-09-19 09:28:30 +00:00
|
|
|
, nix
|
2023-11-06 16:44:36 +00:00
|
|
|
, nixosTests
|
2023-10-18 09:44:59 +00:00
|
|
|
, python3Packages
|
2023-09-19 09:28:30 +00:00
|
|
|
, runCommand
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
|
|
let
|
2023-11-06 17:21:47 +00:00
|
|
|
attrs = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
|
|
|
pname = attrs.project.name;
|
|
|
|
inherit (attrs.project) version;
|
2023-09-19 09:28:30 +00:00
|
|
|
in
|
|
|
|
|
2023-11-06 17:21:47 +00:00
|
|
|
python3Packages.buildPythonApplication
|
2023-09-19 09:28:30 +00:00
|
|
|
{
|
2023-11-06 17:21:47 +00:00
|
|
|
inherit pname version;
|
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
src = lib.cleanSource ./.;
|
|
|
|
|
2023-10-18 09:44:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
2023-11-06 17:21:47 +00:00
|
|
|
python3Packages.setuptools
|
2023-10-18 09:44:59 +00:00
|
|
|
];
|
2023-11-06 17:21:47 +00:00
|
|
|
|
|
|
|
postFixup = ''
|
2023-11-20 01:17:42 +00:00
|
|
|
wrapProgram $out/bin/${pname} \
|
|
|
|
--add-flags "--patterns ${allowedPatternsPath}" \
|
2023-11-21 16:03:58 +00:00
|
|
|
--add-flags "--nix-exe ${lib.getExe nix}" \
|
|
|
|
${builtins.concatStringsSep " " extraWrapperArgs}
|
2023-11-06 17:21:47 +00:00
|
|
|
'';
|
|
|
|
|
2023-11-06 16:44:14 +00:00
|
|
|
passthru = {
|
|
|
|
inherit allowedPatterns;
|
2023-11-06 16:44:36 +00:00
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) nix-required-mounts;
|
|
|
|
};
|
2023-11-06 16:44:14 +00:00
|
|
|
};
|
2023-11-06 17:21:47 +00:00
|
|
|
meta = {
|
|
|
|
inherit (attrs.project) description;
|
|
|
|
homepage = attrs.project.urls.Homepage;
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
mainProgram = attrs.project.name;
|
|
|
|
maintainers = with lib.maintainers; [ SomeoneSerge ];
|
|
|
|
};
|
|
|
|
}
|