NUR
NUR copied to clipboard
No documentation on how to use the NUR with Home manager flakes
There's a section on how to do it with on Home manager without a flake and NixOS with a flake but now Home mananger with a flake.
I ran into this myself. Tried a couple different approaches and the only one that worked for me was this example.
Is that the canonical approach? If so I can take a stab at a PR updating the documentation with an example.
This is what I use:
(inputs.home-manager.lib.homeManagerConfiguration {
modules = [
inputs.nur.hmModules.nur
];
})
https://github.com/Mic92/dotfiles/blob/9b76629067bafa543715ed97916b1b6a316171bc/home-manager/flake-module.nix
I ran into this myself. Tried a couple different approaches and the only one that worked for me was this example.
Is that the canonical approach? If so I can take a stab at a PR updating the documentation with an example.
I tried that one and haven't been able to get it to work for me for some reason.
@gBasil here's the configuration I landed on for comparison.
I've tried shoving as many different configurations into the flake as possible. I don't know whether the nixos-m1-overlay
is messing with things.
(note, this is not a working setup, at least for me)
flake.nix
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Don't be fooled: The NUR doesn't work in this configuration for some reason
nur.url = "github:nix-community/NUR";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Asahi compatibility
nixos-m1-overlay = {
url = "github:tpwrules/nixos-apple-silicon";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, nur, home-manager, nixos-m1-overlay, ... }@inputs:
let
pkgs = import nixpkgs {
overlays = [
nixos-m1-overlay.overlays.default
nur.overlay
];
};
in
{
nixosConfigurations = {
mikubook = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
./configuration.nix
nixos-m1-overlay.nixosModules.default
nur.nixosModules.nur
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# home-manager.users.basil = import ./users/basil.nix;
home-manager.users.basil = {
imports = [ ./users/basil.nix ];
# import ./users/basil.nix;
_module.args.nur = { inherit nur; };
};
nixpkgs.overlays = [
nixos-m1-overlay.overlays.default
nur.overlay
];
_module.args.nur = { inherit nur; };
}
];
};
};
};
}
users/basil.nix
{ config, lib, pkgs, ... }:
let
someVar = 0;
in {
imports = [ ../packages/vscodium.nix ../packages/firefox.nix ];
programs.firefox.profiles.basil.extensions = with pkgs.nur.repos.rycee.nur; [
ublock-origin
];
// other stuff is in here too
}
When running sudo nixos-rebuild switch
, it gives the attribute 'nur' missing
error on the programs.firefox.profiles.basil.extensions
line. I've no clue what I'm doing wrong.
(sorry for hijacking this issue!)
Edit
While this doesn't solve the issue, my solution was to sidestep the NUR and just use the flake in the one repository I wanted, which meant adding firefox-addons.url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons";
to the flake inputs and then using with inputs.firefox-addons.packages.aarch64-linux
(aarch64-linux
should be replaced with your architecture) in the with
statement.
Any updates?
Any updates?
Well, I have a working config now, though I didn't try out the nur overlay. That might be a better solution.
My config, with all the parts not needed for my home manager config taken out:
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nur, home-manager, ... }:
let
stateVersion = "23.11";
in {
homeConfigurations = {
"annaaurora@LenOwO" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."x86_64-linux";
modules = [
{ home = { inherit stateVersion; }; }
./users/common/home.nix
./users/annaaurora/home.nix
./users/annaaurora/hosts/LenOwO/home.nix
nur.hmModules.nur
];
};
};
};
}
@gBasil Why are you doing the nixpkgs overlay twice?
Using NUR with home manager in a flake is not that different from using NUR in a NixOS flake. You just put nur.hmModules.nur
into the modules or use the same nixpkgs with the overlay, right?
With nur.hmNodules.nur
I can access the firefox addons with config.nur.repos.rycee.firefox-addons
e.g.
The best option seems to be the overlay. Then you can use the NixOS modules from NUR too without infinite recursion according to https://nur.nix-community.org/documentation/#using-the-flake-in-nixos.
But I'm not sure if newbies understand that it's kind of the same process, so it might be a good idea to explain this in the docs.
Here's an example that worked for me, using Home Manager as a NixOS module and flakes. Adding nur.hmModules.nur
to homeManager.sharedModules
did the trick for me:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/NUR";
};
outputs = { self, nixpkgs, home-manager, nur, ... }@inputs: {
nixosConfigurations = {
"nixos" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nur.nixosModules.nur
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.ekisu = import ./home.nix;
home-manager.sharedModules = [ nur.hmModules.nur ];
}
];
};
};
};
}
Using NUR with home manager in a flake is not that different from using NUR in a NixOS flake. You just put
nur.hmModules.nur
into the modules or use the same nixpkgs with the overlay, right?With
nur.hmNodules.nur
I can access the firefox addons withconfig.nur.repos.rycee.firefox-addons
e.g.The best option seems to be the overlay. Then you can use the NixOS modules from NUR too without infinite recursion according to https://nur.nix-community.org/documentation/#using-the-flake-in-nixos.
But I'm not sure if newbies understand that it's kind of the same process, so it might be a good idea to explain this in the docs.
I agree with @auroraanna. Some more detailed explanation in the README would really help
I FINALLY got it to work with my config, I did the following:
# flake.nix
{
inputs = {
# TODO: Try to move to stable version someday if packages not being packaged are not issue in future
# Main package repo unstable verrsion
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Allows for changing user configs
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland.url = "github:hyprwm/Hyprland";
# TODO: Remove fork once merged
# This allows for workspaces to be split with multiple monitors, often breaks with Hyprland updates
hyprsplit = {
url = "github:shezdy/hyprsplit";
inputs.hyprland.follows = "hyprland";
};
# Extra packages not in Nixpkgs
nur.url = "github:nix-community/NUR";
};
outputs = {
nixpkgs,
home-manager,
nur,
...
} @ inputs: let
system = "x86_64-linux";
in {
nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
system = "x86_64-linux";
modules = [
./configuration.nix
# Allows for home manager to be used
nur.nixosModules.nur
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ nur.hmModules.nur ];
};
}
];
};
};
};
}
Then
{inputs, pkgs, config, ...}: let
global = import ../global-var.nix;
in {
home-manager.users.${global.username} = {pkgs, ...}: {
programs.firefox = {
enable = true;
profiles.test = {
extensions = with config.nur.repos.rycee.firefox-addons; [
ublock-origin
];
};
};
};
}
Only error I am getting now is a conflicting file, so I guess I might have to reset my browser which kinda sucks