From 346220064a3be4454b600ef9e4e7ec545ac8450c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 Apr 2025 00:37:24 -0400 Subject: [PATCH 1/2] Format all Nix files --- default.nix | 2 +- flake.nix | 90 ++++++++++++++++++++++++++++++++--------------------- shell.nix | 2 +- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/default.nix b/default.nix index b22e926..12efe75 100644 --- a/default.nix +++ b/default.nix @@ -1,3 +1,3 @@ -(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { +(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { src = builtins.fetchGit ./.; }).defaultNix diff --git a/flake.nix b/flake.nix index 21a3cfc..e7263be 100644 --- a/flake.nix +++ b/flake.nix @@ -3,39 +3,46 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11-small"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: { overlays.default = final: prev: { - nixos-channel-native-programs = with final; stdenv.mkDerivation { - name = "nixos-channel-native-programs"; - buildInputs = [ + nixos-channel-native-programs = + with final; + stdenv.mkDerivation { + name = "nixos-channel-native-programs"; + buildInputs = [ nix pkg-config boehmgc nlohmann_json boost sqlite - ]; + ]; - buildCommand = let - nixHasSignalsHh = nixpkgs.lib.strings.versionAtLeast nix.version "2.19"; - in '' - mkdir -p $out/bin + buildCommand = + let + nixHasSignalsHh = nixpkgs.lib.strings.versionAtLeast nix.version "2.19"; + in + '' + mkdir -p $out/bin - 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) \ - $(pkg-config --libs nix-store) \ - -lsqlite3 \ - ${nixpkgs.lib.optionalString nixHasSignalsHh "-DHAS_SIGNALS_HH"} - ''; - }; + 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) \ + $(pkg-config --libs nix-store) \ + -lsqlite3 \ + ${nixpkgs.lib.optionalString nixHasSignalsHh "-DHAS_SIGNALS_HH"} + ''; + }; - nixos-channel-scripts = with final; stdenv.mkDerivation { - name = "nixos-channel-scripts"; + nixos-channel-scripts = + with final; + stdenv.mkDerivation { + name = "nixos-channel-scripts"; - buildInputs = with perlPackages; - [ nix + buildInputs = with perlPackages; [ + nix sqlite makeWrapper perl @@ -51,25 +58,38 @@ nix-index ]; - buildCommand = '' - mkdir -p $out/bin + buildCommand = '' + mkdir -p $out/bin - cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch - wrapProgram $out/bin/mirror-nixos-branch \ - --set PERL5LIB $PERL5LIB \ - --set XZ_OPT "-T0" \ - --prefix PATH : ${lib.makeBinPath [ wget git nix gnutar xz rsync openssh nix-index nixos-channel-native-programs ]} + cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch + wrapProgram $out/bin/mirror-nixos-branch \ + --set PERL5LIB $PERL5LIB \ + --set XZ_OPT "-T0" \ + --prefix PATH : ${ + lib.makeBinPath [ + wget + git + nix + gnutar + xz + rsync + openssh + nix-index + nixos-channel-native-programs + ] + } - patchShebangs $out/bin - ''; - }; + patchShebangs $out/bin + ''; + }; }; - packages.default.x86_64-linux = (import nixpkgs { - system = "x86_64-linux"; - overlays = [ self.overlays.default ]; - }).nixos-channel-scripts; + packages.default.x86_64-linux = + (import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default ]; + }).nixos-channel-scripts; checks.x86_64-linux.default = self.packages.default.x86_64-linux; }; diff --git a/shell.nix b/shell.nix index db84e3d..ff89556 100644 --- a/shell.nix +++ b/shell.nix @@ -1,3 +1,3 @@ -(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) { +(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { src = builtins.fetchGit ./.; }).shellNix From 8263fae0ee05c960b9df47413559e5924183a835 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 Apr 2025 00:55:26 -0400 Subject: [PATCH 2/2] Fix build with Nix 2.28, improve packaging in other ways --- flake.nix | 132 ++++++++++++++++++++++----------------------- index-debuginfo.cc | 20 +++---- 2 files changed, 74 insertions(+), 78 deletions(-) diff --git a/flake.nix b/flake.nix index e7263be..f8593c5 100644 --- a/flake.nix +++ b/flake.nix @@ -7,66 +7,65 @@ { self, nixpkgs }: { overlays.default = final: prev: { - nixos-channel-native-programs = - with final; - stdenv.mkDerivation { - name = "nixos-channel-native-programs"; - buildInputs = [ - nix - pkg-config - boehmgc - nlohmann_json - boost - sqlite - ]; - - buildCommand = - let - nixHasSignalsHh = nixpkgs.lib.strings.versionAtLeast nix.version "2.19"; - in - '' - mkdir -p $out/bin - - 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) \ - $(pkg-config --libs nix-store) \ - -lsqlite3 \ - ${nixpkgs.lib.optionalString nixHasSignalsHh "-DHAS_SIGNALS_HH"} - ''; - }; - - nixos-channel-scripts = - with final; - stdenv.mkDerivation { - name = "nixos-channel-scripts"; - - buildInputs = with perlPackages; [ - nix - sqlite - makeWrapper - perl - FileSlurp - LWP - LWPProtocolHttps - ListMoreUtils - DBDSQLite - NetAmazonS3 - brotli - jq - nixos-channel-native-programs - nix-index - ]; - - buildCommand = '' - mkdir -p $out/bin - - cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch - wrapProgram $out/bin/mirror-nixos-branch \ - --set PERL5LIB $PERL5LIB \ - --set XZ_OPT "-T0" \ - --prefix PATH : ${ - lib.makeBinPath [ + nixos-channel-native-programs = final.stdenv.mkDerivation { + name = "nixos-channel-native-programs"; + + strictDeps = true; + + nativeBuildInputs = with final.buildPackages; [ + pkg-config + ]; + + buildInputs = with final; [ + nixVersions.nix_2_28 + nlohmann_json + boost + ]; + + buildCommand = '' + mkdir -p $out/bin + + $CXX \ + -Os -g -Wall \ + -std=c++14 \ + $(pkg-config --libs --cflags nix-store) \ + $(pkg-config --libs --cflags nix-main) \ + -I . \ + ${./index-debuginfo.cc} \ + -o $out/bin/index-debuginfo + ''; + }; + + nixos-channel-scripts = final.stdenv.mkDerivation { + name = "nixos-channel-scripts"; + + strictDeps = true; + + nativeBuildInputs = with final.buildPackages; [ + makeWrapper + ]; + + buildInputs = with final.perlPackages; [ + final.perl + FileSlurp + LWP + LWPProtocolHttps + ListMoreUtils + DBDSQLite + NetAmazonS3 + ]; + + buildCommand = '' + mkdir -p $out/bin + + cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch + wrapProgram $out/bin/mirror-nixos-branch \ + --set PERL5LIB $PERL5LIB \ + --set XZ_OPT "-T0" \ + --prefix PATH : ${ + final.lib.makeBinPath ( + with final; + [ wget git nix @@ -77,20 +76,21 @@ nix-index nixos-channel-native-programs ] - } + ) + } - patchShebangs $out/bin - ''; - }; + patchShebangs $out/bin + ''; + }; }; - packages.default.x86_64-linux = + packages.x86_64-linux.default = (import nixpkgs { system = "x86_64-linux"; overlays = [ self.overlays.default ]; }).nixos-channel-scripts; - checks.x86_64-linux.default = self.packages.default.x86_64-linux; + checks.x86_64-linux.default = self.packages.x86_64-linux.default; }; } diff --git a/index-debuginfo.cc b/index-debuginfo.cc index e320ccb..1b22c3d 100644 --- a/index-debuginfo.cc +++ b/index-debuginfo.cc @@ -1,19 +1,15 @@ -#include - #include -#include "shared.hh" -#include "sqlite.hh" -#include "s3-binary-cache-store.hh" -#include "thread-pool.hh" -#include "nar-info.hh" +#include + +#include +#include -// https://github.com/NixOS/nix/commit/ac89bb064aeea85a62b82a6daf0ecca7190a28b7 -#ifdef HAS_SIGNALS_HH -#include "signals.hh" -#endif +#include +#include +#include -#include +#include // cache.nixos.org/debuginfo/ // => redirect to NAR