Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixos-search
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6936bcd658bbcc378c8469d7869b8ed9c83f2460
Choose a base ref
..
head repository: NixOS/nixos-search
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e987b1cfce5a73145a5125555aa5172bd7cffbd4
Choose a head ref
Showing with 892 additions and 9,491 deletions.
  1. +2 −7 .github/actions/common-setup/action.yml
  2. +1 −1 .github/workflows/build-flake-info.yml
  3. +1 −1 .github/workflows/check-flake-files.yml
  4. +2 −1 .github/workflows/frontend.yml
  5. +3 −3 .github/workflows/import-to-elasticsearch.yml
  6. +2 −2 .github/workflows/update-flake-lock.yml
  7. +20 −0 COPYING
  8. +1 −1 flake-info/README.md
  9. +1 −1 flake-info/src/commands/nix_flake_attrs.rs
  10. +1 −1 flake-info/src/data/import.rs
  11. +98 −13 flake-info/src/data/prettyprint.rs
  12. +47 −13 flake.lock
  13. +16 −7 flake.nix
  14. +0 −34 flakes/manual.toml
  15. +2 −2 frontend/config/webpack.common.js
  16. +8 −9 frontend/config/webpack.dev.js
  17. +1 −1 frontend/config/webpack.prod.js
  18. +61 −36 frontend/elm-srcs.nix
  19. +40 −35 frontend/elm.json
  20. +48 −9,220 frontend/package-lock.json
  21. +3 −0 frontend/package.json
  22. BIN frontend/registry.dat
  23. +49 −28 frontend/src/Main.elm
  24. +7 −5 frontend/src/Page/Packages.elm
  25. +43 −25 frontend/src/Search.elm
  26. +9 −0 frontend/src/assets/bootstrap-responsive.min.css
  27. +9 −0 frontend/src/assets/bootstrap.min.css
  28. +1 −1 frontend/src/assets/desc-search-options.xml
  29. +1 −1 frontend/src/assets/desc-search-packages.xml
  30. BIN frontend/src/assets/favicon.png
  31. BIN frontend/src/assets/images/glyphicons-halflings-white.png
  32. BIN frontend/src/assets/images/glyphicons-halflings.png
  33. BIN frontend/src/assets/images/nix-logo.png
  34. BIN frontend/src/assets/img/glyphicons-halflings.png
  35. +11 −11 frontend/src/index.html
  36. +1 −0 frontend/src/index.js
  37. +401 −30 frontend/src/index.scss
  38. +2 −2 frontend/tests/Example.elm
9 changes: 2 additions & 7 deletions .github/actions/common-setup/action.yml
Original file line number Diff line number Diff line change
@@ -11,18 +11,13 @@ runs:
steps:

