Add nix flake

Signed-off-by: Finn Behrens <me@kloenk.dev>
This commit is contained in:
Finn Behrens 2021-09-22 19:15:57 +02:00 committed by PaddiM8
parent 2999856771
commit 96f2c10eb3
3 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ kalk/Cargo.lock
cli/Cargo.lock cli/Cargo.lock
cli/test cli/test
.vscode/ .vscode/
result*

25
flake.lock Normal file
View File

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1632255010,
"narHash": "sha256-p/BYR6qhbCtDpOfw9uMYwjwyhuCVKgiSUpKZaV/63UE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "bfc38d3d0d22c528e8abc46c5dd5f3f50fc4554b",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

55
flake.nix Normal file
View File

@ -0,0 +1,55 @@
{
description = "A very basic flake";
outputs = { self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
#"aarch64-darwin" # currently not building due to gmp
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
in {
overlay = final: prev: {
kalker = final.rustPlatform.buildRustPackage {
pname = "kalker";
version = "unstable";
src = self;
nativeBuildInputs = with final; [ m4 ];
outputs = [ "out" "lib" ];
postInstall = ''
moveToOutput "lib" "$lib"
'';
cargoLock = { lockFile = self + "/Cargo.lock"; };
}
# FIXME: fix aarch64-darwin builds
/* // (if (final.stdenv.isDarwin && final.stdenv.isAarch64) then {
CARGO_FEATURE_USE_SYSTEM_LIBS = "1";
RUST_BACKTRACE = "1";
buildInputs = with final; [ gmp mpfr libmpc ];
} else
{ })
*/
;
};
packages = forAllSystems (system: nixpkgsFor.${system});
defaultPackage = forAllSystems (system: self.packages.${system}.kalker);
};
}