1   ===============================================================================
2   Nix OS Module                                    nixCats.module
3                                     nixCats.module.mkNixosModules
4                                      nixCats.module.mkHomeModules
5   
6   We can create modules based on a configuration
7   by exporting the following in our flake outputs.
8   
9   <mkNixosModules> {
10      defaultPackageName = "nixCats";
11      moduleNamespace = [ "nixCats" ];
12      luaPath = "${./.}";
13      inherit nixpkgs dependencyOverlays
14        categoryDefinitions packageDefinitions extra_pkg_config;
15  };
16  
17  <mkHomeModules> {
18      defaultPackageName = "nixCats";
19      moduleNamespace = [ "nixCats" ];
20      luaPath = "${./.}";
21      inherit nixpkgs dependencyOverlays
22        categoryDefinitions packageDefinitions extra_pkg_config;
23  };
24  
25  If moduleNamespace is omitted, it will default to [ defaultPackageName ].
26  
27  moduleNamespace controls the namespace for the module options.
28  
29  This means if moduleNamespace = [ "my_mods" "nixCats" ];
30  
31  Then you would my_mods.nixCats.enable = true;
32  and my_mods.nixCats.packageNames = [ "package" "names" "toinstall" ];
33  
34  More specifically, the options will be here:
35  
36    options = with lib; lib.setAttrByPath moduleNamespace ({ /* nixCats options */ });
37  
38  
39  If you do not have a luaPath, you may pass it a keepLua builder.
40  
41  IMPORTANT
42  By default, the module inherits pkgs.config from the system's pkgs object,
43  and its overlays AND the flake's overlays and nixCats config,
44  as well as the flake's nixpkgs source (by default).
45  It will inherit things from your system,
46  but your system will not inherit things from nixCats,
47  other than the packages themselves in config.${defaultPackageName}.out
48  
49  -------------------------------------------------------------------------------
50  Module Options
51  
52  Home-Manager https://nixcats.org/nixCats_hm_options.html
53  
54  NixOS and nix-darwin https://nixcats.org/nixCats_nixos_options.html
55  Same options as home manager but also has the same options defineable per user
56  
57  -------------------------------------------------------------------------------
58  Accessing the finished packages for running via nix run
59  
60  The modules set read only config values containing the resulting packages
61  built by the module.
62  
63  They can be grabbed in your flake.nix via the self variable.
64  
65  Within your config that you grab from your self variable, the packages will be
66  here:
67  
68    config."<defaultPackageName>".out.packages."<PACKAGE_NAME>"
69  
70  and if using the NixOS module there is ALSO
71  
72    config."<defaultPackageName>".out.users."<USER_NAME>".packages."<PACKAGE_NAME>"
73  
74  Which can be useful! Say, for example, you installed your nvim via a home
75  manager module. You can then set your EDITOR variable like this!
76  
77    home.sessionVariables.EDITOR = let
78      nvimpkg = config."<defaultPackageName>".out.packages."<PACKAGE_NAME>";
79    in "${nvimpkg}/bin/${nvimpkg.nixCats_packageName}";
80  
81  
82  When exporting the package from your system's flake.nix,
83  you will need to get config from self first.
84  
85  To find your package from the self variable, it will look something like
86  this:
87  
88    # getting it from a home manager configuration
89    self.homeConfigurations."<home_config_name>".config."<defaultPackageName>".out.packages."<package_name>"
90  
91    # getting it from a nixos configuration
92    self.nixosConfigurations."<system_config_name>".config."<defaultPackageName>".out.packages."<package_name>"
93  
94    # getting home manager package when home manager is a nixos module
95    self.nixosConfigurations."<system_config_name>".config.home-manager.users."<username>"."<defaultPackageName>".out.packages."<package_name>"
96  
97  
98  You can then export that from your flake as
99  packages.${system}.default or
100 packages.${system}.whatever
101 
102 when creating modules with mkNixosModules or mkHomeModules you can also
103 set the moduleNamespace to whatever you want.
104 This will also change where you grab the package from.
105 The read-only config value will be in the same set your other options are declared in.
106 
107 =================================================================================
108 vim:tw=78:ts=8:ft=help:norl: