init
This commit is contained in:
commit
4e22a48854
24
flake.nix
Normal file
24
flake.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
description = "Hare for mac";
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-darwin" "aarch64-darwin" ];
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
harec = pkgs.callPackage ./pkgs/harec.nix { };
|
||||
#hare = pkgs.callPackage ./pkgs/hare.nix { inherit harec; };
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
harec
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
71
pkgs/hare.nix
Normal file
71
pkgs/hare.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
makeWrapper,
|
||||
scdoc,
|
||||
substituteAll,
|
||||
qbe,
|
||||
harec,
|
||||
binutils-unwrapped,
|
||||
tzdata
|
||||
}:
|
||||
let
|
||||
platform = lib.toLower stdenv.hostPlatform.uname.system;
|
||||
arch = stdenv.hostPlatform.uname.processor;
|
||||
qbePlatform = {
|
||||
x86_64 = "amd64_sysv";
|
||||
aarch64 = "arm64";
|
||||
riscv64 = "rv64";
|
||||
}.${arch};
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "hare";
|
||||
version = "0.24";
|
||||
src = builtins.fetchGit {
|
||||
url = "https://git.sr.ht/~sircmpwn/hare";
|
||||
ref = "master";
|
||||
rev = "0cd51184a7acdfd4ef20195d1648622b04477293";
|
||||
};
|
||||
|
||||
patches = [
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
harec
|
||||
makeWrapper
|
||||
qbe
|
||||
scdoc
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
binutils-unwrapped
|
||||
harec
|
||||
qbe
|
||||
tzdata
|
||||
];
|
||||
|
||||
makeFlags = [
|
||||
"HARECACHE=.harecache"
|
||||
"PREFIX=${builtins.placeholder "out"}"
|
||||
"ARCH=${arch}"
|
||||
"VERSION=${finalAttrs.version}-nixpkgs"
|
||||
"QBEFLAGS=-t${qbePlatform}"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"AS=${stdenv.cc.targetPrefix}as"
|
||||
"LD=${stdenv.cc.targetPrefix}ld"
|
||||
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
|
||||
# not follow the FHS.
|
||||
"HAREPATH=$(SRCDIR)/hare/stdlib"
|
||||
];
|
||||
|
||||
postConfigure = ''
|
||||
ln -s configs/linux.mk config.mk
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/hare \
|
||||
--prefix PATH : ${lib.makeBinPath [binutils-unwrapped harec qbe]}
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
})
|
35
pkgs/harec.nix
Normal file
35
pkgs/harec.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ lib, stdenv, qbe }:
|
||||
let
|
||||
platform = lib.toLower stdenv.hostPlatform.uname.system;
|
||||
arch = stdenv.hostPlatform.uname.processor;
|
||||
qbePlatform = {
|
||||
x86_64 = "amd64_sysv";
|
||||
aarch64 = "arm64";
|
||||
riscv64 = "rv64";
|
||||
}.${arch};
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "harec";
|
||||
version = "0.24";
|
||||
src = builtins.fetchGit {
|
||||
url = "github.com/hshq/harelang-harec";
|
||||
ref = "master";
|
||||
rev = "51446fdef8b39df1fbf4fa2644d3f51f020f974a";
|
||||
};
|
||||
buildInputs = [ qbe ];
|
||||
nativeBuildInputs = [ qbe ];
|
||||
|
||||
makeFlags = [
|
||||
"PREFIX=${builtins.placeholder "out"}"
|
||||
"ARCH=${arch}"
|
||||
"VERSION=${finalAttrs.version}-nixpkgs"
|
||||
"QBEFLAGS=-t${qbePlatform}"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"AS=${stdenv.cc.targetPrefix}as"
|
||||
"LD=${stdenv.cc.targetPrefix}ld"
|
||||
];
|
||||
|
||||
postConfigure = ''
|
||||
ln -s configs/darwin.mk config.mk
|
||||
'';
|
||||
})
|
9
pkgs/setup-hook.sh
Normal file
9
pkgs/setup-hook.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
addHarepath () {
|
||||
for haredir in third-party stdlib; do
|
||||
if [[ -d "$1/src/hare/$haredir" ]]; then
|
||||
addToSearchPath HAREPATH "$1/src/hare/$haredir"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
addEnvHooks "$hostOffset" addHarepath
|
Loading…
Reference in a new issue