Hi everyone, I wondering the following:
My home-manager config is a nix flake on github. How do I import it into my nixos config?
Setup:
I have 2 repositories, one containing my nixos config, one containing my home-manager config. Both are nix flakes and work perfectly individually.
My nixos flake looks as follows:
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-config = {
url = "/home/cgahr/.config/home-manager";
# url = "git+ssh://git@github.com/cgahr/home-manager-config";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
outputs = { self, nixpkgs, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs pkgs;
};
modules = [
./configuration.nix
inputs.home-manager.nixosModules.default
{
home-manager.users."cgahr" = inputs.home-manager-config.homeConfigurations."cgahr";
# home-manager.users."cgahr" = inputs.home-manager-config.nixosModules.home;
home-manager.extraSpecialArgs = { inherit inputs; };
}
];
};
};
}
My home-manager flake looks as follows:
{
description = "Home Manager configuration of cgahr";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-colors.url = "github:misterio77/nix-colors";
};
outputs =
{ home-manager
, nix-colors
, nixpkgs
, ...
}@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
# nixosModules.home = import ./home.nix;
homeConfigurations."cgahr" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home.nix ];
extraSpecialArgs = {
inherit inputs;
};
};
};
}
As you can see, my personal home-manager config is a nix flake residing on github (private), but for debugging purposes I import the local folder.
What I have tried so far:
Running sudo nixos-rebuild switch --flake .#default --impure
fails with the following error
error: Module `:anon-6:anon-1' has an unsupported attribute `activation-script'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: activation-script activationPackage extendModules newsDisplay newsEntries pkgs) into the explicit `config' attribute.
If I uncomment the commented line in each flake respectively, I get the following error:
error: attribute 'nix-colors' missing
I’m at a loss at what to do. Any help is appreciated!