Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

92 rindas
2.4 KiB

  1. /* Some functions for manipulating meta attributes, as well as the
  2. name attribute. */
  3. { lib }:
  4. rec {
  5. /* Add to or override the meta attributes of the given
  6. derivation.
  7. Example:
  8. addMetaAttrs {description = "Bla blah";} somePkg
  9. */
  10. addMetaAttrs = newAttrs: drv:
  11. drv // { meta = (drv.meta or {}) // newAttrs; };
  12. /* Disable Hydra builds of given derivation.
  13. */
  14. dontDistribute = drv: addMetaAttrs { hydraPlatforms = []; } drv;
  15. /* Change the symbolic name of a package for presentation purposes
  16. (i.e., so that nix-env users can tell them apart).
  17. */
  18. setName = name: drv: drv // {inherit name;};
  19. /* Like `setName', but takes the previous name as an argument.
  20. Example:
  21. updateName (oldName: oldName + "-experimental") somePkg
  22. */
  23. updateName = updater: drv: drv // {name = updater (drv.name);};
  24. /* Append a suffix to the name of a package (before the version
  25. part). */
  26. appendToName = suffix: updateName (name:
  27. let x = builtins.parseDrvName name; in "${x.name}-${suffix}-${x.version}");
  28. /* Apply a function to each derivation and only to derivations in an attrset
  29. */
  30. mapDerivationAttrset = f: set: lib.mapAttrs (name: pkg: if lib.isDerivation pkg then (f pkg) else pkg) set;
  31. /* Decrease the nix-env priority of the package, i.e., other
  32. versions/variants of the package will be preferred.
  33. */
  34. lowPrio = drv: addMetaAttrs { priority = 10; } drv;
  35. /* Apply lowPrio to an attrset with derivations
  36. */
  37. lowPrioSet = set: mapDerivationAttrset lowPrio set;
  38. /* Increase the nix-env priority of the package, i.e., this
  39. version/variant of the package will be preferred.
  40. */
  41. hiPrio = drv: addMetaAttrs { priority = -10; } drv;
  42. /* Apply hiPrio to an attrset with derivations
  43. */
  44. hiPrioSet = set: mapDerivationAttrset hiPrio set;
  45. /* Check to see if a platform is matched by the given `meta.platforms`
  46. element.
  47. A `meta.platform` pattern is either
  48. 1. (legacy) a system string.
  49. 2. (modern) a pattern for the platform `parsed` field.
  50. We can inject these into a patten for the whole of a structured platform,
  51. and then match that.
  52. */
  53. platformMatch = platform: elem: let
  54. pattern =
  55. if builtins.isString elem
  56. then { system = elem; }
  57. else { parsed = elem; };
  58. in lib.matchAttrs pattern platform;
  59. enableIfAvailable = p: if p.meta.available or true then [ p ] else [];
  60. }