From ca04fc74a5904601947132f9ce42a22bc379c136 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 19 May 2024 01:28:44 +0300 Subject: WIP: cross-compilation attempt via overlay Doesn't work, linker troubles. Not sure what's happening, but I probably need to tweak rustc a bit. --- flake.nix | 18 +++++++++++++----- kittybox.nix | 4 ++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index d2e20a5..e78b88c 100644 --- a/flake.nix +++ b/flake.nix @@ -25,14 +25,22 @@ forAllSystems = f: flake-utils.lib.eachSystem supportedSystems f; in { nixosModules.default = import ./configuration.nix self; + overlays.default = final: prev: let + naersk' = final.pkgsBuildHost.callPackage naersk {}; + in { + kittybox = final.callPackage ./kittybox.nix { + naersk = naersk'; + inherit (final.pkgsBuildHost.nodePackages) typescript; + }; + }; } // forAllSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + localSystem.system = system; + overlays = [ self.overlays.default ]; + }; in { packages = { - kittybox = pkgs.callPackage ./kittybox.nix { - naersk = naersk.lib.${system}; - inherit (pkgs.nodePackages) typescript; - }; + kittybox = pkgs.kittybox; default = self.packages.${system}.kittybox; }; diff --git a/kittybox.nix b/kittybox.nix index eea7006..a8cac0e 100644 --- a/kittybox.nix +++ b/kittybox.nix @@ -29,6 +29,10 @@ naersk.buildPackage rec { postgresql postgresqlTestHook ]; + # Cross-compilation support + CARGO_BUILD_TARGET = stdenv.targetPlatform.rust.cargoShortTarget; + "CARGO_TARGET_${stdenv.targetPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" = "-C linker=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; + # Tests create arbitrary databases; we need to be prepared for that postgresqlTestUserOptions = "LOGIN SUPERUSER"; postgresqlTestSetupPost = '' -- cgit 1.4.1