While setting up a new workstation I noticed a few core apps (the Swiss Proton suite of apps) are running behind in updates quite a bit. Since the new versions have both features and security patches I went looking for a way to get them from the unstable nixpkgs instead. The ones I’m trying this with are Electron-wrapped apps making me fairly confident mixing them with stable won’t do any harm.
I found this thread and have been trying to implement @waffle8946’s answer into my flake with the packages being in home-manager. I chose to make a new thread rather than necro that one.
I’ll only post the relevant parts of my configs, obviously. Feel free to ask for more if required.
I started with this in my flake.nix:
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-26.05/nixexprs.tar.xz";
nixpkgs-unstable.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
home-manager = {
url = "github:nix-community/home-manager/release-26.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ...} @inputs:
let
lib = nixpkgs.lib;
in {
nixosConfiguration = {
workstation = lib.nixosSystem {
system = "x86_64-linux";
modules = [
.\configuration.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs; };
users.name = ./home.nix;
};
};
];
};
};
};
I figured I only need to add specialArgs above modules if I also want to use it outside of home-manager.
Questions:
- Do I or do I not add
nixpkgs-unstableto theoutputsline{ self, nixpkgs, nixpkgs-unstable, home-manager, ... }? I only need it if I use it in that same scriptblock, right? I know I need@inputseither way so its purpose might not be clear to me. - Unrelated, but I switched to the non-Github channel-tarballs since that’s apparently recommended and am wondering if home-manager has those as well.
Next, the home.nix:
{ config, inputs, pkgs, pkgsUnstable, ... }:
{
_module.args.pkgsUnstable = import inputs.nixpkgs-unstable {
inherit (pkgs.stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
home = {
packages = [
pkgsUnstable.proton-pass
];
};
}
Now, doing this leads to an error: In module 'nixpkgs.config', you're trying to define a value of type 'null' rather than an attribute set for the option ''!. This usually happens if '' has option definitions inside that are not matched.
If I comment out the inherit (config.nixpkgs) config; it appears to build successfully and I have the app version I was expecting.
Questions:
- Any idea what is causing the error and how to best deal with it?
- In this case I added
pkgsUnstableon the top line because I am using it further down the file. That said, my scripting brain is telling me thatpkgsUnstableis only defined later down the file so it does nothing up there. Guess it is required and it’s another thing I don’t understand? - Is the
(with pkgs; [ stable-package ]) ++ (with pkgsUnstable; [ unstable-package ]);the cleanest way to combine both in the same file without having to prefix every package? I see a several mentions in the other thread usingwith pkgsand then prefixing a package withpkgsUnstable.but once again my scripting brain tells me that will resolve topkgs.pkgsUnstable.and error out.
As always, if anybody has suggestions on how to do this better/cleaner I am happy for the advice. If I’m going to keep using NixOS I need to keep my configs as intuitive and clean as possible.