From 5990cce95f562ed185f55cb9bc3f230265d2ab9d Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 19 Mar 2015 15:48:54 +0000 Subject: [PATCH 1/7] lib: cleanup a little bit, add traceIf --- lib/customisation.nix | 17 +++++++++-------- lib/debug.nix | 10 ++++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index 960eebfc79b..91a25055df2 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -29,8 +29,8 @@ rec { For another application, see build-support/vm, where this function is used to build arbitrary derivations inside a QEMU - virtual machine. */ - + virtual machine. + */ overrideDerivation = drv: f: let newDrv = derivation (drv.drvAttrs // (f drv)); @@ -56,18 +56,17 @@ rec { makeOverridable = f: origArgs: let ff = f origArgs; + overrideWith = newArgs: origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs); in if builtins.isAttrs ff then (ff // - { override = newArgs: - makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); + { override = newArgs: makeOverridable f (overrideWith newArgs); deepOverride = newArgs: makeOverridable f (lib.overrideExisting (lib.mapAttrs (deepOverrider newArgs) origArgs) newArgs); overrideDerivation = fdrv: makeOverridable (args: overrideDerivation (f args) fdrv) origArgs; }) else if builtins.isFunction ff then - { override = newArgs: - makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); + { override = newArgs: makeOverridable f (overrideWith newArgs); __functor = self: ff; deepOverride = throw "deepOverride not yet supported for functors"; overrideDerivation = throw "overrideDerivation not yet supported for functors"; @@ -102,8 +101,10 @@ rec { }; */ callPackageWith = autoArgs: fn: args: - let f = if builtins.isFunction fn then fn else import fn; in - makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) autoArgs) // args); + let + f = if builtins.isFunction fn then fn else import fn; + auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs; + in makeOverridable f (auto // args); /* Add attributes to each output of a derivation without changing the derivation itself */ diff --git a/lib/debug.nix b/lib/debug.nix index 8852c22981c..2d10d981114 100644 --- a/lib/debug.nix +++ b/lib/debug.nix @@ -13,10 +13,11 @@ rec { addErrorContextToAttrs = lib.mapAttrs (a: v: lib.addErrorContext "while evaluating ${a}" v); + traceIf = p: msg: x: if p then trace msg x else x; - traceVal = x: builtins.trace x x; - traceXMLVal = x: builtins.trace (builtins.toXML x) x; - traceXMLValMarked = str: x: builtins.trace (str + builtins.toXML x) x; + traceVal = x: trace x x; + traceXMLVal = x: trace (builtins.toXML x) x; + traceXMLValMarked = str: x: trace (str + builtins.toXML x) x; # this can help debug your code as well - designed to not produce thousands of lines traceShowVal = x : trace (showVal x) x; @@ -42,6 +43,7 @@ rec { traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b)); traceCall3 = n : f : a : b : c : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b) (t "arg 3" c)); + # FIXME: rename this? traceValIfNot = c: x: if c x then true else trace (showVal x) false; @@ -106,6 +108,6 @@ rec { ) else let r = strict expr; - in builtins.trace "${str}\n result:\n${builtins.toXML r}" r + in trace "${str}\n result:\n${builtins.toXML r}" r ); } From 89bfacdf90fff0dde857c5b0e29b73042ec1d4c7 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Tue, 24 Mar 2015 21:34:54 +0000 Subject: [PATCH 2/7] kernel: add a warning/note at the top of common-config so that people would hopefully stop breaking the older kernels --- .../os-specific/linux/kernel/common-config.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index e6d45af7c59..002c2997cd6 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -1,3 +1,21 @@ +/* + + WARNING/NOTE: whenever you want to add an option here you need to + either + + * mark it as an optional one with `?` suffix, + * or make sure it works for all the versions in nixpkgs, + * or check for which kernel versions it will work (using kernel + changelog, google or whatever) and mark it with `versionOlder` or + `versionAtLeast`. + + Then do test your change by building all the kernels (or at least + their configs) in nixpkgs or else you will guarantee lots and lots + of pain to users trying to switch to an older kernel because of some + hardware problems with a new one. + +*/ + { stdenv, version, kernelPlatform, extraConfig, features }: with stdenv.lib; From dc4fa2da8acd6acc2b83fd4526711b8c35a79058 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 19 Mar 2015 10:51:49 +0000 Subject: [PATCH 3/7] nixos: udev: build rules locally --- nixos/modules/services/hardware/udev.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix index 39180f4d37e..a775aed0fda 100644 --- a/nixos/modules/services/hardware/udev.nix +++ b/nixos/modules/services/hardware/udev.nix @@ -28,6 +28,7 @@ let # Perform substitutions in all udev rules files. udevRules = stdenv.mkDerivation { name = "udev-rules"; + preferLocalBuild = true; buildCommand = '' mkdir -p $out shopt -s nullglob From 5c6d86540b748096b89051182840e6e3b83b47c8 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 19 Mar 2015 16:03:09 +0000 Subject: [PATCH 4/7] nixos: use types.enum instead of ad-hoc check in sshd service --- nixos/modules/services/networking/ssh/sshd.nix | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index b11f996c63c..b2740bd33b7 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -9,12 +9,6 @@ let nssModulesPath = config.system.nssModules.path; - permitRootLoginCheck = v: - v == "yes" || - v == "without-password" || - v == "forced-commands-only" || - v == "no"; - knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts); knownHostsText = flip (concatMapStringsSep "\n") knownHosts @@ -116,12 +110,9 @@ in permitRootLogin = mkOption { default = "without-password"; - type = types.addCheck types.str permitRootLoginCheck; + type = types.enum ["yes" "without-password" "forced-commands-only" "no"]; description = '' - Whether the root user can login using ssh. Valid values are - yes, without-password, - forced-commands-only or - no. + Whether the root user can login using ssh. ''; }; From 18127cc1e23fd1414dead49764c99225f494aa23 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Sat, 21 Mar 2015 13:08:44 +0000 Subject: [PATCH 5/7] conky: cleanup --- pkgs/top-level/all-packages.nix | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index eb83bcc8996..e93d393249d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8675,16 +8675,7 @@ let cifs_utils = callPackage ../os-specific/linux/cifs-utils { }; - conky = callPackage ../os-specific/linux/conky { - mpdSupport = config.conky.mpdSupport or true; - x11Support = config.conky.x11Support or false; - xdamage = config.conky.xdamage or false; - wireless = config.conky.wireless or false; - luaSupport = config.conky.luaSupport or false; - rss = config.conky.rss or false; - weatherMetar = config.conky.weatherMetar or false; - weatherXoap = config.conky.weatherXoap or false; - }; + conky = callPackage ../os-specific/linux/conky (config.conky or {}); conntrack_tools = callPackage ../os-specific/linux/conntrack-tools { }; From de222a9cee95f65833bf338d0cad9781c1af9194 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 19 Mar 2015 16:13:16 +0000 Subject: [PATCH 6/7] fetchmail: use callPackage --- pkgs/top-level/all-packages.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e93d393249d..51c102e3088 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10386,9 +10386,7 @@ let fbreader = callPackage ../applications/misc/fbreader { }; - fetchmail = import ../applications/misc/fetchmail { - inherit stdenv fetchurl openssl; - }; + fetchmail = callPackage ../applications/misc/fetchmail { }; fldigi = callPackage ../applications/audio/fldigi { }; From 4cd43bd2aed32ec6127feb35b4d5c613ced24286 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Sat, 21 Mar 2015 12:24:19 +0000 Subject: [PATCH 7/7] ocamlnat: use newScope directly --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 51c102e3088..803b44e9274 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4253,7 +4253,7 @@ let }; opam = callPackage ../development/tools/ocaml/opam { }; - ocamlnat = let callPackage = newScope pkgs.ocamlPackages_3_12_1; in callPackage ../development/ocaml-modules/ocamlnat { }; + ocamlnat = newScope pkgs.ocamlPackages_3_12_1 ../development/ocaml-modules/ocamlnat { }; qcmm = callPackage ../development/compilers/qcmm { lua = lua4;