summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorCharles Strahan <charles@cstrahan.com>2016-04-30 00:19:57 -0400
committerCharles Strahan <charles@cstrahan.com>2016-10-11 19:59:00 -0400
commitda36847d925058fd86f027b64cc712c57be11ad8 (patch)
tree232dd7e5aa3188fc587392a0bbc180d3e3b44e0b /lib/trivial.nix
parent9ce4e47bf6acccbb586c8caaf6f2bcf20789ac39 (diff)
downloadnixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar.gz
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar.bz2
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar.lz
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar.xz
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.tar.zst
nixpkgs-da36847d925058fd86f027b64cc712c57be11ad8.zip
nixos: make it easy to apply kernel patches
This makes it easy to specify kernel patches:

    boot.kernelPatches = [ pkgs.kernelPatches.ubuntu_fan_4_4 ];

To make the `boot.kernelPatches` option possible, this also makes it
easy to extend and/or modify the kernel packages within a linuxPackages
set. For example:

    pkgs.linuxPackages.extend (self: super: {
      kernel = super.kernel.override {
        kernelPatches = super.kernel.kernelPatches ++ [
          pkgs.kernelPatches.ubuntu_fan_4_4
        ];
      };
    });

Closes #15095
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 3e606f0df48..a0c31757ba7 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -53,6 +53,27 @@ rec {
   # argument, but it's nice this way if several uses of `extends` are cascaded.
   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
 
+  # Create an overridable, recursive attribute set. For example:
+  #
+  #     nix-repl> obj = makeExtensible (self: { })
+  #
+  #     nix-repl> obj
+  #     { __unfix__ = «lambda»; extend = «lambda»; }
+  #
+  #     nix-repl> obj = obj.extend (self: super: { foo = "foo"; })
+  #
+  #     nix-repl> obj
+  #     { __unfix__ = «lambda»; extend = «lambda»; foo = "foo"; }
+  #
+  #     nix-repl> obj = obj.extend (self: super: { foo = super.foo + " + "; bar = "bar"; foobar = self.foo + self.bar; })
+  #
+  #     nix-repl> obj
+  #     { __unfix__ = «lambda»; bar = "bar"; extend = «lambda»; foo = "foo + "; foobar = "foo + bar"; }
+  makeExtensible = rattrs:
+    fix' rattrs // {
+      extend = f: makeExtensible (extends f rattrs);
+   };
+
   # Flip the order of the arguments of a binary function.
   flip = f: a: b: f b a;