Rely on upstream for extracting nixpkgs options (#460)
* flake-info: rely on upstream for extracting nixpkgs options Use the `options.json` generated in nixpkgs to be more in sync with the manual. Also fixes usage of `nixpkgs-archive` with local paths. * Bump VERSION
This commit is contained in:
parent
3b41f2dcfd
commit
d0ea61ad4e
|
@ -1,6 +1,6 @@
|
|||
{ flake }:
|
||||
{ flake ? null }:
|
||||
let
|
||||
resolved = builtins.getFlake (toString flake);
|
||||
resolved = builtins.getFlake "input-flake";
|
||||
|
||||
nixpkgs = (import <nixpkgs> {});
|
||||
lib = nixpkgs.lib;
|
||||
|
@ -93,7 +93,7 @@ let
|
|||
flake = modulePath;
|
||||
};
|
||||
in
|
||||
map (cleanUpOption extraAttrs) (lib.filter (x: !x.internal) opts);
|
||||
map (cleanUpOption extraAttrs) (lib.filter (x: x.visible && !x.internal) opts);
|
||||
|
||||
readFlakeOptions = let
|
||||
nixosModulesOpts = builtins.concatLists (lib.mapAttrsToList (moduleName: module:
|
||||
|
@ -144,8 +144,10 @@ rec {
|
|||
packages = lib.attrValues (collectSystems packages');
|
||||
apps = lib.attrValues (collectSystems apps');
|
||||
options = readFlakeOptions;
|
||||
nixos-options = readOptions {
|
||||
module = import "${builtins.fetchTarball { url = flake; }}/nixos/modules/module-list.nix";
|
||||
};
|
||||
all = packages ++ apps ++ options;
|
||||
|
||||
# nixpkgs-specific, doesn't use the flake argument
|
||||
nixos-options = lib.mapAttrsToList (name: option: option // { inherit name; })
|
||||
(builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile
|
||||
"${(import <nixpkgs/nixos/release.nix> {}).options}/share/doc/nixos/options.json")));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ pub fn get_derivation_info<T: AsRef<str> + Display>(
|
|||
|
||||
let mut command = Command::with_args("nix", ARGS.iter());
|
||||
command.add_arg_pair("-f", script_path.as_os_str());
|
||||
command.add_args(["--arg", "flake", flake_ref.as_ref()].iter());
|
||||
command.add_args(["--override-flake", "input-flake", flake_ref.as_ref()].iter());
|
||||
command.add_args(["--argstr", "flake", flake_ref.as_ref()].iter());
|
||||
command.add_arg(kind.as_ref());
|
||||
if temp_store {
|
||||
let temp_store_path = PathBuf::from("/tmp/flake-info-store");
|
||||
|
|
|
@ -13,6 +13,7 @@ const FLAKE_INFO_SCRIPT: &str = include_str!("flake_info.nix");
|
|||
pub fn get_nixpkgs_info<T: AsRef<str> + Display>(nixpkgs_channel: T) -> Result<Vec<NixpkgsEntry>> {
|
||||
let mut command = Command::new("nix-env");
|
||||
command.add_args(&[
|
||||
"--json",
|
||||
"-f",
|
||||
"<nixpkgs>",
|
||||
"-I",
|
||||
|
@ -22,7 +23,6 @@ pub fn get_nixpkgs_info<T: AsRef<str> + Display>(nixpkgs_channel: T) -> Result<V
|
|||
"import <nixpkgs/pkgs/top-level/packages-config.nix>",
|
||||
"-qa",
|
||||
"--meta",
|
||||
"--json",
|
||||
]);
|
||||
|
||||
command.enable_capture();
|
||||
|
@ -66,9 +66,6 @@ pub fn get_nixpkgs_options<T: AsRef<str> + Display>(
|
|||
script_path.to_str().unwrap(),
|
||||
"-I",
|
||||
format!("nixpkgs={}", nixpkgs_channel.as_ref()).as_str(),
|
||||
"--arg",
|
||||
"flake",
|
||||
nixpkgs_channel.as_ref(),
|
||||
"nixos-options",
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue