depot/third_party/nixpkgs/pkgs/tools/nix/nix-init/license.nix
Default email a0cb138ada Project import generated by Copybara.
GitOrigin-RevId: a100acd7bbf105915b0004427802286c37738fef
2023-02-02 18:25:31 +00:00

23 lines
628 B
Nix

# vendored from src/licenses.nix
{ lib, writeText }:
let
inherit (builtins) concatLists concatStringsSep length;
inherit (lib) flip licenses mapAttrsToList optional;
inserts = concatLists
(flip mapAttrsToList licenses
(k: v: optional (v ? spdxId) '' xs.insert("${v.spdxId}", "${k}");''));
in
writeText "license.rs" ''
fn get_nix_licenses() -> rustc_hash::FxHashMap<&'static str, &'static str> {
let mut xs = std::collections::HashMap::with_capacity_and_hasher(
${toString (length inserts)},
Default::default(),
);
${concatStringsSep "\n " inserts}
xs
}
''