nix-community/NUR

Doesn't seem to work

nonetrix opened this issue · 8 comments

I followed the instructions however running nixos-rebuild test returns

/etc/nixosđź”’
❯ sudo nixos-rebuild test
building Nix...
building the system configuration...
error: NUR import call didn't receive a pkgs argument, but the evaluation of NUR's moredhel repository requires it.

       This is either because
         - You're trying to use a package from that repository, but didn't pass a `pkgs` argument to the NUR import.
           In that case, refer to the installation instructions at https://github.com/nix-community/nur#installation on how to properly import NUR

         - You're trying to use a module/overlay from that repository, but it didn't properly declare their module.
           In that case, inform the maintainer of the repository: https://github.com/moredhel/nur-packages
(use '--show-trace' to show detailed location information)

/etc/nixosđź”’ took 2s
❯

Here is the file that fails to build

{ config, pkgs, lib, ... }:
let
  # Import the global variables file
  global = import ../global-var.nix;
  nur-no-pkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {};
in {
  imports = [
    # Import home manager https://github.com/nix-community/home-manager
    <home-manager/nixos>
  ];
  
  # Configuration for the user specified in the global-var file
  home-manager.users.${global.username} = { pkgs, ...}: {
    imports = lib.attrValues nur-no-pkgs.repos.moredhel.hmModules.modules;
    cmacrae.programs.firefox.extensions =
    with pkgs.nur.repos.rycee.firefox-addons; [
      ublock-origin
      # "10ten-ja-reader"
      fastforward
      return-youtube-dislikes
      search-by-image
      sponsorblock
      stylus
      darkreader
      violentmonkey
      firefox-translations
    ];
  };
}

And here is my configuration.nix

#  ________         __                                 __         
# |  |  |  |.-----.|  |.----.-----.--------.-----.    |  |_.-----.
# |  |  |  ||  -__||  ||  __|  _  |        |  -__|    |   _|  _  |
# |________||_____||__||____|_____|__|__|__|_____|    |____|_____|
#                                                               
#                          ___ __ __                              
# .--------.--.--.       .'  _|__|  |.-----.-----.                
# |        |  |  |     __|   _|  |  ||  -__|__ --|                
# |__|__|__|___  |    |__|__| |__|__||_____|_____|                
#          |_____|                                                

{ config, pkgs, ... }:
let
  # Import the global variables file
  global = import ./global-var.nix;
in {
  # The version this configuration was made in
  home-manager.users.user.home.stateVersion = "23.05";
  system.stateVersion = "23.05"; 

  
  nixpkgs.config.packageOverrides = pkgs: {
    nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
      inherit pkgs;
    };
  };

  imports =
    [
      # Import home manager https://github.com/nix-community/home-manager
      <home-manager/nixos>  
      ./hardware-configuration.nix
      ./terminal/zsh.nix
      ./terminal/nvim.nix
      ./terminal/unconfigured.nix
      ./graphical/alacritty.nix
      ./graphical/tk-themes/gtk.nix
      ./graphical/tk-themes/qt.nix
      ./graphical/tk-themes/themes.nix
      ./graphical/i3.nix
      ./graphical/picom.nix
      ./graphical/fonts.nix
      ./graphical/codium.nix
      ./graphical/virt-manager.nix
      ./graphical/openrgb.nix
      ./graphical/unconfigured.nix
      ./graphical/firefox.nix
      ./misc/hosts.nix
      ./misc/udev.nix
      ./misc/default-programs.nix
      ./services/pipewire.nix
      ./services/xorg.nix
      ./services/polkit.nix
      ./services/podman.nix
      ./services/xdg-portal.nix
      ./services/flatpak.nix
      ./lanuage-support/keyboard/mozc.nix
    ];

  # Enable boot loader and set boot mount point
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  # Networking
  networking.hostName = "nixos";
  networking.networkmanager.enable = true;

  # Set time zone
  time.timeZone = "America/Chicago";

  # Set default locale
  i18n.defaultLocale = "en_US.UTF-8";

  # Set extra locale settings
  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };  

  # Create user with the name specified in the global-var file with Zsh shell, additional groups and no packages
  users.users.${global.username} = {
    isNormalUser = true;
    shell = pkgs.zsh;
    description = "user";
    extraGroups = [ "networkmanager" "wheel" "video" "audio" ];
    packages = with pkgs; [];
  };

  # Allow installing packages that are not free
  nixpkgs.config.allowUnfree = true;

  nix.settings.auto-optimise-store = true;
  
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 30d";
  };
}

Also I added

{
  packageOverrides = pkgs: {
    nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
      inherit pkgs;
    };
  };
}

As suggested for home manager in ~/.config/nixpkgs/config.nix however it's worth noting this folder and file didn't exist before I created it

Also, nix-shell -p nur.repos.mic92.hello-nur works fine

Please keep in mind I am newbie and most if not all of my knowledge of Nix and NixOS is just me naturally acquiring it

Also it would be great if there was a discussions section perhaps on this repository

Mic92 commented

If you want to discuss on the repository itself please use it's issue tracker. Here we only deal with general NUR questions.

Mic92 commented

Currently it's not clear to me if your evaluation fails on getting the firefox addons from NUR or the home-manager module. Can you comment out one or the other for clarification?

Mic92 commented

The attribute you are trying to use uses pkgs.lib and fails for that reason: https://github.com/moredhel/nur-packages/blob/0efec61d26ae2e84bf14fb4697e390cc971ca574/default.nix#L20
I think the home-manager example won't work anymore for that reason. There is rawModules in the same repository. I think this should still work than:

imports = lib.attrValues nur-no-pkgs.repos.moredhel.hmModules.rawModules;
Mic92 commented

fixed in #532

I seem to be getting this now

error: The option `home-manager.users.user.services.unison.enable' in `/nix/var/nix/profiles/per-user/root/channels/home-manager/modules/services/unison.nix' is already declared in `/nix/store/4jdp1n0xmazyay1gpw6z5d6pjrmhjzs5-source/home-manager/modules/unison.nix'.
{ config, pkgs, lib, ... }:
let
  # Import the global variables file
  global = import ../global-var.nix;
  nur-no-pkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {};
in {
  imports = [
    # Import home manager https://github.com/nix-community/home-manager
    <home-manager/nixos>
  ];



  
  
  # Configuration for the user specified in the global-var file
  home-manager.users.${global.username} = { pkgs, libs, ...}: {
    
  
    imports = lib.attrValues nur-no-pkgs.repos.moredhel.hmModules.rawModules;
    programs.firefox = {
      enable = true;
      # extensions =
      # with pkgs.nur.repos.rycee.firefox-addons; [
      #   ublock-origin
      #   # "10ten-ja-reader"
      #   fastforward
      #   return-youtube-dislikes
      #   search-by-image
      #   sponsorblock
      #   stylus
      #   darkreader
      #   violentmonkey
      #   firefox-translations
      # ];
    };
  };
}

I should have said this at the beginning but I am using home manager master branch and NixOS unstable

Mic92 commented

The issue your are seeing now is an issue with the particular nur repository having a conflict with home-manager. Please report the issue there as NUR does not do maintenance of user repository.