Skip to content

Instantly share code, notes, and snippets.

@matthewbauer
Last active October 18, 2020 13:50
Show Gist options
  • Save matthewbauer/7c57f8fb69705bb8da9741bf4b9a7e64 to your computer and use it in GitHub Desktop.
Save matthewbauer/7c57f8fb69705bb8da9741bf4b9a7e64 to your computer and use it in GitHub Desktop.
# Usage: $ nix eval "(builtins.attrNames (import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs)"
# $ nix run "(import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs.\"24.3\"" -u LANG -c emacs
{ channels ? [ "19.03" "18.09" "18.03" "17.09" "17.03"
"16.09" "16.03" "15.09" "14.12" "14.04" "13.10" ]
, attrs ? builtins.attrNames (import <nixpkgs> {})
, system ? builtins.currentSystem
, args ? { inherit system; }
}: let
getSet = channel: (import (builtins.fetchTarball "channel:nixos-${channel}") args).pkgs;
getPkg = name: channel: let
pkgs = getSet channel;
pkg = pkgs.${name};
version = (builtins.parseDrvName pkg.name).version;
in if builtins.hasAttr name pkgs && pkg ? name then {
name = version;
value = pkg;
} else null;
in builtins.listToAttrs (map (name: {
inherit name;
value = builtins.listToAttrs
(builtins.filter (x: x != null)
(map (getPkg name) channels));
}) attrs)
@steshaw
Copy link

steshaw commented Sep 8, 2019

Nice, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment