Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rely on upstream for extracting nixpkgs options #460

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
30
31
14 changes: 8 additions & 6 deletions flake-info/src/commands/flake_info.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ flake }:
{ flake ? null }:
let
resolved = builtins.getFlake (toString flake);
resolved = builtins.getFlake "input-flake";

nixpkgs = (import <nixpkgs> {});
lib = nixpkgs.lib;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")));
}
3 changes: 2 additions & 1 deletion flake-info/src/commands/nix_flake_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 1 addition & 4 deletions flake-info/src/commands/nixpkgs_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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();
Expand Down Expand Up @@ -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",
]);

Expand Down