1
1
mirror of https://github.com/divnix/digga.git synced 2024-11-23 20:22:04 +03:00
digga/profiles
Timothy DeHerrera 1651913910
profiles: simplify profiles to suites
* Leave importing to nixpkgs module implentation. Provide a path
  instead; resolves #136.
* Allow profiles which are not lambdas but simple attribute sets,
  relaxing the constraints a bit.
* Update profile README.md
* defaultImports -> mkProfileAttrs: allow importing subprofiles even
  if parent directory does not contain a default.nix.
2021-02-25 14:47:19 -07:00
..
core nix: patch nix directly for experimental features 2021-02-17 12:54:41 -07:00
README.md profiles: simplify profiles to suites 2021-02-25 14:47:19 -07:00

Profiles

Profiles are simply NixOS modules which contain generic expressions suitable for any host. A good example is the configuration for a text editor, or window manager. If you need some concrete examples, just checkout the community branch.

Constraints

For the sake of consistency, a profile should always be defined in a default.nix containing a valid nixos module which does not declare any new module options. If you need to do that, use the modules directory.

Note:

hercules-ci expects all profiles to be defined in a default.nix. Similarly, suites expect a default.nix as well.

Example

Correct ✔

profiles/develop/default.nix:

{  ... }:
{
  programs.zsh.enable = true;
}

Incorrect

profiles/develop.nix:

{
  options = {};
}

Subprofiles

Profiles can also define subprofiles. They follow the same constraints outlined above. A good top level profile should be a high level concern, such a your personal development environment, and the subprofiles should be more concrete program configurations such as your text editor, and shell configs. This way, you can either pull in the whole development profile, or pick and choose individual programs.

Example

profiles/develop/default.nix:

{
  imports = [ ./zsh ];
  # some generic development concerns ...
}

profiles/develop/zsh/default.nix:

{  ... }:
{
  programs.zsh.enable = true;
  # zsh specific options ...
}

Conclusion

Profiles are the most important concept in devos. They allow us to keep our nix expressions self contained and modular. This way we can maximize reuse while minimizing boilerplate. Always strive to keep your profiles as generic and modular as possible. Anything machine specific belongs in your host files.