From 32f8b603cb09bd85b8ad9092b55b4f3869da19d5 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 2 Dec 2019 15:53:26 +0100 Subject: [PATCH] Use cross-compile pairs in Flake --- default.nix | 30 +++++++++++++++++++----------- flake.lock | 4 ++-- flake.nix | 17 +++++++---------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/default.nix b/default.nix index e2c602b6a..4263960ff 100644 --- a/default.nix +++ b/default.nix @@ -1,15 +1,15 @@ +{ localSystem ? "x86_64-linux", crossSystem ? "x86_64-genode", self ? { }, ... +}@args: + let - nixpkgsGit = builtins.fetchGit { + pinnedNixpkgs = import (builtins.fetchGit { url = "https://gitea.c3d2.de/ehmry/nixpkgs.git"; ref = "genode"; - }; - pinnedNixpkgs = import nixpkgsGit { - localSystem = "x86_64-linux"; - crossSystem = "x86_64-genode"; - }; + }); + + nixpkgs = + args.nixpkgs or (pinnedNixpkgs { inherit localSystem crossSystem; }); -in { system ? "x86_64-genode", self ? { }, nixpkgs ? pinnedNixpkgs }: -let inherit (nixpkgs) stdenv buildPackages fetchgit llvmPackages; src = self.outPath or ./.; @@ -25,15 +25,23 @@ let buildRepo = { repo, repoInputs }: let tupArch = with stdenv.targetPlatform; + if isAarch32 then "arm" - else if isAarch64 then + else + + if isAarch64 then "arm64" - else if isx86_32 then + else + + if isx86_32 then "i386" - else if isx86_64 then + else + + if isx86_64 then "x86_64" else + abort "unhandled targetPlatform"; toTupConfig = attrs: diff --git a/flake.lock b/flake.lock index d33ce29ba..46cb2b2dc 100644 --- a/flake.lock +++ b/flake.lock @@ -2,9 +2,9 @@ "inputs": { "nixpkgs": { "inputs": {}, - "narHash": "sha256-g++A7ut8qyY3yi6WskTHwYbci6+MeTxJDLyzSrTjruM=", + "narHash": "sha256-/9hMb9pgV8awDYYchUueplyKF6bz23b7z5gqQ999nro=", "originalUrl": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode", - "url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode&rev=9426fc2248cfc706f7a659b04fcd6935515232bc" + "url": "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode&rev=d63ee96d86672a9cb23d83d50ee02687eded2818" } }, "version": 3 diff --git a/flake.nix b/flake.nix index f37afdd91..c04960f0c 100644 --- a/flake.nix +++ b/flake.nix @@ -5,19 +5,16 @@ inputs.nixpkgs.uri = "git+https://gitea.c3d2.de/ehmry/nixpkgs.git?ref=genode"; - outputs = { self, nixpkgs }: - let - systems = [ "x86_64-genode" ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); - in { - packages = forAllSystems (system: + outputs = { self, nixpkgs }: { + packages = nixpkgs.lib.forAllCrossSystems + ({ system, localSystem, crossSystem }: import ./default.nix { - inherit system self; + inherit localSystem crossSystem self; nixpkgs = builtins.getAttr system nixpkgs.legacyPackages; }); - defaultPackage = forAllSystems (system: self.packages."${system}".os); + defaultPackage.x86_64-linux = self.packages.x86_64-linux-x86_64-genode.os; - hydraJobs = self.packages; - }; + hydraJobs = self.packages; + }; }