How to use it in home.nix ?
I'm using NixOS with flakes, and following is my home.nix:
{ pkgs, nixosConfig, inputs, ...}: {
imports = [
inputs.plasma-manager.homeManagerModules.plasma-manager
./plasma.home.nix # generated by rc2nix
];
...
But following error is reported:
error: infinite recursion encountered
at /nix/store/si9r9isfbg2fl7az5w3gwwrbdpzpfvcl-source/lib/modules.nix:483:28:
482| builtins.addErrorContext (context name)
483| (args.${name} or config._module.args.${name})
| ^
484| ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)
So how should I import it ?
Hmm, I'm not sure what's going on here. You appear to be doing things correctly. However, it's hard to tell without seeing the entire file flake and home files.
You might want to try using extraModules like what I have in the example file:
https://github.com/pjones/plasma-manager/blob/trunk/example/flake.nix
Thanks, that seems helpful, but I got another error:
error: The 'homeManagerConfiguration' arguments
- 'configuration',
- 'username',
- 'homeDirectory'
- 'stateVersion',
- 'extraModules', and
- 'system'
have been removed. Instead use the arguments 'pkgs' and
'modules'. See the 22.11 release notes for more: https://nix-community.github.io/home-manager/release-notes.html#sec-release-22.11-highlights
Deprecated args passed: configuration username homeDirectory extraModules
Seems flakes api changed .
It looks like the example is still using 22.05.
I don't have time to work on this right now, but if you open a PR I'm happy to merge it.
I migrated it like following, but still not working, not sure why. Could you please split your example's home.nix into home.nix and plasma.nix, and the first one imports the second one, and the second one is exported by rc2nix directly?

I recently got this working (Plasma-manager, in a flake config with home-manager as a NixOS module, in a nix-starter-configs based Flake setup.
Important bits of flake.nix:
{
description = "DESCRIPTION";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
hardware.url = "github:nixos/nixos-hardware";
# Home manager
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Flake-utils, not really necessary for a single system
flake-utils.url = "github:numtide/flake-utils";
plasma-manager.url = "github:pjones/plasma-manager";
plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.inputs.home-manager.follows = "home-manager";
};
outputs = { nixpkgs, hardware, home-manager, flake-utils, plasma-manager, ... }@inputs:
let
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
];
in
rec {
# Your custom packages and modifications
overlays = {
default = import ./overlay { inherit inputs; };
};
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
homeManagerModules = import ./modules/home-manager;
# Devshell for bootstrapping
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells = forAllSystems (system: {
default = legacyPackages.${system}.callPackage ./shell.nix { };
});
# This instantiates nixpkgs for each system listed above
# Allowing you to add overlays and configure it (e.g. allowUnfree)
# Our configurations will use these instances
# Your flake will also let you access your package set through nix build, shell, run, etc.
legacyPackages = forAllSystems (system:
import inputs.nixpkgs {
inherit system;
# This adds our overlays to pkgs
overlays = builtins.attrValues overlays;
# NOTE: Using `nixpkgs.config` in your NixOS config won't work
# Instead, you should set nixpkgs configs here
# (https://nixos.org/manual/nixpkgs/stable/#idm140737322551056)
config.allowUnfree = true;
}
);
nixosConfigurations = {
nixos-x1carbon = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
pkgs = legacyPackages.x86_64-linux;
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
modules = (builtins.attrValues nixosModules) ++ [
# > Our main nixos configuration file <
./nixos/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = { inherit inputs; }; # Pass flake input to home-manager
home-manager.users.USERNAME.imports = [ ./home-manager/home.nix ];
home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ];
}
];
};
};
};
}
in home-manager/home.nix
{ inputs, outputs, lib, config, pkgs, ... }: {
# You can import other home-manager modules here
imports = [
# If you want to use modules your own flake exports (from modules/home-manager):
# outputs.homeManagerModules.example
# Or modules exported from other flakes (such as nix-colors):
# I think one could import plasma-manager here instead of adding it to sharedModules in flake.nix, but I didn't try that yet
# You can also split up your configuration and import pieces of it here:
./sub-configs/plasma.nix
];
And then stick the output of rc2nix in a plasma.nix after the inputs function ({ config, lib, pkgs, plasma-manager, ... }: or similar).
Provide a minimal standalone flake example.
./flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.url = "github:pjones/plasma-manager";
plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.inputs.home-manager.follows = "home-manager";
};
outputs = { self, nixpkgs, home-manager, plasma-manager }: {
# change to your system architecture
homeConfigurations.asahi = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.aarch64-linux; modules = [ ./home/asahi.nix ]; extraSpecialArgs = { inherit plasma-manager; }; };
};
}
./home/asahi.nix
{ pkgs, lib, config, ... }: {
imports = [
./kde.nix
];
home.stateVersion = "24.05";
home = {
username = "NAME";
homeDirectory = "/home/NAME";
};
}
./home/kde.nix
{ plasma-manager, ... }: {
imports = [
plasma-manager.homeManagerModules.plasma-manager
];
# MacOS-like window switching
programs.plasma = {
enable = true;
shortcuts.kwin = {
"Walk Through Windows" = "Meta+Tab";
};
};
}
The infinite recursion here seems to be in home-manager?
Copying all the plasma-manager files into my flake and referencing it directly with a path makes the issue go away. This appears to be a home-manager bug.
was this reported upstream @Lymia ?