Re: [Nix-dev] nix modules: Unsetting attrsOf options?

2016-09-07 Thread Tomasz Czyż
filterAttrs is going through all of them I think, but try removeAttrs (or
something similar).

I'm not sure, but probably you want to remove those before importing (or
rather before evaluation), right?

so probably you need to do something like

module = import ./my-module;
module` = removeAttrs.

imports = [ module` ];

but I've not tried this, just my guess.

2016-09-07 11:12 GMT+01:00 Rickard Nilsson :

> On 09/07/2016 11:54 AM, 4levels wrote:
>
>> Hi Rickard,
>>
>> All I can think of currently is that you could create a new config
>> variable using filterAttrs to keep only the information you need.
>> Not sure if this solves your question though as I'm not aware if you can
>> use another variable in your scenario.
>>
>
> Using filterAttrs like this would introduce an infinite recursion, I think:
>
> config = {
>   myattrs = filterAttrs (k: _: k != "a") config.myattrs;
> }
>
> But maybe that wasn't what you had in mind.
>
> For the issue that spurred this question I have now added an "enable"
> option for the attributes, see: https://github.com/NixOS/nixpk
> gs/pull/18391
>
> However, that is not a general solution to this problem, so any further
> hints are welcome.
>
>   / Rickard
>
>
> Kind regards,
>>
>> Erik
>>
>> On Wed, Sep 7, 2016 at 12:35 AM Rickard Nilsson
>> > wrote:
>>
>> Is it possible to unset an attrsOf option? Say I import a module that
>> looks like this:
>>
>> options = {
>>myattrs = mkOption {
>>  type = types.attrsOf ...
>>  default = {};
>>};
>> }
>>
>> config = {
>>myattrs = {
>>  a = ...
>>  b = ...
>>};
>> };
>>
>> And then I want to remove the "a" attribute in the importing config:
>>
>> config = {
>>myattrs.a = mkForce ...
>> }
>>
>> Is that possible in any way?
>>
>>
>>/ Rickard
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl 
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>
>>
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>



-- 
Tomasz Czyż
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] nix modules: Unsetting attrsOf options?

2016-09-07 Thread Guillaume Maudoux (Layus)
I remember having som luck with

config = {
  myattrs.a = mkForce null;
}

Depending on how the module handles null values, it could work.

-- Layus.

Le 07/09/16 à 00:35, Rickard Nilsson a écrit :
> Is it possible to unset an attrsOf option? Say I import a module that
> looks like this:
>
> options = {
>   myattrs = mkOption {
> type = types.attrsOf ...
> default = {};
>   };
> }
>
> config = {
>   myattrs = {
> a = ...
> b = ...
>   };
> };
>
> And then I want to remove the "a" attribute in the importing config:
>
> config = {
>   myattrs.a = mkForce ...
> }
>
> Is that possible in any way?
>
>
>   / Rickard
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] nix modules: Unsetting attrsOf options?

2016-09-07 Thread 4levels
Hi Rickard,

All I can think of currently is that you could create a new config variable
using filterAttrs to keep only the information you need.
Not sure if this solves your question though as I'm not aware if you can
use another variable in your scenario.

Kind regards,

Erik

On Wed, Sep 7, 2016 at 12:35 AM Rickard Nilsson 
wrote:

> Is it possible to unset an attrsOf option? Say I import a module that
> looks like this:
>
> options = {
>myattrs = mkOption {
>  type = types.attrsOf ...
>  default = {};
>};
> }
>
> config = {
>myattrs = {
>  a = ...
>  b = ...
>};
> };
>
> And then I want to remove the "a" attribute in the importing config:
>
> config = {
>myattrs.a = mkForce ...
> }
>
> Is that possible in any way?
>
>
>/ Rickard
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] nix modules: Unsetting attrsOf options?

2016-09-06 Thread Rickard Nilsson
Is it possible to unset an attrsOf option? Say I import a module that 
looks like this:


options = {
  myattrs = mkOption {
type = types.attrsOf ...
default = {};
  };
}

config = {
  myattrs = {
a = ...
b = ...
  };
};

And then I want to remove the "a" attribute in the importing config:

config = {
  myattrs.a = mkForce ...
}

Is that possible in any way?


  / Rickard
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev