Skip to content

Commit

Permalink
Merge branch 'main' into mc/dolphin-emu
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewCroughan authored Nov 8, 2022
2 parents 53be9bf + f249d49 commit 43d40c2
Show file tree
Hide file tree
Showing 38 changed files with 16,578 additions and 7,650 deletions.
9 changes: 7 additions & 2 deletions .github/actions/common-setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Setup Environment
inputs:
GITHUB_TOKEN:
required: true
description: "GitHub access token used to prevent GitHub's rate limit for unauthenticated requests"
CACHIX_SIGNING_KEY: # determines what node version to install
required: true
description: 'Cachix Signing Key'
Expand All @@ -8,11 +11,13 @@ runs:
steps:

- name: Installing Nix
uses: cachix/install-nix-action@v16
uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
extra_nix_config: |
access-tokens = github.com=${{ inputs.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v10
- uses: cachix/cachix-action@v12
with:
name: nixos-search
signingKey: '${{ inputs.CACHIX_SIGNING_KEY }}'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-flake-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}


Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-flake-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}

- name: Try importing all custom flakes
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}


Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/import-to-elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}

- name: NixOS Channels
Expand All @@ -41,7 +42,7 @@ jobs:
env:
RUST_LOG: debug
FI_ES_EXISTS_STRATEGY: abort
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }}
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL2 }}

steps:
- name: Checking out the repository
Expand All @@ -50,6 +51,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}

- name: Import ${{ matrix.channel }} channel
Expand All @@ -62,7 +64,7 @@ jobs:
- name: Warmup ${{ matrix.channel }} channel
run: |
for (( i = 0; i < 3; i++ )) do
curl -sS ${{ secrets.ELASTICSEARCH_URL }}/latest-$(< VERSION)-nixos-${{ matrix.channel }}/_search | jq -c '.took // .'
curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(< VERSION)-nixos-${{ matrix.channel }}/_search | jq -c '.took // .'
done
if: github.repository_owner == 'NixOS'

Expand All @@ -79,7 +81,7 @@ jobs:
env:
RUST_LOG: debug
FI_ES_EXISTS_STRATEGY: recreate
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }}
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL2 }}

steps:

Expand All @@ -89,6 +91,7 @@ jobs:
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}

- name: Import ${{ matrix.group }} group
Expand All @@ -99,6 +102,6 @@ jobs:
- name: Warmup ${{ matrix.group }} group
run: |
for (( i = 0; i < 3; i++ )) do
curl -sS ${{ secrets.ELASTICSEARCH_URL }}/latest-$(< VERSION)-group-${{ matrix.group }}/_search | jq -c '.took // .'
curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(< VERSION)-group-${{ matrix.group }}/_search | jq -c '.took // .'
done
if: github.repository_owner == 'NixOS'
4 changes: 2 additions & 2 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v17
uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v10
uses: DeterminateSystems/update-flake-lock@v14
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ignore
logs
node_modules
npm-debug.log*
package-lock.json
repl-temp-*
result
src-url
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31
32
5 changes: 2 additions & 3 deletions flake-info/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions flake-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ structopt = "0.3"
command-run = "0.13"
env_logger = "0.9"
log = "0.4"
tempfile = "3"
lazy_static = "1.4"
fancy-regex = "0.6"
tokio = { version = "*", features = ["full"] }
reqwest = { version = "0.11", features = ["json", "blocking"] }
sha2 = "0.9"
pandoc = "0.8"
pandoc = "0.8.10"
semver = "1.0"

elasticsearch = {git = "https://github.com/elastic/elasticsearch-rs", features = ["rustls-tls"], optional = true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let
readPackages = system: drvs: lib.mapAttrsToList (
attribute_name: drv: (
{
entry_type = "package";
attribute_name = attribute_name;
system = system;
name = drv.name;
Expand All @@ -35,6 +36,7 @@ let
readApps = system: apps: lib.mapAttrsToList (
attribute_name: app: (
{
entry_type = "app";
attribute_name = attribute_name;
system = system;
}
Expand Down Expand Up @@ -86,6 +88,7 @@ let
x;
in
opt
// { entry_type = "option"; }
// applyOnAttr "default" substFunction
// applyOnAttr "example" substFunction # (_: { __type = "function"; })
// applyOnAttr "type" substFunction
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions flake-info/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ pkgs.rustPlatform.buildRustPackage rec {
libiconv
darwin.apple_sdk.frameworks.Security
];

checkInputs = with pkgs; [ pandoc ];


ROOTDIR = builtins.placeholder "out";
NIXPKGS_PANDOC_FILTERS_PATH = "${pkgs.path + "/doc/build-aux/pandoc-filters"}";

checkFlags = [
"--skip elastic::tests"
"--skip nix_gc::tests"
];

postInstall = ''
cp -rt "$out" assets
wrapProgram $out/bin/flake-info \
--set NIXPKGS_PANDOC_FILTERS_PATH "${NIXPKGS_PANDOC_FILTERS_PATH}" \
--set NIXOS_CHANNELS '${builtins.toJSON nixosChannels}' \
--prefix PATH : ${pkgs.pandoc}/bin
'';
Expand Down
7 changes: 7 additions & 0 deletions flake-info/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ pub use nix_check_version::{check_nix_version, NixCheckError};
pub use nix_flake_attrs::get_derivation_info;
pub use nix_flake_info::get_flake_info;
pub use nixpkgs_info::{get_nixpkgs_info, get_nixpkgs_options};

use lazy_static::lazy_static;
use std::path::PathBuf;

lazy_static! {
static ref EXTRACT_SCRIPT: PathBuf = crate::DATADIR.join("commands/flake_info.nix");
}
9 changes: 1 addition & 8 deletions flake-info/src/commands/nix_flake_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ use anyhow::{Context, Result};
use command_run::{Command, LogTo};
use serde_json::Deserializer;
use std::fmt::Display;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

const SCRIPT: &str = include_str!("flake_info.nix");
const ARGS: [&str; 4] = [
"eval",
"--json",
Expand All @@ -23,12 +20,8 @@ pub fn get_derivation_info<T: AsRef<str> + Display>(
temp_store: bool,
extra: &[String],
) -> Result<Vec<FlakeEntry>> {
let script_dir = tempfile::tempdir()?;
let script_path = script_dir.path().join("extract.nix");
writeln!(File::create(&script_path)?, "{}", SCRIPT)?;

let mut command = Command::with_args("nix", ARGS.iter());
command.add_arg_pair("-f", script_path.as_os_str());
command.add_arg_pair("-f", super::EXTRACT_SCRIPT.clone());
command.add_arg_pair("-I", "nixpkgs=channel:nixpkgs-unstable");
command.add_args(["--override-flake", "input-flake", flake_ref.as_ref()].iter());
command.add_args(["--argstr", "flake", flake_ref.as_ref()].iter());
Expand Down
23 changes: 5 additions & 18 deletions flake-info/src/commands/nixpkgs_info.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use anyhow::{Context, Result};
use serde_json::Deserializer;
use std::io::Write;
use std::{collections::HashMap, fmt::Display, fs::File};
use std::{collections::HashMap, fmt::Display};

use command_run::{Command, LogTo};
use log::error;

use crate::data::import::{NixOption, NixpkgsEntry, Package};

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(&[
Expand Down Expand Up @@ -54,20 +51,10 @@ pub fn get_nixpkgs_info<T: AsRef<str> + Display>(nixpkgs_channel: T) -> Result<V
pub fn get_nixpkgs_options<T: AsRef<str> + Display>(
nixpkgs_channel: T,
) -> Result<Vec<NixpkgsEntry>> {
let script_dir = tempfile::tempdir()?;
let script_path = script_dir.path().join("flake_info.nix");
writeln!(File::create(&script_path)?, "{}", FLAKE_INFO_SCRIPT)?;

let mut command = Command::new("nix");
command.add_args(&[
"eval",
"--json",
"-f",
script_path.to_str().unwrap(),
"-I",
format!("nixpkgs={}", nixpkgs_channel.as_ref()).as_str(),
"nixos-options",
]);
let mut command = Command::with_args("nix", &["eval", "--json"]);
command.add_arg_pair("-f", super::EXTRACT_SCRIPT.clone());
command.add_arg_pair("-I", format!("nixpkgs={}", nixpkgs_channel.as_ref()));
command.add_arg("nixos-options");

command.enable_capture();
command.log_to = LogTo::Log;
Expand Down
Loading

0 comments on commit 43d40c2

Please sign in to comment.