- https://github.com/nix-community/home-manager
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --add https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz home-manager
nix-shell '<home-manager>' -A install
- Pick a random config file (in INI, json, or yml format) from /etc
on your computer
- You can generate files in your home directory with home-manager
- Create a custom module to generate it
lib.generators
can help generate various file formatslib.generators.toJSON { } { foo = 1; }
results in{ "foo": 1 }
{ lib, config, ... }:
with lib; # incule lib to cut down on boilerplate
let cg = config.services.my-config-generator;
in
{
options.services.my-config-generator = {
enable = mkEnableOption "Enable config generator";
etcName = mkOption { type = types.path; };
default = {
type = types.listOf (submodule {
options = {
type = lib.mkOption { type = lib.str; };
};
});
};
config = lib.mkIf cg.enable {
environment.etc."${cg.etcName}".text = /* generate file here */
};
};
}