2022-09-02 23:03:57 +00:00
|
|
|
{
|
2022-11-02 13:12:13 +00:00
|
|
|
description = "harmonic";
|
2022-09-02 23:03:57 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
naersk = {
|
|
|
|
url = "github:nix-community/naersk";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, fenix
|
|
|
|
, naersk
|
|
|
|
, ...
|
|
|
|
} @ inputs:
|
|
|
|
let
|
|
|
|
nameValuePair = name: value: { inherit name value; };
|
|
|
|
genAttrs = names: f: builtins.listToAttrs (map (n: nameValuePair n (f n)) names);
|
|
|
|
allSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
|
|
|
|
forAllSystems = f: genAttrs allSystems (system: f rec {
|
|
|
|
inherit system;
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
});
|
|
|
|
|
|
|
|
fenixToolchain = system: with fenix.packages.${system};
|
|
|
|
combine ([
|
|
|
|
stable.clippy
|
|
|
|
stable.rustc
|
|
|
|
stable.cargo
|
|
|
|
stable.rustfmt
|
|
|
|
stable.rust-src
|
|
|
|
] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [
|
|
|
|
targets.x86_64-unknown-linux-musl.stable.rust-std
|
|
|
|
] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [
|
|
|
|
targets.aarch64-unknown-linux-musl.stable.rust-std
|
|
|
|
]);
|
|
|
|
in
|
|
|
|
{
|
2022-09-28 20:49:07 +00:00
|
|
|
devShells = forAllSystems ({ system, pkgs, ... }:
|
2022-09-02 23:03:57 +00:00
|
|
|
let
|
|
|
|
toolchain = fenixToolchain system;
|
|
|
|
ci = import ./nix/ci.nix { inherit pkgs; };
|
|
|
|
eclint = import ./nix/eclint.nix { inherit pkgs; };
|
|
|
|
|
|
|
|
spellcheck = pkgs.writeScriptBin "spellcheck" ''
|
|
|
|
${pkgs.codespell}/bin/codespell \
|
|
|
|
--ignore-words-list crate,pullrequest,pullrequests,ser \
|
|
|
|
--skip target \
|
|
|
|
.
|
|
|
|
'';
|
|
|
|
in
|
2022-09-28 20:49:07 +00:00
|
|
|
{
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
name = "nix-install-shell";
|
|
|
|
|
|
|
|
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
toolchain
|
|
|
|
openssl
|
|
|
|
rust-analyzer
|
2022-11-01 16:32:14 +00:00
|
|
|
cargo-outdated
|
2022-09-28 20:49:07 +00:00
|
|
|
|
|
|
|
# CI dependencies
|
|
|
|
jq
|
|
|
|
codespell
|
|
|
|
findutils # for xargs
|
|
|
|
git
|
|
|
|
nixpkgs-fmt
|
|
|
|
eclint
|
|
|
|
]
|
|
|
|
++ ci
|
|
|
|
++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [ libiconv darwin.apple_sdk.frameworks.Security ]);
|
|
|
|
};
|
2022-09-02 23:03:57 +00:00
|
|
|
});
|
|
|
|
|
2022-10-13 16:11:23 +00:00
|
|
|
checks = forAllSystems ({ system, pkgs, ... }:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
format = pkgs.runCommand "check-format"
|
|
|
|
{
|
|
|
|
buildInputs = with pkgs; [ rustfmt cargo ];
|
|
|
|
} ''
|
|
|
|
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
|
|
|
|
touch $out # it worked!
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2022-09-02 23:03:57 +00:00
|
|
|
packages = forAllSystems
|
|
|
|
({ system, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
naerskLib = pkgs.callPackage naersk {
|
|
|
|
cargo = fenixToolchain system;
|
|
|
|
rustc = fenixToolchain system;
|
|
|
|
};
|
|
|
|
|
|
|
|
sharedAttrs = {
|
|
|
|
pname = "harmonic";
|
|
|
|
version = "0.0.0-unreleased";
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
|
|
|
|
openssl
|
|
|
|
] ++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs.darwin.apple_sdk.frameworks; [
|
|
|
|
SystemConfiguration
|
|
|
|
]);
|
|
|
|
|
|
|
|
doCheck = true;
|
2022-09-09 18:43:35 +00:00
|
|
|
RUSTFLAGS = "--cfg tracing_unstable";
|
2022-09-02 23:03:57 +00:00
|
|
|
|
|
|
|
override = { preBuild ? "", ... }: {
|
|
|
|
preBuild = preBuild + ''
|
2022-09-26 15:43:10 +00:00
|
|
|
# logRun "cargo clippy --all-targets --all-features -- -D warnings"
|
2022-09-02 23:03:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2022-09-28 20:49:07 +00:00
|
|
|
rec {
|
2022-09-02 23:03:57 +00:00
|
|
|
harmonic = naerskLib.buildPackage
|
|
|
|
(sharedAttrs // { });
|
2022-10-12 13:33:19 +00:00
|
|
|
default = self.packages.${system}.harmonic;
|
2022-10-06 19:21:49 +00:00
|
|
|
} // lib.optionalAttrs (system == "x86_64-linux") rec {
|
|
|
|
default = harmonicStatic;
|
2022-09-02 23:03:57 +00:00
|
|
|
harmonicStatic = naerskLib.buildPackage
|
|
|
|
(sharedAttrs // {
|
|
|
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
|
|
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
|
|
|
|
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}";
|
|
|
|
});
|
2022-10-06 19:21:49 +00:00
|
|
|
} // lib.optionalAttrs (system == "aarch64-linux") rec {
|
|
|
|
default = harmonicStatic;
|
2022-09-02 23:03:57 +00:00
|
|
|
harmonicStatic = naerskLib.buildPackage
|
|
|
|
(sharedAttrs // {
|
|
|
|
CARGO_BUILD_TARGET = "aarch64-unknown-linux-musl";
|
|
|
|
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
|
|
|
|
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}";
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|