Hi there, I’m pretty new to NixOS, and I have worked through this guide to get started and get started with flakes. I’ve been tinkering with publicly available configs and everything has been mostly working fine, but now I ran into a bit of a roadblock. When trying to define services in my home-manager modules, I get the following error message:
error: undefined variable 'hm'
at /nix/store/d5wq3bcaafv5msw7lcjcyq5g20pjk5zn-source/modules/services/swayidle.nix:112:8:
111| assertions = [
112| (hm.assertions.assertPlatform "services.swayidle" pkgs platforms.linux)
| ^
113| ];
The only reference i found to this error is here:
The comment mentions to make sure that the module is included in the correct configuration (i.e. home-manager), but to the best of my current knowledge, I think I am. These are parts of my current config, I am not sure if the rest is relevant, but can update if needed. My flake.nix
:
{
description = "NixOS configuration of cluosh";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
};
outputs = {
self,
nixpkgs,
home-manager,
...
}@inputs: let
lib = nixpkgs.lib;
in rec {
nixosConfigurations = {
test = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/test
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs lib;
};
users.cluosh = ./home;
};
}
];
};
};
};
}
My ./home/default.nix
:
{
config,
pkgs,
...
}: {
imports = [
./programs
#./desktop/hyprland
];
home = {
username = "cluosh";
homeDirectory = "/home/cluosh";
stateVersion = "23.05";
};
services = {
swayidle.enable = true;
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}
The services are used somewhere further down in my hyprland config, but i just moved the swayidle
services to my top home module for debugging. The error happens with anything defined as a service, not just swayidle
. I have a feeling I am missing something very obvious, but I haven’t been able to figure it out myself and would be thankful for some pointers.