So I am trying to create my configuration using flakes and home-manager using modules.
I would like to manage my configuration so that my modules can create configurations for home-manager and the system transparently. So I could write module.zsh.enable and it would install my config using home-manager and define it as my default shell with the system configuration.
Here is my flake.nix
{
description = "My system config";
inputs = {
# Core deps
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs{
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in {
nixosConfigurations = {
# Wip for hosts
ideapad = lib.nixosSystem {
inherit system;
modules = [
./hosts/ideapad
home-manager.nixosModules.home-manager
{
home-manager.users.<myusername> = import ./home/home.nix;
}
];
};
};
};
}
Here is ./hosts/ideapad
{ config, pkgs, ... }:
{
# imports, hardware config and other stuff here
# Modules configurations
home-manager.users.<myusername>.modules.test = "myname";
}
And here is ./home/home.nix
{ config, lib, pkgs, nixpkgs, ... }:
{
options = {
modules.test = lib.mkOption {
type = lib.types.bool;
example = true;
};
};
config = mkIf config.modules.test {
#Home-Manager configuration
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
# plugins
enableAutosuggestions = true;
}
# System configuration (not using home-manager)
# Doesn't work since I am nested in home-manager.users.<myusername>
# users.extraUsers.<myusername>.shell = pkgs.zsh;
}
Is there anyway so that in ./hosts/ideapad
i can write
mode.test = "myname";
instead of
home-manager.users.xgroleau.
and that both the system and home-manager configuration would work?
I understand that they are not in the same hierarchy of the config, but would there be anyway to do it?