Show default outputs (#452)

* Show default outputs

Following https://github.com/NixOS/nix/pull/6242, we now have access to
default outputs so we can single them out in the frontend.

We can also drop `--out-path`, which speeds up import quite a lot and
doesn't require increasing swap space or allowing broken/unfree
packages anymore.

* Use nixUnstable in CI

* Bump VERSION
This commit is contained in:
Naïm Favier 2022-03-27 15:52:54 +02:00 committed by GitHub
parent b2e0ce28fc
commit 5798bb000e
Failed to generate hash of commit
10 changed files with 28 additions and 19 deletions

View file

@ -6,7 +6,7 @@ inputs:
runs:
using: "composite"
steps:
- name: Installing Nix
uses: cachix/install-nix-action@v16
with:

View file

@ -45,11 +45,6 @@ jobs:
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }}
steps:
- name: Increase swap space
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 10
- name: Checking out the repository
uses: actions/checkout@v3
@ -58,6 +53,11 @@ jobs:
with:
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
- name: Installing Nix unstable
run: |
nix-env -f '<nixpkgs>' -iA nixVersions.unstable # for https://github.com/NixOS/nix/pull/6242
echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH"
- name: Import ${{ matrix.channel }} channel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1 +1 @@
27
28

View file

@ -1,2 +1,2 @@
[env]
MIN_NIX_VERSION = "2.7.0" # we need PRs #5878 and #5922 for package outputs
MIN_NIX_VERSION = "2.4.0" # flakes

View file

@ -26,6 +26,7 @@ let
version = drv.version or "";
outputs = drv.outputs;
# paths = builtins.listToAttrs ( map (output: {name = output; value = drv.${output};}) drv.outputs );
default_output = drv.outputName;
}
// lib.optionalAttrs (drv ? meta && drv.meta ? description) { inherit (drv.meta) description; }
// lib.optionalAttrs (drv ? meta && drv.meta ? license) { inherit (drv.meta) license; }

View file

@ -22,18 +22,9 @@ pub fn get_nixpkgs_info<T: AsRef<str> + Display>(nixpkgs_channel: T) -> Result<V
"import <nixpkgs/pkgs/top-level/packages-config.nix>",
"-qa",
"--meta",
"--out-path",
"--json",
]);
// Nix might fail to evaluate some disallowed packages
let mut env = HashMap::new();
env.insert("NIXPKGS_ALLOW_BROKEN".into(), "1".into());
env.insert("NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM".into(), "1".into());
env.insert("NIXPKGS_ALLOW_UNFREE".into(), "1".into());
env.insert("NIXPKGS_ALLOW_INSECURE".into(), "1".into());
command.env = env;
command.enable_capture();
command.log_to = LogTo::Log;
command.log_output_on_error = true;

View file

@ -71,6 +71,7 @@ pub enum Derivation {
package_pversion: String,
package_platforms: Vec<System>,
package_outputs: Vec<String>,
package_default_output: Option<String>,
package_license: Vec<License>,
package_license_set: Vec<String>,
package_maintainers: Vec<Maintainer>,
@ -125,6 +126,7 @@ impl From<(import::FlakeEntry, super::Flake)> for Derivation {
version,
platforms,
outputs,
default_output,
description,
license,
} => {
@ -159,6 +161,7 @@ impl From<(import::FlakeEntry, super::Flake)> for Derivation {
package_pversion: version,
package_platforms: platforms,
package_outputs: outputs,
package_default_output: Some(default_output),
package_license,
package_license_set,
package_description: description.clone(),
@ -255,6 +258,7 @@ impl From<import::NixpkgsEntry> for Derivation {
.map(Flatten::flatten)
.unwrap_or_default(),
package_outputs: package.outputs.into_keys().collect(),
package_default_output: package.default_output,
package_license,
package_license_set,
package_maintainers,

View file

@ -32,6 +32,7 @@ pub enum FlakeEntry {
version: String,
platforms: Vec<System>,
outputs: Vec<String>,
default_output: String,
description: Option<String>,
#[serde(deserialize_with = "string_or_struct", default)]
license: License,
@ -125,7 +126,9 @@ pub struct Package {
pub pname: String,
pub version: String,
#[serde(default)]
pub outputs: HashMap<String, String>,
pub outputs: HashMap<String, Option<String>>,
#[serde(rename = "outputName", default)]
pub default_output: Option<String>,
pub system: String,
#[serde(default)]
pub meta: Meta,

View file

@ -117,6 +117,9 @@ lazy_static! {
"package_outputs": {
"type": "keyword"
},
"package_default_output": {
"type": "keyword"
},
"package_description": {
"type": "text",
"analyzer": "english",

View file

@ -70,6 +70,7 @@ type alias ResultItemSource =
, pname : String
, pversion : String
, outputs : List String
, default_output : Maybe String
, description : Maybe String
, longDescription : Maybe String
, licenses : List ResultPackageLicense
@ -348,7 +349,12 @@ viewResultItem channel showInstallDetails show item =
++ optionals (List.length item.source.outputs > 1)
[ li []
(text "Outputs: "
:: (item.source.outputs
:: (item.source.default_output
|> Maybe.map (\d -> [ strong [] [ code [] [ text d ] ], text " " ])
|> Maybe.withDefault []
)
++ (item.source.outputs
|> List.filter (\o -> Just o /= item.source.default_output)
|> List.sort
|> List.map (\o -> code [] [ text o ])
|> List.intersperse (text " ")
@ -806,6 +812,7 @@ decodeResultItemSource =
|> Json.Decode.Pipeline.required "package_pname" Json.Decode.string
|> Json.Decode.Pipeline.required "package_pversion" Json.Decode.string
|> Json.Decode.Pipeline.required "package_outputs" (Json.Decode.list Json.Decode.string)
|> Json.Decode.Pipeline.required "package_default_output" (Json.Decode.nullable Json.Decode.string)
|> Json.Decode.Pipeline.required "package_description" (Json.Decode.nullable Json.Decode.string)
|> Json.Decode.Pipeline.required "package_longDescription" (Json.Decode.nullable Json.Decode.string)
|> Json.Decode.Pipeline.required "package_license" (Json.Decode.list decodeResultPackageLicense)