Last active
October 18, 2020 13:50
-
-
Save matthewbauer/7c57f8fb69705bb8da9741bf4b9a7e64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks.