From bbde40af3ed6f53d25410596ce0ed4347d0be053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:36 +0200 Subject: [PATCH] Make it easy to build a static nix-find-roots from this source tree Just `nix build .#nix-find-roots` (or `nix-build -A nix-find-roots`) --- flake.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/flake.nix b/flake.nix index c464b8f7c..b45502293 100644 --- a/flake.nix +++ b/flake.nix @@ -403,6 +403,23 @@ BINDIR=${placeholder "bin"}/bin ''; }; + nix-find-roots = prev.stdenv.mkDerivation { + name = "nix-find-roots-${version}"; + inherit version; + + src = "${self}/src/nix-find-roots"; + + CXXFLAGS = prev.lib.optionalString prev.stdenv.hostPlatform.isStatic "-static"; + + buildPhase = '' + $CXX $CXXFLAGS -std=c++17 nix-find-roots.cc -o nix-find-roots + ''; + + installPhase = '' + mkdir -p $out/bin + cp nix-find-roots $out/bin/ + ''; + }; }; in { @@ -560,6 +577,7 @@ packages = forAllSystems (system: { inherit (nixpkgsFor.${system}) nix; } // (nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) { + inherit (nixpkgsFor.${system}.pkgsStatic) nix-find-roots; nix-static = let nixpkgs = nixpkgsFor.${system}.pkgsStatic; in with commonDeps nixpkgs; nixpkgs.stdenv.mkDerivation {