hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.74k stars 901 forks source link

Not in `$PATH` when using Nix home-manager standalone with flakes #564

Closed spikespaz closed 2 years ago

spikespaz commented 2 years ago

Steps to reproduce: Use my flake @ https://github.com/spikespaz/dotfiles or derive it, Observe the diff that adds hyprland to my dots.

Expected outcome: which hyprland shows a path on my PATH

Noted outcome: which: no hyprland in...

Edit: Read last comment. Use unstable.

vaxerski commented 2 years ago

@fufexan

fufexan commented 2 years ago

@spikespaz I see you've added the NixOS module, but tried to use the HM option here. You can either use the NixOS module with the programs.hyprland.enable = true; option, or use the HM one by importing hyprland.homeManagerModules.default and enabling the respective option wayland.windowManager.hyprland.enable = true;.

spikespaz commented 2 years ago

I tried hyprland.homeManagerModules.default in the import set here.

Looks like the hyprland.nixosModules.default was something I forgot to remove from my first round of trying this.

My profile.nix, as far as I can tell, matches the instructions except for the redundant NixOS module mentioned above.

Is this redundancy the problem? Do they conflict?

Why does home-manager use programs.<progname>.enable for most things, but your NixOS module instead uses that and the home-manager one uses wayland.windowManager.hyprland.enable?

fufexan commented 2 years ago

Is this redundancy the problem? Do they conflict?

In the current state yes. Using both at the same time is explained in the wiki, near the bottom of the Nix page.

Why does home-manager use programs..enable for most things, but your NixOS module instead uses that and the home-manager one uses wayland.windowManager.hyprland.enable?

We followed the option names that Sway uses. It would've been wayland.windowManager.hyprland for the NixOS module as well, if the wayland option existed. Maybe in the future.

spikespaz commented 2 years ago

Removing the hyprland.nixosModules.default has not worked.

fufexan commented 2 years ago

I'm thinking maybe the overridden 22.05 nixpkgs is conflicting? Try building hyprland without using nixpkgs.follows.

spikespaz commented 2 years ago
    hyprland = {
      url = "github:hyprwm/hyprland/v0.11.0beta";
#       inputs.nixpkgs.follows = "nixpkgs";
    };
[jacob@jacob-thinkpad:/etc/nixos]$ sudo nixos-rebuild switch --flake .#
[sudo] password for jacob: 
warning: Git tree '/etc/nixos' is dirty
warning: updating lock file '/etc/nixos/flake.lock':
• Updated input 'hyprland/nixpkgs':
    follows 'nixpkgs'
  → 'github:NixOS/nixpkgs/5e804cd8a27f835a402b22e086e36e797716ef8b' (2022-08-23)
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
leaving systemd-boot 250.4 in place (250.4 is not newer)
activating the configuration...
setting up /etc...
reloading user units for jacob...
setting up tmpfiles

[jacob@jacob-thinkpad:/etc/nixos]$ which hyprland
which: no hyprland in (/run/wrappers/bin:/home/jacob/.nix-profile/bin:/etc/profiles/per-user/jacob/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin)
vaxerski commented 2 years ago

it's Hyprland

spikespaz commented 2 years ago
[jacob@jacob-thinkpad:/etc/nixos]$ which Hyprland
which: no Hyprland in (/run/wrappers/bin:/home/jacob/.nix-profile/bin:/etc/profiles/per-user/jacob/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin)

If that were the issue, I'd be a little miffed. Nobody else uses uppercase binary names. This is a Nix Flake, not a Special Snowflake.

vaxerski commented 2 years ago

sorry man I am a bit special yes

I even got special ed in class :sunglasses:

fufexan commented 2 years ago

Can you check the value of nixosConfigurations.jacob-thinkpad.config.home-manager.users.jacob.wayland.windowManagers.hyprland.package? Or the equivalent homeConfigurations string if you use standalone HM.

spikespaz commented 2 years ago

How?

fufexan commented 2 years ago

nix run github:fufexan/dotfiles#repl <path/to/your/flake> and then type homeConfigurations."jacob@jacob-thinkpad" or whatever your profile's name is, and then everything from config. onwards from my previous comment.

If you get stuck and it's not exactly how I typed it, backtrack and try tab-completion.

spikespaz commented 2 years ago

It is trying to call a function instead of printing the result of the set expression. How can I make it provide the value instead of calling a function?

