[Nix-dev] Shape configuration.nix differently

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri May 29 02:51:20 CEST 2015


For your information, the module system is """basically""" doing the following:

let config =
  pkgs.lib.fold (x: y: pkgs.lib.mergeAttrs x y) {} (map
(collect_all_imports) { config = config });
in
  config

Which is why I was wondering what you were trying to do.
This also mean that any filed imported with "imports" is a valid
module, in a similar way as configuration.nix.  If you look closely,
NixOS is composed entirely of modules.

Then the term "submodule" is used for options such as "fileSysems" or
"jobs", such that we can extend these options from different modules.


On Fri, May 29, 2015 at 2:24 AM, Manuel Pages
<amarr.industrial at gmail.com> wrote:
> Dear Nicolas, I have already read the diffs and lib/modules.nix
> and am sad. I don't have enough knowledge to criticize those changes
> though.
>
> Dear Jeffery, this way my "submodules" are shaped as a first-order
> functions (Submodule :: Set -> Set), with your approach we
> actually have (Submodule :: Set -> (Set -> Set)) which is fine by
> me and I'll use this approach for now.
>
> Thank you very much!
>
> On Fri, May 29, 2015 at 2:04 AM, Jeffrey David Johnson <jefdaj at gmail.com>
> wrote:
>>
>> Isn't that the same as
>>
>> ```
>> {
>>   imports = [
>>     ./hardware-configuration.nix
>>     ./boot/grub.nix
>>   ];
>> }
>> ```
>>
>> ? I think you can still access config and pkgs from each file.
>> Jeff
>>
>> On Fri, 29 May 2015 01:55:34 +0200
>> Nicolas Pierron <nicolas.b.pierron at gmail.com> wrote:
>>
>> > I am not sure to understand your
>> >
>> > On Fri, May 29, 2015 at 1:39 AM, Manuel Pages
>> > <amarr.industrial at gmail.com> wrote:
>> > > Hey, I'm working on a differently-shaped /etc/nixos/configuration.nix.
>> > >
>> > > My vision is to shape it like this:
>> > >
>> > > ```
>> > > { config, pkgs, ... }:
>> > > pkgs.lib.fold (x: y: pkgs.lib.mergeAttrs x y) {} [
>> > >   import ./hardware-configuration.nix { pkgs = pkgs; config = config;
>> > > }
>> > >   import ./boot/grub.nix { device = "/dev/sda"; }
>> > >   # ...
>> > > ]
>> > > ```
>> >
>> > The problem that you see is that recent modifications of the module
>> > system change pkgs to be the result of the configuration, instead of
>> > being the one from your system.
>> > This change as a side-effect of making pkgs.lib cause infinite
>> > recursions.
>> >
>> > Then, I am not completely sure to understand what you want to achieve
>> > which cannot be done with the module system?
>> >
>> > --
>> > Nicolas Pierron
>> > http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
>> > _______________________________________________
>> > nix-dev mailing list
>> > nix-dev at lists.science.uu.nl
>> > http://lists.science.uu.nl/mailman/listinfo/nix-dev
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
>
>
> --
> Fly safe,
> Sloz
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>



-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/


More information about the nix-dev mailing list