Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

nixpkgs.hostPlatform not set

Open aimixsaka opened this issue 2 years ago • 6 comments

I want to use Nixos module with flakes to build Hyprland, while got error with nixpkgs.hostPlatform not set.

Command I execute: sudo nixos-rebuild switch --flake '.#aimi'

Output:

[sudo] password for aimi:
error: Neither nixpkgs.hostPlatform nor the legacy option nixpkgs.system has been set.
       You can set nixpkgs.hostPlatform in hardware-configuration.nix by re-running
       a recent version of nixos-generate-config.
       The option nixpkgs.system is still fully supported for NixOS 22.05 interoperability,
       but will be deprecated in the future, so we recommend to set nixpkgs.hostPlatform.
(use '--show-trace' to show detailed location information

Expect output: Everything is ok.

Other message: NixOS version: NixOS 22.11 nix version: nix (Nix) 2.11.1 flake.nix:

# hyprland flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    hyprland.url = "github:hyprwm/Hyprland";
  };

  outputs = {nixpkgs, hyprland, ...}: {
    nixosConfigurations.aimi = nixpkgs.lib.nixosSystem {
      # ...
      modules = [
        hyprland.nixosModules.default
        {programs.hyprland.enable = true;}
        # ...
      ];
    };
  };
}

(the sample one in wiki)

flake.nix place: /etc/nixos/env/hyprland/flake.nix I run command in /etc/nixos/env/hyprland/

I checked my hardware-configuration.nix and fount nixpkgs.hostPlatform is ok: nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; And I've tried nixos-generate-config, still this error. Is this my personal environment bug?

aimixsaka avatar Jan 07 '23 12:01 aimixsaka

@fufexan

vaxerski avatar Jan 07 '23 12:01 vaxerski

I don't have enough context about your pkgs to know what's wrong. Are you setting nixpkgs.pkgs like I do here? Or are you letting the module system import it by itself?

I do not get this error, and neither does @colemickens. So there must be something different between our nixpkgs versions.

Something else I could add is to try using nixos-unstable instead of 22.11.

fufexan avatar Jan 07 '23 13:01 fufexan

I'm experiencing this problem. Followed steps in wiki.

thedaringdev avatar Jan 08 '23 03:01 thedaringdev

I'm experiencing this problem. Followed steps in wiki.

Did you solved it?

aimixsaka avatar Jan 08 '23 04:01 aimixsaka

Edit because I'm dumb Is hardware-configuration.nix actually being imported by your flake? Running nixos-generate-config wouldn't fix anything if /etc/nixos/hardware-configuration.nix isn't actually imported by the flake.

Edit 2 Try adding this to your inputs

inputs.nixpkgs.follows = "nixpkgs";

Original Message: Do you have something like this in hardware-configuration.nix?

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";

ArtixBTW avatar Jan 08 '23 21:01 ArtixBTW

Edit 2 Try adding this to your inputs

inputs.nixpkgs.follows = "nixpkgs";

Why, exactly? This means you no longer get cache hits.

fufexan avatar Jan 09 '23 12:01 fufexan

Edit 2 Try adding this to your inputs

inputs.nixpkgs.follows = "nixpkgs";

Why, exactly? This means you no longer get cache hits.

Adding inputs.nixpkgs.follows = "nixpkgs"; to my flake file resulted in the following error

error: stack overflow (possible infinite recursion)

thedaringdev avatar Jan 10 '23 04:01 thedaringdev

I resolved the problem by simply including the hardware-configuration.nix in the same location as the configuration.nix which is being called by the flake.nix

thedaringdev avatar Jan 12 '23 15:01 thedaringdev

Hi! @itsOnly1Jah - Could you share your config directory structure?

I am getting the same error on a fresh install and my configuration.nix, hardware-configuration.nix, and flake.nix are all in the same /etc/nixos directory.

ioniua avatar Jan 23 '23 17:01 ioniua

