Clarification on unstable nixpkgs (and pkgs in general) with a flake

I just noticed something in my setup.

In my flake (inputs), I have nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";.

Then elsewhere in a module, I have an app installed with:

environment.systemPackages = with pkgs; [
    _1password-gui
    _1password
];

Then, I also have:

programs._1password = { enable = true; };

  # Enable the 1Passsword GUI with myself as an authorized user for polkit
  programs._1password-gui = {
    enable = true;
    polkitPolicyOwners = [ "dustin" ];
  };

So, my clarifying questions:

  • if I have programs._1password-gui.enable = true;, do I actually need to install under environment.systemPackages = with pkgs; [ ? Do I need both?
  • In my flake, I have the nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";, why is the version of _1password-gui installed from stable and not unstable as I specified in my flake?

I appreciate the time of everyone. Thank you.

With those settings enabled, you do not also need to have the package installed manually. If you read where the options are defined in Nixpkgs you can find lines like this:

  config = mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

where cfg.package refers to the package for the program being enabled. This is adding the package for you if the option is enabled.

I can’t say why your package would be installed from stable without some more information. Maybe your inputs are just out of date? They can be updated with nix flake update.

1 Like

How did you determine that?

I went into the “about” in the GUI app. Unstable is currently 8.10.7.

Question, is nix flake update the same as running sudo nixos-rebuild switch --upgrade --flake .#HOSTNAME?

No. nix flake update only updates the flake. nixos-rebuild switch --upgrade will update channels and switch the system. But flakes are not using channels so the --upgrade flag is useless for you.

1 Like

well, I sure have been going that wrong then! So the proper way for me to update everything would actually be nix flake update && sudo nixos-rebuild switch --flake .#HOSTNAME. Maybe that’s why I have the older app. Testing.

Yup, this fixed it. I likely had .6 when it was in unstable, “thought” I was updating properly, and when it all shifted from .6.7, just appeared like I have “stable”.

1 Like