72 lines
1.6 KiB
Nix
72 lines
1.6 KiB
Nix
|
# SPDX-FileCopyrightText: Emery Hemingway
|
||
|
#
|
||
|
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
|
||
|
|
||
|
{ stdenv, buildPackages, fetchgit, genode, pkgconfig, tup }:
|
||
|
|
||
|
let
|
||
|
tupArch = with stdenv.targetPlatform;
|
||
|
if isAarch32 then "arm" else
|
||
|
if isAarch64 then "arm64" else
|
||
|
if isx86_32 then "i386" else
|
||
|
if isx86_64 then "x86_64" else
|
||
|
abort "unhandled targetPlatform";
|
||
|
|
||
|
toTupConfig = attrs:
|
||
|
with builtins;
|
||
|
let op = config: name: "${config}CONFIG_${name}=${getAttr name attrs} ";
|
||
|
in foldl' op "" (attrNames attrs);
|
||
|
|
||
|
in stdenv.mkDerivation rec {
|
||
|
name = "nic_bus";
|
||
|
version = "1.0";
|
||
|
src = fetchgit {
|
||
|
url = "https://git.sr.ht/~ehmry/nic_bus";
|
||
|
rev = "76881b4fbb99e9a995d1f35a33529ff8f38c89bc";
|
||
|
sha256 = "08fcbfnlg0ljbgv95yd5q70c7xa0sg2k0njv4ygancs7d7f7q4bb";
|
||
|
};
|
||
|
|
||
|
nativeBuildInputs = [ pkgconfig tup ];
|
||
|
|
||
|
buildInputs = [ genode.base genode.os ];
|
||
|
|
||
|
tupConfig = toTupConfig {
|
||
|
TUP_ARCH = tupArch;
|
||
|
VERSION = version;
|
||
|
};
|
||
|
|
||
|
configurePhase = ''
|
||
|
cp -v ${genode.base.src}/Tuprules.tup .
|
||
|
|
||
|
# Configure Tup
|
||
|
echo $tupConfig | tr ' CONFIG_' '\nCONFIG_' > tup.config
|
||
|
echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config
|
||
|
echo CONFIG_NIX_OUTPUTS_DEV=$dev >> tup.config
|
||
|
|
||
|
# Scan repository and generate script
|
||
|
tup init
|
||
|
tup generate buildPhase.sh
|
||
|
|
||
|
# Redirect artifacts to Nix store
|
||
|
mkdir -p $out
|
||
|
ln -s $out out
|
||
|
'';
|
||
|
|
||
|
buildPhase = ''
|
||
|
test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $dev/
|
||
|
pushd .
|
||
|
set -v
|
||
|
source buildPhase.sh
|
||
|
set +v
|
||
|
popd
|
||
|
'';
|
||
|
|
||
|
dontInstall = true;
|
||
|
|
||
|
meta = with stdenv.lib; {
|
||
|
license = licenses.agpl3;
|
||
|
maintainers = [ maintainers.ehmry ];
|
||
|
};
|
||
|
|
||
|
}
|