From da36847d925058fd86f027b64cc712c57be11ad8 Mon Sep 17 00:00:00 2001 From: Charles Strahan Date: Sat, 30 Apr 2016 00:19:57 -0400 Subject: 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 --- lib/trivial.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/trivial.nix') 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; -- cgit 1.4.1