use crane for the flake

This commit is contained in:
Noa Aarts 2024-12-16 15:15:11 +01:00
parent 00ef4ca355
commit 0bda61cbcc
Signed by: noa
GPG key ID: 1850932741EFF672
5 changed files with 327 additions and 160 deletions

View file

@ -2,6 +2,7 @@
name = "flurry"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0"
[dependencies]
async-trait = "0.1.83"

View file

@ -1 +1 @@
-C target-cpu=native
target-cpu = "native"

10
deny.toml Normal file
View file

@ -0,0 +1,10 @@
[licenses]
allow = [
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"Unicode-3.0",
"Apache-2.0 WITH LLVM-exception",
"AGPL-3.0",
]

237
flake.lock generated
View file

@ -1,16 +1,80 @@
{
"nodes": {
"advisory-db": {
"flake": false,
"locked": {
"lastModified": 1733749954,
"narHash": "sha256-2Ug80Uf/oUujxgh02Iy5vTG0V+Ab9+YUHuRLRY0ayiY=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "ec9ce28714bb38d77a2223e7266df705500a7f11",
"type": "github"
},
"original": {
"owner": "rustsec",
"repo": "advisory-db",
"type": "github"
}
},
"advisory-db_2": {
"flake": false,
"locked": {
"lastModified": 1733749954,
"narHash": "sha256-2Ug80Uf/oUujxgh02Iy5vTG0V+Ab9+YUHuRLRY0ayiY=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "ec9ce28714bb38d77a2223e7266df705500a7f11",
"type": "github"
},
"original": {
"owner": "rustsec",
"repo": "advisory-db",
"type": "github"
}
},
"crane": {
"locked": {
"lastModified": 1734324364,
"narHash": "sha256-omYTR59TdH0AumP1cfh49fBnWZ52HjfdNfaLzCMZBx0=",
"owner": "ipetkov",
"repo": "crane",
"rev": "60d7623f1320470bf2fdb92fd2dca1e9a27b98ce",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"crane_2": {
"locked": {
"lastModified": 1734324364,
"narHash": "sha256-omYTR59TdH0AumP1cfh49fBnWZ52HjfdNfaLzCMZBx0=",
"owner": "ipetkov",
"repo": "crane",
"rev": "60d7623f1320470bf2fdb92fd2dca1e9a27b98ce",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": []
},
"locked": {
"lastModified": 1734157906,
"narHash": "sha256-4zYEtbxdhYkmmFC5vgv9pmIVHylEuKs+iJb1XsKDN7o=",
"lastModified": 1734331093,
"narHash": "sha256-9UrKDtqfLdsmDW4kRG/jSUAWot0jfL4WzcKA4nCvJZM=",
"owner": "nix-community",
"repo": "fenix",
"rev": "06de03ede52ce64db6eb65be878a39b5ec944f50",
"rev": "e39e49f3314f7dd09671094dc640b528ba2b1e4b",
"type": "github"
},
"original": {
@ -21,15 +85,20 @@
},
"fenix_2": {
"inputs": {
"nixpkgs": "nixpkgs_3",
"rust-analyzer-src": "rust-analyzer-src_2"
"nixpkgs": [
"tsunami",
"nixpkgs"
],
"rust-analyzer-src": [
"tsunami"
]
},
"locked": {
"lastModified": 1733812506,
"narHash": "sha256-3fgFIijf23nKfJogpcEaUGky1W2BpOzpr0ljgx+cmOM=",
"lastModified": 1734331093,
"narHash": "sha256-9UrKDtqfLdsmDW4kRG/jSUAWot0jfL4WzcKA4nCvJZM=",
"owner": "nix-community",
"repo": "fenix",
"rev": "0d8227f07b35ab04fee007fff4f9bb18c6d66af1",
"rev": "e39e49f3314f7dd09671094dc640b528ba2b1e4b",
"type": "github"
},
"original": {
@ -38,122 +107,128 @@
"type": "github"
}
},
"nixpkgs": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1733940404,
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1734126203,
"narHash": "sha256-0XovF7BYP50rTD2v4r55tR5MuBLet7q4xIz6Rgh3BBU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "71a6392e367b08525ee710a93af2e80083b5b3e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1733940404,
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=",
"owner": "nixos",
"lastModified": 1734126203,
"narHash": "sha256-0XovF7BYP50rTD2v4r55tR5MuBLet7q4xIz6Rgh3BBU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713",
"rev": "71a6392e367b08525ee710a93af2e80083b5b3e2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1733581040,
"narHash": "sha256-Qn3nPMSopRQJgmvHzVqPcE3I03zJyl8cSbgnnltfFDY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1733759999,
"narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"advisory-db": "advisory-db",
"crane": "crane",
"fenix": "fenix",
"nixpkgs": "nixpkgs_2",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"tsunami": "tsunami"
}
},
"rust-analyzer-src": {
"flake": false,
"systems": {
"locked": {
"lastModified": 1734121833,
"narHash": "sha256-EZtwXmh9P9FnoXKfbjGxyWksjrjPB4HES2HVIV+STNg=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "fc18d263aa95f7d6de8174bd4c6663dfe865e6d5",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"rust-analyzer-src_2": {
"flake": false,
"systems_2": {
"locked": {
"lastModified": 1733756789,
"narHash": "sha256-cK9hSImKm6FkMeIsdjzuRA1tjOKnXI1VHdmJbmpOYqI=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "99a6ecd41e5e458b3f4c2142b29a80d77ecda248",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tsunami": {
"inputs": {
"advisory-db": "advisory-db_2",
"crane": "crane_2",
"fenix": "fenix_2",
"nixpkgs": "nixpkgs_4"
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1734016882,
"narHash": "sha256-QqnrhOPgvykA+2a9iIzpOW8S3Ef8uA7aAFxcRqS8fB8=",
"lastModified": 1734357001,
"narHash": "sha256-NN/Eu7ZDJUsii7AKNk6wtRcuHkv5i3jxB0PC3HFqy8E=",
"owner": "itepastra",
"repo": "tsunami",
"rev": "872017618ae615152dc97b6379f5e92b175a55e9",
"rev": "91e796c9886282f88bfab8df5f077a7df9800759",
"type": "github"
},
"original": {

237
flake.nix
View file

@ -1,99 +1,180 @@
{
description = "A pixelflut stress testing tool";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
tsunami = {
url = "github:itepastra/tsunami";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs =
{
self,
fenix,
nixpkgs,
crane,
fenix,
flake-utils,
tsunami,
advisory-db,
...
}:
let
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
forAllSystems =
f:
nixpkgs.lib.genAttrs allSystems (
system:
f {
inherit system;
inherit tsunami;
pkgs = import nixpkgs { inherit system; };
fpkgs = import fenix { inherit system; };
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
tsu = tsunami.packages.${system};
inherit (pkgs) lib;
craneLib = (crane.mkLib pkgs).overrideToolchain (p: fenix.packages.${system}.complete.toolchain);
src = craneLib.cleanCargoSource ./.;
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
strictDeps = true;
buildInputs =
[
# Add additional build inputs here
]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
craneLibLLvmTools = craneLib.overrideToolchain (
fenix.packages.${system}.complete.withComponents [
"cargo"
"llvm-tools"
"rustc"
]
);
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself, reusing the dependency
# artifacts from above.
flurry = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
in
{
packages = forAllSystems (
{ pkgs, fpkgs, ... }:
let
toolchain = fpkgs.minimal.toolchain;
fs = pkgs.lib.fileset;
in
rec {
default = flurry;
flurry =
(pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
}).buildRustPackage
{
pname = "flurry";
version = "0.1.0";
cargoLock.lockFile = ./Cargo.lock;
src = fs.toSource {
root = ./.;
fileset = fs.unions [
./Cargo.lock
./Cargo.toml
./src
./assets
];
};
};
}
);
devShells = forAllSystems (
{
pkgs,
fpkgs,
system,
...
}:
let
ffpkgs = fpkgs.complete;
in
{
default = pkgs.mkShell {
buildInputs = [
ffpkgs.cargo
ffpkgs.clippy
ffpkgs.rust-src
ffpkgs.rustc
ffpkgs.rustfmt
pkgs.gcc
pkgs.wgo
tsunami.packages.${system}.tsunami
];
in
{
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit flurry;
# Run clippy (and deny all warnings) on the crate source,
# again, reusing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
flurry-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
flurry-doc = craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
}
);
# Check formatting
flurry-fmt = craneLib.cargoFmt {
inherit src;
};
}
);
hydraJobs = {
devShell.x86_64-linux = self.devShells.x86_64-linux.default;
flurry.x86_64-linux = self.packages.x86_64-linux.flurry;
};
};
flurry-toml-fmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
# taplo arguments can be further customized below as needed
# taploExtraArgs = "--config ./taplo.toml";
};
# Audit dependencies
flurry-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
# Audit licenses
flurry-deny = craneLib.cargoDeny {
inherit src;
};
# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `flurry` if you do not want
# the tests to run twice
flurry-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
}
);
};
packages =
{
default = flurry;
}
// lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
flurry-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (
commonArgs
// {
inherit cargoArtifacts;
}
);
};
apps.default = flake-utils.lib.mkApp {
drv = flurry;
};
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = [
pkgs.wgo
pkgs.cargo-flamegraph
tsu.default
];
};
}
);
}