Added basic flake.nix

This commit is contained in:
Andrew Rioux 2024-01-23 10:25:20 -05:00
parent 53133debec
commit 4905ab54f0
Signed by: andrew.rioux
GPG Key ID: 9B8BAC47C17ABB94

73
flake.nix Normal file
View File

@ -0,0 +1,73 @@
{
description = "Sparse C2 framework";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, crane, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
targets.x86_64-pc-windows-gnu.stable.rust-std
targets.x86_64-unknown-linux-musl.stable.rust-std
stable.rust-analyzer
];
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
src = craneLib.cleanCargoSource (craneLib.path ./.);
commonArgs = {
inherit src;
strictDeps = true;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
};
artifacts = craneLib.buildDepsOnly commonArgs;
crate = craneLib.buildPackage (commonArgs // {
inherit artifacts;
buildInputs = with pkgs; [ cmake make ];
});
in with pkgs; {
devShells.default = craneLib.devShell rec {
name = "sparse";
buildInputs = [ cmake make ];
};
packages = {
default = crate;
windows = craneLib.buildPackage (commonArgs // {
doCheck = false;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
depsBuildBUild = [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
});
checks = { inherit crate; };
};
});
}