- name: Installing Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
extra_nix_config: |
access-tokens = github.com=${{ inputs.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
- uses: cachix/cachix-action@v15
with:
name: nixos-search
signingKey: '${{ inputs.CACHIX_SIGNING_KEY }}'

- name: Installing jq
shell: bash
run: |
nix-env -f '<nixpkgs>' -iA jq
2 changes: 1 addition & 1 deletion .github/workflows/build-flake-info.yml
Original file line number Diff line number Diff line change
@@ -27,4 +27,4 @@ jobs:

- name: Building flake-info
run: |
nix -vL build .#flake-info
nix --accept-flake-config -vL build .#flake-info
2 changes: 1 addition & 1 deletion .github/workflows/check-flake-files.yml
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ jobs:
do
echo "::group::Group \"$(basename $flake_group .toml)\""
nix run .#flake-info -- group "$flake_group" "$(basename "$flake_group" .toml)" --report
nix run --accept-flake-config .#flake-info -- --json group "$flake_group" "$(basename "$flake_group" .toml)" --report
if [[ -f "./report.txt" ]]
then
3 changes: 2 additions & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Frontend: Build & Deploy to Netlify"
on:
workflow_dispatch:
pull_request:
paths:
- "flake.nix"
@@ -33,7 +34,7 @@ jobs:
cp -RL ./result/* ./dist/
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v2.0
uses: nwtgck/actions-netlify@v3.0
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
6 changes: 3 additions & 3 deletions .github/workflows/import-to-elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ jobs:
- name: NixOS Channels
id: nixos-channels
run: |
nix build -L .#nixosChannels
nix build --accept-flake-config -L .#nixosChannels
channels="{\"channel\": $(< ./result)}"
echo "$channels"
echo "matrix=$channels" >> "$GITHUB_OUTPUT"
@@ -62,7 +62,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
nix run .#flake-info -- --push --elastic-schema-version=$(< VERSION) nixpkgs ${{ matrix.channel }}
nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(< VERSION) nixpkgs ${{ matrix.channel }}
if: github.repository_owner == 'NixOS'

- name: Warmup ${{ matrix.channel }} channel
@@ -110,7 +110,7 @@ jobs:

- name: Import ${{ matrix.group }} group
run: |
nix run .#flake-info -- --push --elastic-schema-version=$(< ./VERSION) group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }}
nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(< ./VERSION) group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }}
if: github.repository_owner == 'NixOS'

- name: Warmup ${{ matrix.group }} group
4 changes: 2 additions & 2 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v23
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v19
uses: DeterminateSystems/update-flake-lock@v22
20 changes: 20 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2020-2024 Rok Garbas and the nixos-search contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion flake-info/README.md
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ An example `targets.json` file can look like the following
```

```
$ flake-info group ./targets.json small-group
$ flake-info --json group ./targets.json small-group
```

### Elasticsearch
2 changes: 1 addition & 1 deletion flake-info/src/commands/nix_flake_attrs.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ pub fn get_derivation_info<T: AsRef<str> + Display>(
) -> Result<Vec<FlakeEntry>> {
let mut command = Command::with_args("nix", ARGS.iter());
command.add_arg_pair("-f", super::EXTRACT_SCRIPT.clone());
command.add_arg_pair("-I", "nixpkgs=channel:nixpkgs-unstable");
command.add_arg_pair("-I", "nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz");
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());
2 changes: 1 addition & 1 deletion flake-info/src/data/import.rs
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ impl Serialize for DocValue {
md.to_owned()
}))
}
DocValue::Value(v) => serializer.serialize_str(&print_value(v.to_owned())),
DocValue::Value(v) => serializer.serialize_str(&print_value(v)),
}
}
}
111 changes: 98 additions & 13 deletions flake-info/src/data/prettyprint.rs
Original file line number Diff line number Diff line change
@@ -15,11 +15,24 @@ impl Display for Indent {
}
}

pub fn print_value(value: Value) -> String {
pub fn print_value(value: &Value) -> String {
print_value_indent(value, Indent(0))
}

fn print_value_indent(value: Value, indent: Indent) -> String {
/// Formats an attrset key by adding quotes when necessary
fn format_attrset_key(key: &str) -> String {
if key.contains("/")
|| key.contains(" ")
|| key.is_empty()
|| (b'0'..=b'9').contains(&key.as_bytes()[0])
{
format!("{:?}", key)
} else {
key.to_string()
}
}

fn print_value_indent(value: &Value, indent: Indent) -> String {
match value {
Value::Null => "null".to_owned(),
Value::Bool(b) => format!("{}", b),
@@ -44,6 +57,14 @@ fn print_value_indent(value: Value, indent: Indent) -> String {
if a.is_empty() {
return "[ ]".to_owned();
}
if a.len() == 1 {
// Return early if the wrapped value fits on one line
let val = print_value(a.first().unwrap());
if !val.contains("\n") {
return format!("[ {} ]", val);
}
}

let items = a
.into_iter()
.map(|v| print_value_indent(v, indent.next()))
@@ -63,9 +84,26 @@ fn print_value_indent(value: Value, indent: Indent) -> String {
if o.is_empty() {
return "{ }".to_owned();
}
if o.len() == 1 {
// Return early if the wrapped value fits on one line
let val = print_value(o.values().next().unwrap());
if !val.contains("\n") {
return format!(
"{{ {} = {}; }}",
format_attrset_key(o.keys().next().unwrap()),
val
);
}
}
let items = o
.into_iter()
.map(|(k, v)| format!("{} = {}", k, print_value_indent(v, indent.next())))
.map(|(k, v)| {
format!(
"{} = {}",
format_attrset_key(&k),
print_value_indent(v, indent.next())
)
})
.collect::<Vec<_>>()
.join(&format!(";\n{}", indent.next()));

@@ -90,7 +128,7 @@ mod tests {
#[test]
fn test_string() {
let json = json!("Hello World");
assert_eq!(print_value(json), "\"Hello World\"");
assert_eq!(print_value(&json), "\"Hello World\"");
}

#[test]
@@ -101,7 +139,7 @@ World
!!!"#
);
assert_eq!(
print_value(json),
print_value(&json),
r#"''
Hello
World
@@ -113,26 +151,46 @@ World
#[test]
fn test_num() {
let json = json!(1);
assert_eq!(print_value(json), "1");
assert_eq!(print_value(&json), "1");
}

#[test]
fn test_bool() {
let json = json!(true);
assert_eq!(print_value(json), "true");
assert_eq!(print_value(&json), "true");
}

#[test]
fn test_empty_list() {
let json = json!([]);
assert_eq!(print_value(json), "[ ]");
assert_eq!(print_value(&json), "[ ]");
}

#[test]
fn test_list_one_item() {
let json = json!([1]);
assert_eq!(print_value(&json), "[ 1 ]");
}

#[test]
fn test_list_one_multiline_item() {
let json = json!(["first line\nsecond line"]);
assert_eq!(
print_value(&json),
r#"[
''
first line
second line
''
]"#
);
}

#[test]
fn test_filled_list() {
let json = json!([1, "hello", true, null]);
assert_eq!(
print_value(json),
print_value(&json),
r#"[
1
"hello"
@@ -145,15 +203,42 @@ World
#[test]
fn test_empty_set() {
let json = json!({});
assert_eq!(print_value(json), "{ }");
assert_eq!(print_value(&json), "{ }");
}

#[test]
fn test_set_one_item() {
let json = json!({ "hello": "world" });
assert_eq!(print_value(&json), "{ hello = \"world\"; }");
}

#[test]
fn test_set_number_key() {
let json = json!({ "1hello": "world" });
assert_eq!(print_value(&json), "{ \"1hello\" = \"world\"; }");
}

#[test]
fn test_set_one_multiline_item() {
let json = json!({ "hello": "pretty\nworld" });
assert_eq!(
print_value(&json),
"{
hello = ''
pretty
world
'';
}"
);
}

#[test]
fn test_filled_set() {
let json = json!({"hello": "world"});
let json = json!({"hello": "world", "another": "test"});
assert_eq!(
print_value(json),
print_value(&json),
"{
another = \"test\";
hello = \"world\";
}"
);
@@ -176,7 +261,7 @@ World
]);

assert_eq!(
print_value(json),
print_value(&json),
r#"[
"HDMI-0"
{
Loading