Skip to content

Instantly share code, notes, and snippets.

@mausch
Forked from matthewbauer/generate-versions.nix
Last active October 18, 2020 15:09
Show Gist options
  • Save mausch/c3aec376c953bc26d3b32f2711dc96f9 to your computer and use it in GitHub Desktop.
Save mausch/c3aec376c953bc26d3b32f2711dc96f9 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
{}:
let
channels = [ "nixos-20.09" "nixos-20.03" "nixos-19.09" "nixpkgs-unstable" ];
getSet = channel: (import (builtins.fetchTarball "channel:${channel}") {inherit (builtins.currentSystem);}).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;
attrs = builtins.attrNames (import <nixpkgs> {});
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