Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 fetchFromGitLab, 5 autoreconfHook, 6 autoconf-archive, 7 pkg-config, 8 which, 9 flex, 10 bison, 11 withPerl ? 12 stdenv.hostPlatform == stdenv.buildPlatform && lib.meta.availableOn stdenv.hostPlatform perl, 13 perl, 14 withPython ? 15 # static can't load python libraries 16 !stdenv.hostPlatform.isStatic 17 && lib.meta.availableOn stdenv.hostPlatform python3Packages.python 18 # m4 python include script fails if cpu bit depth is different across machines 19 && stdenv.hostPlatform.parsed.cpu.bits == stdenv.buildPlatform.parsed.cpu.bits, 20 python3Packages, 21 swig, 22 ncurses, 23 libxcrypt, 24 25 # test 26 dejagnu, 27 28 # passthru 29 nix-update-script, 30 nixosTests, 31 callPackage, 32}: 33stdenv.mkDerivation (finalAttrs: { 34 pname = "libapparmor"; 35 version = "4.1.1"; 36 37 src = fetchFromGitLab { 38 owner = "apparmor"; 39 repo = "apparmor"; 40 tag = "v${finalAttrs.version}"; 41 hash = "sha256-f9FgowlV4lZKKuddGCirqbajhIGyTUQc7IFHSvqY6eQ="; 42 }; 43 sourceRoot = "${finalAttrs.src.name}/libraries/libapparmor"; 44 45 postPatch = '' 46 substituteInPlace swig/perl/Makefile.am \ 47 --replace-fail install_vendor install_site 48 ''; 49 50 strictDeps = true; 51 52 nativeBuildInputs = [ 53 autoconf-archive 54 autoreconfHook 55 bison 56 flex 57 pkg-config 58 swig 59 ncurses 60 which 61 dejagnu 62 perl # podchecker 63 ] 64 ++ lib.optionals withPython [ 65 python3Packages.setuptools 66 ]; 67 68 nativeCheckInputs = [ 69 python3Packages.pythonImportsCheckHook 70 ]; 71 72 buildInputs = [ 73 libxcrypt 74 ] 75 ++ (lib.optional withPerl perl) 76 ++ (lib.optional withPython python3Packages.python); 77 78 # required to build apparmor-parser 79 dontDisableStatic = true; 80 81 # https://gitlab.com/apparmor/apparmor/issues/1 82 configureFlags = [ 83 (lib.withFeature withPerl "perl") 84 (lib.withFeature withPython "python") 85 ]; 86 87 doCheck = withPerl && withPython; 88 89 checkInputs = [ dejagnu ]; 90 91 pythonImportsCheck = [ 92 "LibAppArmor" 93 ]; 94 95 passthru = { 96 updateScript = nix-update-script { }; 97 tests.nixos = nixosTests.apparmor; 98 apparmorRulesFromClosure = callPackage ./apparmorRulesFromClosure.nix { }; 99 }; 100 101 meta = { 102 homepage = "https://apparmor.net/"; 103 description = "Mandatory access control system - core library"; 104 license = with lib.licenses; [ 105 gpl2Only 106 lgpl21Only 107 ]; 108 maintainers = lib.teams.apparmor.members; 109 platforms = lib.platforms.linux; 110 }; 111})