nix-repl> homeConfigurations.jacob                 
error: attempt to call something which is not a function but a set

       at /nix/store/fzzvnygk1w1qfnnsdypillxw094fn685-source/flake.nix:30:15:

           29|     homeConfigurations = {
           30|       jacob = home-manager.lib {
             |               ^
           31|         modules = [

The command ends at my profile name because I was playing around, but the same message shows when I run the full path you had requested.

fufexan commented 2 years ago

That looks wrong, doesn't it? It should be home-manager.lib.homeManagerConfiguration {.

spikespaz commented 2 years ago

I don't understand why I would open braces there. I thought I was trying to read the evaluated expression to the REPL stdout. I have not read through home-manager's lib, so I would have no way of knowing that the function returns a set with the attribute named homeManagerConfiguration. You also have never said homeManagerConfiguration. How would I know? It would look wrong to me because I have no idea what it should look like.

Could you please send me the exact command that I need to type into the REPL? Sometimes I need my hand held in lieu of documentation.

fufexan commented 2 years ago

You're right. I forgot to include the relevant starter snippet for HM configs. Currently the docs expect you to know how to use HM already.

This line should be changed to the one I said in the comment above. The full changed snippet would be

      jacob = home-manager.lib.homeManagerConfiguration {
        modules = [
          ./users/jacob/profile.nix
        ];
        pkgs = import nixpkgs {
          config.allowUnfree = true; # if you want unfree packages
          system = "x86_64-linux";
        };
      };

modules and pkgs are two attributes that HM requires in order to evaluate a configuration.

After you saved the file, you can run nix run github:nix-community/home-manager -- switch --flake .#jacob.

spikespaz commented 2 years ago

Apparently I am calling homeManagerConfiguration without required argument system for some reason. I have never seen system passed as an argument in any usage example.

  outputs = { nixpkgs, nixos-hardware, home-manager, hyprland, ... }:
    let
      system = "x86_64-linux";
    in
  {
    nixosConfigurations = {
      jacob-thinkpad = nixpkgs.lib.nixosSystem {
        inherit system;

        modules = [
          ./system/filesystems.nix
          ./system/configuration.nix
          nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2
        ];
      };
    };
    homeConfigurations = {
      jacob = home-manager.lib.homeManagerConfiguration {
        #pkgs = nixpkgs.legacyPackages.${system};
        pkgs = import nixpkgs {
          inherit system;
        };

        modules = [
          ./users/jacob/profile.nix
        ];
      };
    };
  };

What is legacyPackages for as I see in examples? Why do some people's dotfiles not use it?

spikespaz commented 2 years ago
[jacob@jacob-thinkpad:/etc/nixos]$ nix run github:nix-community/home-manager -- switch --flake .#jacob
warning: Git tree '/etc/nixos' is dirty
error: 'homeManagerConfiguration' at /nix/store/d5j5vgsfvwkaqmc1qhwaay5mp51yaqkm-source/flake.nix:44:36 called without required argument 'system'

       at /nix/store/wp4rdgavm3qv49g5qs729rlxk4idjrc4-source/flake.nix:34:15:

           33|     homeConfigurations = {
           34|       jacob = home-manager.lib.homeManagerConfiguration {
             |               ^
           35|         #pkgs = nixpkgs.legacyPackages.${system};
fufexan commented 2 years ago

Apparently I am calling homeManagerConfiguration without required argument system for some reason.

Yeah I just realized you're using HM 22.05. Only master requires pkgs and modules. The 22.05 HM requires a few more attributes set.

  outputs = { nixpkgs, nixos-hardware, home-manager, hyprland, ... }:
    let
      system = "x86_64-linux";
    in
  {
    nixosConfigurations = {
      jacob-thinkpad = nixpkgs.lib.nixosSystem {
        inherit system;

        modules = [
          ./system/filesystems.nix
          ./system/configuration.nix
          nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2
        ];
      };
    };
    homeConfigurations = {
      jacob = home-manager.lib.homeManagerConfiguration {
        #pkgs = nixpkgs.legacyPackages.${system};
        pkgs = import nixpkgs {
          inherit system;
        };
        configuration = {};
        stateVersion = "22.05";
        username = "jacob";
        homeDirectory = "/home/jacob";
        system = "x86_64-linux;

        extraModules = [
          ./users/jacob/profile.nix
        ];
      };
    };
  };
fufexan commented 2 years ago

What is legacyPackages for as I see in examples? Why do some people's dotfiles not use it?

So you know the packages output of flakes, right? That one accepts a flat attrset of packages. Nixpkgs itself has multiple nested sets of packages, like python310Packages, gnomePackages, etc. So using packages to expose the entire nixpkgs wouldn't work. That's why the legacyPackages flake output was introduced. It serves the same purpose as packages, but allows nested attributes inside it.

Some people use it for convenience when they don't need to import Nixpkgs with a certain config, like config.allowUnfree = true;. These two are actually equivalent though:

pkgs = nixpkgs.legacyPackages."x86_64-linux";
pkgs = import nixpkgs {
  system = "x86_64-linux";
};
spikespaz commented 2 years ago

For those who find this in the future, just use nixpkgs-unstable instead of nixpkgs-22.05 wherever you see it. All of these issues went away. Home Manager especially doesn't like being on the stable release. It changes too fast and the documentation gets updated too frequently so you will have wrong information if you're looking at the currently-published version.

fufexan commented 2 years ago

Yeah, we explicitly mentioned at the top of the Nix page that we don't support 22.05.

spikespaz commented 2 years ago

I saw. I was under the impression that I was free to try though, and worst case scenario, simply change the one that it follows. Sorry for wasting your time.

viperML commented 2 years ago

It is not supported simply because we don't use nixos/HM stable. If anyone manages to get a stable setup, they can just submit a PR to expand the wiki.

Another issue is that the wayland package lags behind, and we currently need 1.21.0 (IIRC)

fufexan commented 2 years ago

Sorry for wasting your time.

It's no problem, at least you pointed out some issues with the wiki and we can improve it now.

I was under the impression that I was free to try though, and worst case scenario, simply change the one that it follows.

Yeah that's the idea. Although not tested it may or may not work. I thought it would work if you let the hyprland flake use its own nixpkgs, but it seems like it won't?

spikespaz commented 2 years ago

I thought it would work if you let the hyprland flake use its own nixpkgs, but it seems like it won't?

Allegedly not. That was my assumption also. Makes me wonder what side-effects all of those lambdas have in the Nix ecosystem.

ghost commented 2 years ago

I am using this flake in nixos stable and its working , i removed "follow nixpkgs line under input section"

{ description = "nixos configuration";

inputs = { nixpkgs.url = "nixpkgs/nixos-22.05"; hyprland.url = "github:hyprwm/Hyprland"; };

outputs = { self, nixpkgs, hyprland }: { nixosConfigurations = { nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ hyprland.nixosModules.default { programs.hyprland.enable = true; } ./system/configuration.nix ]; }; }; };

}