diff options
author | Charles Strahan <charles@cstrahan.com> | 2016-04-30 00:19:57 -0400 |
---|---|---|
committer | Charles Strahan <charles@cstrahan.com> | 2016-10-11 19:59:00 -0400 |
commit | da36847d925058fd86f027b64cc712c57be11ad8 (patch) | |
tree | 232dd7e5aa3188fc587392a0bbc180d3e3b44e0b /lib | |
parent | 9ce4e47bf6acccbb586c8caaf6f2bcf20789ac39 (diff) |
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')
-rw-r--r-- | lib/trivial.nix | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix index 3e606f0df48f3..a0c31757ba7ae 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; |