lol

muon: only run tests in `passthru.tests`

This was done to for `muonStandalone` to have minimal dependencies.

Other edits:

- Additional cleanup to the postUnpack.

- I've added `cmdlineForMuon` flags that I've learned about since
starting work on the `setupHook`. Without these, we get warnings about
`fortify` requiring `-O2`, and muon defaults to `-O0` when "plain"
isn't given.

winston 1992ee89 53889b7b

+59 -15
+59 -15
pkgs/by-name/mu/muon/package.nix
··· 9 9 libarchive, 10 10 libpkgconf, 11 11 pkgconf, 12 - python3, 13 12 samurai, 14 - scdoc, 15 - writableTmpDirAsHomeHook, 16 13 zlib, 17 14 embedSamurai ? false, 15 + # docs 18 16 buildDocs ? true, 17 + scdoc, 18 + # tests 19 + runTests ? false, 20 + gettext, 21 + muon, 22 + nasm, 23 + pkg-config, 24 + python3, 25 + writableTmpDirAsHomeHook, 19 26 }: 20 27 stdenv.mkDerivation (finalAttrs: { 21 28 pname = "muon" + lib.optionalString embedSamurai "-embedded-samurai"; ··· 23 30 24 31 srcs = builtins.attrValues finalAttrs.passthru.srcs; 25 32 26 - sourceRoot = "./muon-src"; 33 + sourceRoot = "muon-src"; 27 34 28 35 outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ]; 29 36 30 37 nativeBuildInputs = [ 31 38 pkgconf 32 - (python3.withPackages (ps: [ ps.pyyaml ])) 33 39 ] 34 40 ++ lib.optionals (!embedSamurai) [ samurai ] 35 - ++ lib.optionals buildDocs [ scdoc ]; 41 + ++ lib.optionals buildDocs [ 42 + scdoc 43 + ] 44 + ++ lib.optionals (buildDocs || finalAttrs.doCheck) [ 45 + (python3.withPackages (ps: [ ps.pyyaml ])) 46 + ]; 36 47 37 48 buildInputs = [ 38 49 curl ··· 44 55 strictDeps = true; 45 56 46 57 postUnpack = '' 47 - for subproject in ${lib.optionalString buildDocs "meson-docs"} meson-tests; do 48 - cp -r "$subproject" "$sourceRoot/subprojects/$subproject" 49 - chmod +w -R "$sourceRoot/subprojects/$subproject" 50 - rm "$sourceRoot/subprojects/$subproject.wrap" 58 + for src in $srcs; do 59 + name=$(stripHash $src) 60 + 61 + # skip the main project, only move subprojects 62 + [ "$name" == "$sourceRoot" ] && continue 63 + 64 + cp -r "$name" "$sourceRoot/subprojects/$name" 65 + chmod +w -R "$sourceRoot/subprojects/$name" 66 + rm "$sourceRoot/subprojects/$name.wrap" 51 67 done 52 68 ''; 53 69 54 70 patches = [ ./darwin-clang.patch ]; 55 71 56 72 postPatch = '' 57 - find subprojects/meson-tests -name "*.py" -exec chmod +x {} \; 58 - patchShebangs . 59 - 73 + find subprojects -name "*.py" -exec chmod +x {} \; 74 + patchShebangs subprojects 75 + '' 76 + + lib.optionalString finalAttrs.doCheck '' 60 77 substituteInPlace \ 61 78 "subprojects/meson-tests/common/14 configure file/test.py.in" \ 62 79 "subprojects/meson-tests/common/274 customtarget exe for test/generate.py" \ ··· 76 93 muonEnable = lib.mesonEnable; 77 94 muonOption = lib.mesonOption; 78 95 96 + # see `muon options -a` to see built-in options 79 97 cmdlineForMuon = lib.concatStringsSep " " [ 80 98 (muonOption "prefix" (placeholder "out")) 99 + # don't let muon override stdenv C flags 100 + (muonEnable "auto_features" true) 101 + (muonOption "buildtype" "plain") 102 + (muonOption "optimization" "plain") 103 + (muonOption "wrap_mode" "nodownload") 104 + # muon features 81 105 (muonBool "static" stdenv.targetPlatform.isStatic) 106 + (muonEnable "man-pages" buildDocs) 82 107 (muonEnable "meson-docs" buildDocs) 108 + (muonEnable "meson-tests" finalAttrs.doCheck) 83 109 (muonEnable "samurai" embedSamurai) 84 110 (muonEnable "tracy" false) 111 + (muonEnable "website" false) 85 112 ]; 86 113 cmdlineForSamu = "-j$NIX_BUILD_CORES"; 87 114 in ··· 102 129 ''; 103 130 104 131 # tests only pass when samurai is embedded 105 - doCheck = embedSamurai; 132 + doCheck = embedSamurai && runTests; 106 133 107 134 nativeCheckInputs = [ 108 - # needed for "common/220 fs module" 135 + # "common/220 fs module" 109 136 writableTmpDirAsHomeHook 137 + # "common/44 pkgconfig-gen" 138 + pkg-config 139 + # "frameworks/6 gettext" 140 + gettext 141 + ] 142 + ++ lib.optionals stdenv.hostPlatform.isx86_64 [ 143 + # "nasm/*" tests 144 + nasm 110 145 ]; 111 146 112 147 checkPhase = '' ··· 151 186 hash = "sha256-z4Fc1lr/m2MwIwhXJwoFWpzeNg+udzMxuw5Q/zVvpSM="; 152 187 }; 153 188 }; 189 + 190 + # tests are run here in package tests, rather than enabling doCheck by 191 + # default, to reduce the number of required dependencies. 192 + passthru.tests.test = (muon.overrideAttrs { pname = "muon-tests"; }).override { 193 + buildDocs = false; 194 + embedSamurai = true; 195 + runTests = true; 196 + }; 197 + 154 198 passthru.updateScript = callPackage ./update.nix { }; 155 199 156 200 meta = {