On 17-02-27 09:15am, Mark Gardner wrote: > Now that I am putting NixOS on more and more machines, I would like to > modularize and share parts of the config to maximize reuse and ensure > uniformity.
As far as the non-dev-ops-y parts go (that is: the nix expression parts), there’s basically two ways to structure modules: 1. Using `import` 2. Using `imports` from the module system 3. Using option definitions All have their place, I personally use the first two for more ephemeral settings and the latter if I want to share something for use by others. Example from my current machine config in our vuizvui repo: I have a folder for my personal machines, with a lib.nix and pkgs.nix; these are included as attrsets with `import` https://github.com/openlab-aux/vuizvui/blob/ac8da8796649e463b7d31dad6bfc95f01008c787/machines/profpatsch/katara.nix#L4 My config for workstation/server/base is split into various module files, which get included with `imports`. https://github.com/openlab-aux/vuizvui/blob/ac8da8796649e463b7d31dad6bfc95f01008c787/machines/profpatsch/katara.nix#L9 https://github.com/openlab-aux/vuizvui/blob/ac8da8796649e463b7d31dad6bfc95f01008c787/machines/profpatsch/base-workstation.nix#L11 Then finally there’s the Thinkpad-specific setup, which I have put into a module with an enable option for others to use. https://github.com/openlab-aux/vuizvui/blob/ac8da8796649e463b7d31dad6bfc95f01008c787/machines/profpatsch/katara.nix#L45 https://github.com/openlab-aux/vuizvui/blob/ac8da8796649e463b7d31dad6bfc95f01008c787/modules/hardware/thinkpad.nix and it’s actually used by our hackerspace’s Thinkpad, too: https://github.com/openlab-aux/vuizvui/blob/cd4bc6fde00e3da0382a3eb151dbbd0087449377/machines/labnet/labtops.nix#L9 I hope that helps. -- Proudly written in Mutt with Vim on NixOS. Q: Why is this email longer than five sentences? A: Sometimes you have to be more verbose. :) May take up to five days to read your message. If it’s urgent, call me. _______________________________________________ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev