ofborg/flake.nix

116 lines
3.1 KiB
Nix
Raw Normal View History

2022-10-27 21:54:17 +00:00
{
inputs = {
2022-12-04 01:27:28 +00:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
2022-10-27 21:54:17 +00:00
};
outputs =
{ self
, nixpkgs
, ...
}@inputs:
let
supportedSystems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in
{
devShell = forAllSystems (system: inputs.self.devShells.${system}.default);
2022-10-27 21:54:17 +00:00
devShells = forAllSystems
(system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
default = pkgs.mkShell {
name = "gh-event-forwarder";
nativeBuildInputs = with pkgs; [
nix # so in --pure mode we actually find the "correct" nix
bash
nix-prefetch-git
rustc
cargo
clippy
rustfmt
pkg-config
git
];
buildInputs = with pkgs; [
] ++ lib.optionals stdenv.isDarwin [ darwin.Security libiconv ];
postHook = ''
checkPhase() (
cd "${builtins.toString ./.}/ofborg"
set -x
cargo fmt
git diff --exit-code
cargofmtexit=$?
cargo clippy
cargoclippyexit=$?
cargo build && cargo test
cargotestexit=$?
sum=$((cargofmtexit + cargoclippyexit + cargotestexit))
exit $sum
)
'';
RUSTFLAGS = "-D warnings";
RUST_BACKTRACE = "1";
RUST_LOG = "ofborg=debug";
NIX_PATH = "nixpkgs=${pkgs.path}";
};
});
packages = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
};
pkg = pkgs.rustPlatform.buildRustPackage {
name = "ofborg";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = with pkgs; [
pkgconfig
pkgs.rustPackages.clippy
];
buildInputs = with pkgs; [
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
]);
preBuild = ''
cargo clippy
'';
doCheck = false; # Tests require access to a /nix/ and a nix daemon
checkInputs = with pkgs; [
nix
];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
2022-11-15 10:14:04 +00:00
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
2022-10-27 21:54:17 +00:00
};
};
};
in
{
default = pkg;
ofborg = pkg;
2022-10-27 21:54:17 +00:00
});
hydraJobs = {
buildRs = forAllSystems (system: self.packages.${system}.ofborg);
2022-10-27 21:54:17 +00:00
};
};
}