Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Um? That's trivial with flakes (and I think it was doable without flakes, but I don't really remember/care). For one-offs (I'd probably do this for your firefox example but YMMV), just tell it the version to run:

  $ nix run nixpkgs#firefox -- --version
  Mozilla Firefox 138.0.1
  $ nix run github:nixos/nixpkgs/nixos-unstable#firefox -- --version
  Mozilla Firefox 139.0.1
  $ nix run github:nixos/nixpkgs/b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa#firefox -- --version
  Mozilla Firefox 122.0.1
Or, if you want to actually incorporate it into your system, tell the system flake to pull whatever versions you want:

  {
    inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
        nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
        nixpkgs-b98a.url = "github:nixos/nixpkgs/b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa";
    };
    outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-b98a }: {
        nixosConfigurations.yourmachinename = nixpkgs.lib.nixosSystem {
            system = "x86_64-linux";
            specialArgs = {
                nixpkgs-unstable = import nixpkgs-unstable {
                    system = "x86_64-linux";
                };
                nixpkgs-b98a = import nixpkgs-b98a {
                    system = "x86_64-linux";
                };

            };
    ---snip---
and then when you pull packages say which one you want:

    packages = with pkgs; [
      dillo  # from stable nixpkgs
      nixpkgs-unstable.firefox  # from unstable
      nixpkgs-b98a.whatever  # from some exact commit of nixpkgs
    ]

I assume you could do the same thing for project-level flakes, but TBH I don't usually do that so I don't have the code to hand. (In contrast with grabbing system packages from whatever version of nixpkgs I want, which I know works because I pulled the example code from the config on the machine I'm typing this comment on.)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: