Hello, I’m newbie in nixos, and i created my first flake, but after rebuilding i get error like :
‘path:/home/varmisa/flakes/packages/desktop/windows-managers/hyprland/setup’ does not provide attribute ‘packages.×86_64-linux-nixosConfiguration.“udev”.config.system.system. build.nixos-rebuild’ , ‘legacyPackages.x86_64-linux.nixosConfiguration.“udev”.config.system.buil d.nixos-rebuild’ or
A single flake can have many nixos configurations, the correct name here is nixosConfigurations.
When you build with nixos-rebuild build --flake .#udev, nixos-rebuild tries to build nixosConfigurations.udev, but nixosConfigurations does not exist in your flake, so you get this error:
lib.nixosSystem arguments vs nixos options?
These are nixos options, they must be put inside a module, they are currently being passed as arguments to nixpkgslib.nixosSystem which for now you only want to pass system and modules as arguments.
You will often see the nixpkgs in two “forms”, commonly they are called nixpkgs and pkgs. nixpkgs is correctly named in you flake, it’s what you get when require github:NixOs/nixpkgs, it has a few functions but you don’t normally use it much outside of nixpkgs.lib.nixosSystem pkgs is the set of all packages, you can get it like this pkgs = import nixpkgs { inherit system; }; or pkgs = nixpkgs.legacyPackages.${system};.
What you want is:
outputs = { self, nixpkgs, home-manager, hyprland }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
# ....
extraPortal = with pkgs; [
xdg-portal-portal-wlr
];
Home manager modules vs Nixos modules
home and nixos modules are not interchangeable, here you can use hyprland.nixosModules.default.
Here’s a suggestion of how you can setup your first flake with home manager:
flake.nix
# My newbie setup for Hyprland - A dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks.
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland = {
url = "github:hyprwm/hyprland";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, home-manager, ... }: {
nixosConfigurations = {
udev = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./configuration.nix
{ home-manager.users.varmisa = ./home.nix; }
];
};
};
};
}
configuration.nix
{ pkgs, inputs, ... }: {
imports = with inputs; [
# run `sudo nixos-generate-config --show-hardware-config > hardware-configuration.nix` to generate
./hardware-configuration.nix
home-manager.nixosModules.default
hyprland.nixosModules.default
# Whatever else nixos modules go here
];
xdg.portal = {
enable = true;
wlr.enable = true;
};
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
users.users.varmisa = {
isNormalUser = true;
group = "varmisa";
};
# Add some options listed in https://search.nixos.org/options
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
}
home.nix
{pkgs, inputs, ... }: {
imports = with inputs; [
# Whatever home manager modules go here
];
# Add some options listed in https://nix-community.github.io/home-manager/options.html
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "23.05";
}
Thanks, but how to add it in hyprland.nix, instead configuration.nix ?
I think, i want to use home manager and flakes separatly, can I create something, like hyprland.nix, and import it in my home manager? And if I can, how ?
I assume you want this hyprland.nix file to be a home-manager module instead of a nixos module. Pretty much all module files are declared the same way, a function that takes some inputs, and sets some options:
Create a hyprland.nix file
{ pkgs, inputs, ... }: {
# You'll need to search for the correct option, I just copy pasted to answer faster
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
}
I think you mean “keep home manager and nixos separate”, you can have both a NixosConfigurations and a homeConfigurations output in a single flake, that way you get a single lockfile and avoid having many duplicate programs installed.
Flake with NixOs and Home manager outputs separate
Thank you very much, for the first time, at least someone helped me, and did not send me to read the documentation, although this also needs to be done.