Hi! @itsOnly1Jah - Could you share your config directory structure?

I am getting the same error on a fresh install and my configuration.nix, hardware-configuration.nix, and flake.nix are all in the same /etc/nixos directory.

I store my flake in a .setup directory of my home folder like so. The only file that references the hardware-configurarion.nix is my configuration.nix file.

├── flake.lock
├── flake.nix
├── hosts
│   ├── configuration.nix
│   ├── default.nix
│   ├── hardware-configuration.nix
│   └── home.nix
└── modules

thedaringdev avatar Jan 23 '23 23:01 thedaringdev

Thank you very much. I'll give this structure a go over the weekend and hopefully fixes my issue as well.

Dritan

On January 23, 2023 6:54:03 PM EST, itsOnly1Jah @.***> wrote:

Hi! @itsOnly1Jah - Could you share your config directory structure?

I am getting the same error on a fresh install and my configuration.nix, hardware-configuration.nix, and flake.nix are all in the same /etc/nixos directory.

I store my flake in a .setup directory of my home folder like so. The only file that references the hardware-configurarion.nix is my configuration.nix file.


├── flake.lock

├── flake.nix

├── hosts

│   ├── configuration.nix

│   ├── default.nix

│   ├── hardware-configuration.nix

│   └── home.nix

└── modules

-- > Reply to this email directly or view it on GitHub:

https://github.com/hyprwm/Hyprland/issues/1334#issuecomment-1401163905

You are receiving this because you commented.

Message ID: @.***>

ioniua avatar Jan 24 '23 00:01 ioniua

Thank you very much. I'll give this structure a go over the weekend and hopefully fixes my issue as well. -- Dritan On January 23, 2023 6:54:03 PM EST, itsOnly1Jah @.> wrote: > Hi! @itsOnly1Jah - Could you share your config directory structure? > > > I am getting the same error on a fresh install and my configuration.nix, hardware-configuration.nix, and flake.nix are all in the same /etc/nixos directory. I store my flake in a .setup directory of my home folder like so. The only file that references the hardware-configurarion.nix is my configuration.nix file. ├── flake.lock ├── flake.nix ├── hosts │ ├── configuration.nix │ ├── default.nix │ ├── hardware-configuration.nix │ └── home.nix └── modules -- > Reply to this email directly or view it on GitHub: #1334 (comment) You are receiving this because you commented. Message ID: @.>

Hi my friend, I am a noob in nix but I find a solution on web which add system = "xxxxx" line

nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ....... ]; };

WaytrueDeng avatar Feb 03 '23 12:02 WaytrueDeng

If you're putting flake.nix and configuration.nix in the same place, make sure to import configuration.nix in flake.nix

twilightty avatar Feb 14 '23 12:02 twilightty

If you're putting flake.nix and configuration.nix in the same place, make sure to import configuration.nix in flake.nix

Do you mind clarifying what you mean here? I am new to NixOS and can't find an obvious way to import the configuration.nix in to the flake.nix.

Thanks!

blakeashleyjr avatar Apr 05 '23 04:04 blakeashleyjr

If you're putting flake.nix and configuration.nix in the same place, make sure to import configuration.nix in flake.nix

Do you mind clarifying what you mean here? I am new to NixOS and can't find an obvious way to import the configuration.nix in to the flake.nix.

Thanks!

Just add it to your nixosConfiguration modules is ok. such as this one (original flake comes from Hyprland Wiki)

# hyprland flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    hyprland.url = "github:hyprwm/Hyprland";
  };

  outputs = {nixpkgs, hyprland, ...}: {
    nixosConfigurations.aimi = nixpkgs.lib.nixosSystem {
      # ...
      modules = [
        hyprland.nixosModules.default
        {programs.hyprland.enable = true;}
        ./configuration.nix # Just like this, add the position of your configuration.nix to here
        # ...
      ];
    };
  };
}

aimixsaka avatar Apr 05 '23 06:04 aimixsaka