about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-05-19 01:28:44 +0300
committerVika <vika@fireburn.ru>2024-05-19 01:28:44 +0300
commitca04fc74a5904601947132f9ce42a22bc379c136 (patch)
tree23973b9c406612775551a6783cf5baaa8b189ba8
parent113a6f9fe6603be7488c1c9a5bb4b1b7c5bb2f71 (diff)
WIP: cross-compilation attempt via overlay nix-cross
Doesn't work, linker troubles. Not sure what's happening, but I
probably need to tweak rustc a bit.
-rw-r--r--flake.nix18
-rw-r--r--kittybox.nix4
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 = ''