From 96698efe0cd9e0ffe38d95e043acafa926fa5e0d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 18 Mar 2022 00:32:53 +0100 Subject: lib/modules: Finally remove deprecated types.optionSet types.optionSet has been deprecated for almost 10 years now (0e333688cea468a28516bf6935648c03ed62a7bb)! A removal was already attempted in 2019 (27982b408e465554b8831f492362bc87ed0ec02a), but it was promptly reinstantiated since some third-party uses were discovered (f531ce75e4178c6867cc1d0f7fec96b2d5c3f1cb). It's finally time to remove it for good :) --- doc/contributing/reviewing-contributions.chapter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/contributing/reviewing-contributions.chapter.md b/doc/contributing/reviewing-contributions.chapter.md index 0a90781d0c5..b78fda6c288 100644 --- a/doc/contributing/reviewing-contributions.chapter.md +++ b/doc/contributing/reviewing-contributions.chapter.md @@ -122,7 +122,7 @@ Reviewing process: - [CODEOWNERS](https://help.github.com/articles/about-codeowners/) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. - Ensure that the module tests, if any, are succeeding. - Ensure that the introduced options are correct. - - Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). - Description, default and example should be provided. - Ensure that option changes are backward compatible. - `mkRenamedOptionModule` and `mkAliasOptionModule` functions provide way to make option changes backward compatible. @@ -157,7 +157,7 @@ Reviewing process: - Ensure that the module tests, if any, are succeeding. - Ensure that the introduced options are correct. - - Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). - Description, default and example should be provided. - Ensure that module `meta` field is present - Maintainers should be declared in `meta.maintainers`. -- cgit 1.4.1 From bf7d13dc4f54561bb2d8b026e25bda70362b789e Mon Sep 17 00:00:00 2001 From: Naïm Favier Date: Tue, 22 Mar 2022 19:53:22 +0100 Subject: fetchpatch: add `relative` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows restricting patches to a specific subdirectory, à la `git diff --relative=subdir`. This cannot be done (cleanly) currently because the `includes` logic happens *after* `stripLen` is applied, so we can't match on `subdir/*`. This change adds a `relative` argument that makes this possible by filtering files before doing any processing, and setting `stripLen` and `extraPrefix` accordingly. --- doc/contributing/coding-conventions.chapter.md | 5 +-- pkgs/build-support/fetchpatch/default.nix | 45 +++++++++++++++++--------- pkgs/build-support/fetchpatch/tests.nix | 16 +++++++++ 3 files changed, 49 insertions(+), 17 deletions(-) (limited to 'doc') diff --git a/doc/contributing/coding-conventions.chapter.md b/doc/contributing/coding-conventions.chapter.md index cfe8582e514..dac6d828ac0 100644 --- a/doc/contributing/coding-conventions.chapter.md +++ b/doc/contributing/coding-conventions.chapter.md @@ -540,10 +540,11 @@ If you do need to do create this sort of patch file, one way to do so is with gi If a patch is available online but does not cleanly apply, it can be modified in some fixed ways by using additional optional arguments for `fetchpatch`: +- `relative`: Similar to using `git-diff`'s `--relative` flag, only keep changes inside the specified directory, making paths relative to it. - `stripLen`: Remove the first `stripLen` components of pathnames in the patch. - `extraPrefix`: Prefix pathnames by this string. -- `excludes`: Exclude files matching this pattern. -- `includes`: Include only files matching this pattern. +- `excludes`: Exclude files matching these patterns (applies after the above arguments). +- `includes`: Include only files matching these patterns (applies after the above arguments). - `revert`: Revert the patch. Note that because the checksum is computed after applying these effects, using or modifying these arguments will have no effect unless the `sha256` argument is changed as well. diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix index 6e25b2d6ecc..d46162c97ff 100644 --- a/pkgs/build-support/fetchpatch/default.nix +++ b/pkgs/build-support/fetchpatch/default.nix @@ -9,7 +9,8 @@ let # 0.3.4 would change hashes: https://github.com/NixOS/nixpkgs/issues/25154 patchutils = buildPackages.patchutils_0_3_3; in -{ stripLen ? 0 +{ relative ? null +, stripLen ? 0 , extraPrefix ? null , excludes ? [] , includes ? [] @@ -17,7 +18,18 @@ in , postFetch ? "" , ... }@args: - +let + args' = if relative != null then { + stripLen = 1 + lib.length (lib.splitString "/" relative) + stripLen; + extraPrefix = if extraPrefix != null then extraPrefix else ""; + } else { + inherit stripLen extraPrefix; + }; +in let + inherit (args') stripLen extraPrefix; +in +lib.throwIfNot (excludes == [] || includes == []) + "fetchpatch: cannot use excludes and includes simultaneously" fetchurl ({ postFetch = '' tmpfile="$TMPDIR/patch" @@ -27,17 +39,19 @@ fetchurl ({ exit 1 fi - "${patchutils}/bin/lsdiff" "$out" \ - | sort -u | sed -e 's/[*?]/\\&/g' \ - | xargs -I{} \ - "${patchutils}/bin/filterdiff" \ - --include={} \ - --strip=${toString stripLen} \ - ${lib.optionalString (extraPrefix != null) '' - --addoldprefix=a/${extraPrefix} \ - --addnewprefix=b/${extraPrefix} \ - ''} \ - --clean "$out" > "$tmpfile" + "${patchutils}/bin/lsdiff" \ + ${lib.optionalString (relative != null) "-p1 -i ${lib.escapeShellArg relative}/'*'"} \ + "$out" \ + | sort -u | sed -e 's/[*?]/\\&/g' \ + | xargs -I{} \ + "${patchutils}/bin/filterdiff" \ + --include={} \ + --strip=${toString stripLen} \ + ${lib.optionalString (extraPrefix != null) '' + --addoldprefix=a/${lib.escapeShellArg extraPrefix} \ + --addnewprefix=b/${lib.escapeShellArg extraPrefix} \ + ''} \ + --clean "$out" > "$tmpfile" if [ ! -s "$tmpfile" ]; then echo "error: Normalized patch '$tmpfile' is empty (while the fetched file was not)!" 1>&2 @@ -64,5 +78,6 @@ fetchurl ({ ${patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile" mv "$tmpfile" "$out" '' + postFetch; - meta.broken = excludes != [] && includes != []; -} // builtins.removeAttrs args ["stripLen" "extraPrefix" "excludes" "includes" "revert" "postFetch"]) +} // builtins.removeAttrs args [ + "relative" "stripLen" "extraPrefix" "excludes" "includes" "revert" "postFetch" +]) diff --git a/pkgs/build-support/fetchpatch/tests.nix b/pkgs/build-support/fetchpatch/tests.nix index 4240b325d65..ff2b81bf3a1 100644 --- a/pkgs/build-support/fetchpatch/tests.nix +++ b/pkgs/build-support/fetchpatch/tests.nix @@ -5,4 +5,20 @@ url = "https://github.com/facebook/zstd/pull/2724/commits/e1f85dbca3a0ed5ef06c8396912a0914db8dea6a.patch"; sha256 = "sha256-PuYAqnJWAE+L9bsroOnnBGJhERW8LHrGSLtIEkKU9vg="; }; + + relative = invalidateFetcherByDrvHash fetchpatch { + url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch"; + relative = "include"; + sha256 = "sha256-KlmIbixcds6GyKYt1fx5BxDIrU7msrgDdYo9Va/KJR4="; + }; + + full = invalidateFetcherByDrvHash fetchpatch { + url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch"; + relative = "test"; + stripLen = 1; + extraPrefix = "foo/bar/"; + excludes = [ "foo/bar/bernoulli_no_atomic_mp.cpp" ]; + revert = true; + sha256 = "sha256-+UKmEbr2rIAweCav/hR/7d4ZrYV84ht/domTrHtm8sM="; + }; } -- cgit 1.4.1