{ nixpkgsPath ? }: self: super: { selfExpr = let config = builtins.removeAttrs self.config [ "_undeclared" ]; configJson = builtins.toJSON config; in self.writeTextFile { name = "nixpkgs-self"; destination = "/default.nix"; text = '' { ... } @ args: import ${builtins.toString nixpkgsPath} { config = (builtins.fromJSON ''' ${configJson} ''') // args.config or {}; } // builtins.removeAttrs args [ "config" ] ''; }; }