Skip to content

Commit

Permalink
Replace ad-hoc command-not-found generation scripts with nix-index
Browse files Browse the repository at this point in the history
This is much, MUCH faster than the existing solution, especially on large channels.
It can be made even faster if we actually reuse anything whatsoever, but this is
a massive improvement in itself.
  • Loading branch information
K900 committed Jan 12, 2023
1 parent d5c5417 commit 8656f3e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 470 deletions.
181 changes: 0 additions & 181 deletions file-cache.hh

This file was deleted.

53 changes: 46 additions & 7 deletions flake.lock

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

20 changes: 8 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
description = "Script for generating Nixpkgs/NixOS channels";

inputs.nixpkgs.follows = "nix/nixpkgs";
inputs.nix-index = {
url = "github:bennofs/nix-index";
inputs.nixpkgs.follows = "nix/nixpkgs";
};

outputs = { self, nixpkgs, nix }:

outputs = { self, nixpkgs, nix, nix-index }:
let nix-index' = nix-index.packages.x86_64-linux.nix-index; in
{

overlays.default = final: prev: {
Expand All @@ -23,15 +27,6 @@
buildCommand = ''
mkdir -p $out/bin
cp ${./file-cache.hh} file-cache.hh
g++ -Os -g ${./generate-programs-index.cc} -Wall -std=c++14 -o $out/bin/generate-programs-index -I . \
$(pkg-config --cflags nix-main) \
$(pkg-config --libs nix-main) \
$(pkg-config --libs nix-expr) \
$(pkg-config --libs nix-store) \
-lsqlite3 -lgc
g++ -Os -g ${./index-debuginfo.cc} -Wall -std=c++14 -o $out/bin/index-debuginfo -I . \
$(pkg-config --cflags nix-main) \
$(pkg-config --libs nix-main) \
Expand All @@ -57,6 +52,7 @@
brotli
jq
nixos-channel-native-programs
nix-index'
];

buildCommand = ''
Expand All @@ -65,7 +61,7 @@
cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch
wrapProgram $out/bin/mirror-nixos-branch \
--set PERL5LIB $PERL5LIB \
--prefix PATH : ${wget}/bin:${git}/bin:${final.nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:${nixos-channel-native-programs}/bin:$out/bin
--prefix PATH : ${wget}/bin:${git}/bin:${final.nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:${nix-index'}/bin:${nixos-channel-native-programs}/bin:$out/bin
patchShebangs $out/bin
'';
Expand Down
Loading

1 comment on commit 8656f3e

@nixos-discourse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/differences-between-nix-channels/13998/5

Please sign in to comment.