From 787cc66cd15159ab80b3a1b7644aa86cd3467bff Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 23 Aug 2021 12:51:27 -0700 Subject: [PATCH 1/1] Make --arg work --- default.nix | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index 95c7a7e..15034d1 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,33 @@ -args@{ ... }: -let actualNixpkgs = import args; -in actualNixpkgs.lib.warn -("Using legacy channel nixpkgs from " + ) actualNixpkgs +let + # We declare some parameters explicitly because nix's --arg command line + # flag requires this. Getting the list of parameters & constructing this + # function dynamically would require import-from-derivation, which is not + # permitted in some evaluation contexts, so we can't do that. Instead, we + # duplicate nixpkgs' list of explicit parameters here, with a check in case + # it drifts out of sync. + unused = builtins.throw "These default values are not used"; + toplevel = args@{ localSystem ? unused, system ? unused, platform ? unused + , crossSystem ? unused, config ? unused, overlays ? unused + , crossOverlays ? unused, ... }: + let + + actualNixpkgs = import args; + noisyNixpkgs = actualNixpkgs.lib.warn + ("Using legacy channel nixpkgs from " + ) actualNixpkgs; + + local-parameters = builtins.attrNames (builtins.functionArgs toplevel); + remote-parameters = + builtins.attrNames (builtins.functionArgs (import )); + missing-parameters = + actualNixpkgs.lib.subtractLists local-parameters remote-parameters; + # Don't warn about extra parameters to avoid spurious warnings as everyone + # rolls past nixpkgs commit 2dde58903e0f2f490088c3b0cedadc9b479da085 + # which removed the platform parameter. + # extra-parameters = + # actualNixpkgs.lib.subtractLists remote-parameters local-parameters; + in actualNixpkgs.lib.traceIf (missing-parameters != [ ]) + ("Note: warn-nixpkgs doesn't know about these nixpkgs parameters, warned" + + "so they might not work with --arg on the nix command line: " + + actualNixpkgs.lib.concatStringsSep " " missing-parameters) noisyNixpkgs; + +in toplevel -- 2.44.1