git.delta.rocks / fleet / refs/commits / 6a5196a1ce6c

difftreelog

feat crosscompilation support

Yaroslav Bolyukin2021-12-20parent: #41ecf40.patch.diff

2 files changed

modifiedflake.nixdiffbeforeafterboth
before · flake.nix
1{2  description = "NixOS configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/staging-next";6    rust-overlay = { url = "github:oxalica/rust-overlay"; flake = false; };7    flake-utils.url = "github:numtide/flake-utils";8  };9  outputs = { self, rust-overlay, flake-utils, nixpkgs }: with nixpkgs.lib; rec {10    lib = import ./lib;11  } // flake-utils.lib.eachDefaultSystem (system:12    let13      pkgs = import nixpkgs14        {15          inherit system; overlays = [ (import rust-overlay) ];16        };17      llvmPkgs = pkgs.buildPackages.llvmPackages_11;18      rust = (pkgs.rustChannelOf { date = "2021-08-16"; channel = "nightly"; }).default.override { extensions = [ "rust-src" ]; };19      rustPlatform = pkgs.makeRustPlatform { cargo = rust; rustc = rust; };20    in21    {22      devShell = (pkgs.mkShell.override { stdenv = llvmPkgs.stdenv; }) {23        nativeBuildInputs = with pkgs; [24          rust25          cargo-edit26          cargo-udeps27          cargo-fuzz2829          pkgconfig30          openssl31        ];32      };33    });34}
after · flake.nix
1{2  description = "NixOS configuration management";34  inputs = {5    nixpkgs.url = "github:nixos/nixpkgs/staging-next";6    rust-overlay = { url = "github:oxalica/rust-overlay"; flake = false; };7    flake-utils.url = "github:numtide/flake-utils";8  };9  outputs = { self, rust-overlay, flake-utils, nixpkgs }: with nixpkgs.lib; rec {10    lib = import ./lib { inherit flake-utils; };11  } // flake-utils.lib.eachDefaultSystem (system:12    let13      pkgs = import nixpkgs14        {15          inherit system; overlays = [ (import rust-overlay) ];16        };17      llvmPkgs = pkgs.buildPackages.llvmPackages_11;18      rust = (pkgs.rustChannelOf { date = "2021-08-16"; channel = "nightly"; }).default.override { extensions = [ "rust-src" ]; };19      rustPlatform = pkgs.makeRustPlatform { cargo = rust; rustc = rust; };20    in21    {22      devShell = (pkgs.mkShell.override { stdenv = llvmPkgs.stdenv; }) {23        nativeBuildInputs = with pkgs; [24          rust25          cargo-edit26          cargo-udeps27          cargo-fuzz2829          pkgconfig30          openssl31        ];32      };33    });34}
modifiedlib/default.nixdiffbeforeafterboth
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -1,9 +1,9 @@
-{
+{ flake-utils }: {
   fleetConfiguration = { data, nixpkgs, hosts, ... }@allConfig:
     let
       config = builtins.removeAttrs allConfig [ "nixpkgs" "data" ];
     in
-    rec {
+    flake-utils.lib.eachDefaultSystem (system: rec {
       root = nixpkgs.lib.evalModules {
         modules = (import ../modules/fleet/_modules.nix) ++ [ config data ];
         specialArgs = {
@@ -25,11 +25,18 @@
                 modules = configuredHosts.${name}.modules ++ (
                   if configuredHosts.${name}.system == "aarch64-linux" then [ (nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix") ]
                   else [ ]
-                );
+                ) ++ [
+                  ({ ... }: {
+                    nixpkgs.localSystem.system = system;
+                    nixpkgs.crossSystem = if system == configuredHosts.${name}.system then null else {
+                      system = configuredHosts.${name}.system;
+                    };
+                  })
+                ];
               };
             }
           )
           (builtins.attrNames root.config.hosts)
       ); #nixpkgs.lib.nixosSystem {}
-    };
+    });
 }