Something went wrong. Try again.
A (minimal) nucleo example
Something went wrong. Try again.
nucleo-example flake.nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110{ description = "nucleo-example-description";
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; };
flake-utils.url = "github:numtide/flake-utils";
advisory-db = { url = "github:rustsec/advisory-db"; flake = false; }; };
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib;
craneLib = crane.mkLib nixpkgs.legacyPackages.${system}; src = craneLib.cleanCargoSource (craneLib.path ./.);
# Common arguments can be set here to avoid repeating them later commonArgs = { inherit src;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; lib.optionals stdenv.isLinux [ pkgs.libGL pkgs.libxkbcommon pkgs.wayland ];
# Additional environment variables can be set directly # MY_CUSTOM_VAR = "some value"; };
# 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. nucleo-example = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); in { checks = { inherit nucleo-example;
# Run clippy (and deny all warnings) on the crate source, # again, resuing 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. nucleo-example-clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; cargoClippyExtraArgs = "--all-targets -- --deny warnings"; });
nucleo-example-doc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
# Check formatting nucleo-example-fmt = craneLib.cargoFmt { inherit src; };
# Audit dependencies nucleo-example-audit = craneLib.cargoAudit { inherit src advisory-db; }; };
packages.default = nucleo-example;
apps.default = flake-utils.lib.mkApp { name = "nucleo-example"; drv = nucleo-example; };
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell { inputsFrom = builtins.attrValues self.checks.${system};
# Additional dev-shell environment variables can be set directly # MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here packages = with pkgs; [ rustc # rust compiler cargo # rust package manager rust-analyzer # rust language server taplo-lsp # toml language server marksman # md language server lldb # debugger ];
LD_LIBRARY_PATH = lib.makeLibraryPath commonArgs.buildInputs; }; });}