How do I update packages with home-manager

I used Vimjoyer’s Ultimate NixOS Guide with flakes and Home-manager to guide my configuration.

This seemed to be working when I had my packages in configuration.nix but when I moved them to home.nix I can’t seem to update yt-dlp to the latest version.

I’m running this to update:
sudo nixos-rebuild switch --flake /home/sergio/nixos-config#oak --upgrade

I see yt-dlp is at 2024.8.1 but my version is 2024.04.09

This is certainly me using a setup that I don’t fully understand, and I barely understood how to update things. I’m very open to any other links or reading material showing what you think may be a better way to configure things.

Since you’re using flakes, packages are pulled from the inputs.nixpkgs that you set at the top of your flake.nix. Flakes use the current lock file flake.lock to know what version of nixpkgs to pull. If you want to update all your inputs (including nixpkgs), you can do nix flake update, which should also update nixpkgs in your inputs. Then - you can do a nixos-rebuild switch.

Thanks for the input. That is what I’ve been doing, but nothing seems to be updating. Namely yt-dlp at the moment.

Does your flake.lock file change after you executed nix flake update?

flake.lock does not get updated:

[sergio@oak:~/nixos-config]$ ls -l
total 48
-rw-r--r-- 1 sergio users  1143 Aug  2 11:04 flake.lock
-rw-r--r-- 1 sergio users   886 Aug  2 11:03 flake.nix
drwxr-xr-x 1 sergio users    18 Jun 30 13:05 hosts
-rw-r--r-- 1 sergio users 33949 Jun 30 13:05 LICENSE
drwxr-xr-x 1 sergio users    76 Aug  2 21:48 modules
-rw-r--r-- 1 sergio users    41 Jun 30 13:05 README.md

[sergio@oak:~/nixos-config]$ nix flake update 
warning: Git tree '/home/sergio/nixos-config' is dirty

[sergio@oak:~/nixos-config]$ ls -l
total 48
-rw-r--r-- 1 sergio users  1143 Aug  2 11:04 flake.lock
-rw-r--r-- 1 sergio users   886 Aug  2 11:03 flake.nix
drwxr-xr-x 1 sergio users    18 Jun 30 13:05 hosts
-rw-r--r-- 1 sergio users 33949 Jun 30 13:05 LICENSE
drwxr-xr-x 1 sergio users    76 Aug  2 21:48 modules
-rw-r--r-- 1 sergio users    41 Jun 30 13:05 README.md

This is my full flake.nix file:

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/24.05";

    home-manager = {
      url = "github:nix-community/home-manager/release-24.05";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      nixosConfigurations = {
        samara = nixpkgs.lib.nixosSystem {
          specialArgs = {inherit inputs;};
          modules = [
            ./hosts/samara/configuration.nix
            inputs.home-manager.nixosModules.default
          ];
        };
        oak = nixpkgs.lib.nixosSystem {
          specialArgs = {inherit inputs;};
          modules = [
            ./hosts/oak/configuration.nix
            inputs.home-manager.nixosModules.default
          ];
        };
      };
    };
}

I thought to remove the /release-24.05 part from the home-manager.url, but that seems to get me into other trouble when running sudo nixos-rebuild switch --flake /home/sergio/nixos-config#oak --upgrade

trace: warning: sergio profile: You are using

  Home Manager version 24.11 and
  Nixpkgs version 24.05.

Using mismatched versions is likely to cause errors and unexpected
behavior. It is therefore highly recommended to use a release of Home
Manager that corresponds with your chosen release of Nixpkgs.

If you insist then you can disable this warning by adding

  home.enableNixpkgsReleaseCheck = false;

to your configuration.

Wonder if I should try to remove the /24.05 from inputs.nixpkgs.url as well. Though that may not bode well.

I think your input URL might be pointing at the wrong thing, eg this:

    nixpkgs.url = "github:nixos/nixpkgs/24.05";

Should be:

    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";

Here are the channels that you should be using: Nix channels - NixOS Wiki

1 Like

Yup, me being a noob. Thanks! All set and updated now.

So now I just needed to run nix flake update and then nixos-rebuild switch and everything is up to date. :partying_face: