aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2025-02-22 18:39:52 +0100
committerMax Audron <audron@cocaine.farm>2025-02-22 18:39:52 +0100
commit9411cfa7572431801872152d8d964634e1504b89 (patch)
tree124aa797ae433ab8db0d282661eb4a8f63a7b0c8 /flake.nix
parentadd todos to readme (diff)
update flake
Diffstat (limited to '')
-rw-r--r--flake.nix132
1 files changed, 62 insertions, 70 deletions
diff --git a/flake.nix b/flake.nix
index c0f2edd..94c8ba1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,12 +2,9 @@
description = "Build a cargo project";
inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
- crane = {
- url = "github:ipetkov/crane";
- inputs.nixpkgs.follows = "nixpkgs";
- };
+ crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
@@ -22,14 +19,25 @@
};
};
- outputs = { self, nixpkgs, crane, flake-utils, advisory-db, fenix, ... }:
- flake-utils.lib.eachDefaultSystem (system:
+ outputs =
+ {
+ self,
+ nixpkgs,
+ crane,
+ flake-utils,
+ advisory-db,
+ fenix,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib;
- rustToolchain = with fenix.packages.${system};
+ rustToolchain =
+ with fenix.packages.${system};
combine [
stable.defaultToolchain
(stable.withComponents [ "rust-src" ])
@@ -37,33 +45,15 @@
rust-analyzer
];
- craneLib = crane.lib.${system}.overrideToolchain rustToolchain;
+ craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
+
+ markdownFilter = path: _type: builtins.match ".*md$" path != null;
+ markdownOrCargo = path: type: (markdownFilter path type) || (craneLib.filterCargoSources path type);
src = lib.cleanSourceWith {
- # Apply the default source cleaning from nixpkgs
- src = lib.cleanSource ./.;
-
- # Then add our own filter on top
- filter = orig_path: type:
- let
- path = (toString orig_path);
- base = baseNameOf path;
- parentDir = baseNameOf (dirOf path);
-
- matchesSuffix = lib.any (suffix: lib.hasSuffix suffix base) [
- ".rs"
- ".toml"
- ".md"
- ];
-
- # Cargo.toml already captured above
- isCargoFile = base == "Cargo.lock";
-
- # .cargo/config.toml already captured above
- isCargoConfig = parentDir == ".cargo" && base == "config";
- in
- type == "directory" || matchesSuffix || isCargoFile
- || isCargoConfig;
+ src = ./.;
+ filter = markdownOrCargo;
+ name = "source";
};
# Build *just* the cargo dependencies, so we can reuse
@@ -77,44 +67,45 @@
};
in
{
- checks = {
- # Build the crate as part of `nix flake check` for convenience
- inherit libquassel;
-
- # 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.
- libquassel-clippy = craneLib.cargoClippy {
- inherit cargoArtifacts src;
- cargoClippyExtraArgs = "--all-targets -- --deny warnings";
+ checks =
+ {
+ # Build the crate as part of `nix flake check` for convenience
+ inherit libquassel;
+
+ # 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.
+ libquassel-clippy = craneLib.cargoClippy {
+ inherit cargoArtifacts src;
+ cargoClippyExtraArgs = "--all-targets -- --deny warnings";
+ };
+
+ libquassel-doc = craneLib.cargoDoc { inherit cargoArtifacts src; };
+
+ # Check formatting
+ libquassel-fmt = craneLib.cargoFmt { inherit src; };
+
+ # Audit dependencies
+ libquassel-audit = craneLib.cargoAudit { inherit src advisory-db; };
+
+ # Run tests with cargo-nextest
+ # Consider setting `doCheck = false` on `libquassel` if you do not want
+ # the tests to run twice
+ libquassel-nextest = craneLib.cargoNextest {
+ inherit cargoArtifacts src;
+ partitions = 1;
+ partitionType = "count";
+ };
+ }
+ // lib.optionalAttrs (system == "x86_64-linux") {
+ # NB: cargo-tarpaulin only supports x86_64 systems
+ # Check code coverage (note: this will not upload coverage anywhere)
+ libquassel-coverage = craneLib.cargoTarpaulin { inherit cargoArtifacts src; };
};
- libquassel-doc = craneLib.cargoDoc { inherit cargoArtifacts src; };
-
- # Check formatting
- libquassel-fmt = craneLib.cargoFmt { inherit src; };
-
- # Audit dependencies
- libquassel-audit = craneLib.cargoAudit { inherit src advisory-db; };
-
- # Run tests with cargo-nextest
- # Consider setting `doCheck = false` on `libquassel` if you do not want
- # the tests to run twice
- libquassel-nextest = craneLib.cargoNextest {
- inherit cargoArtifacts src;
- partitions = 1;
- partitionType = "count";
- };
- } // lib.optionalAttrs (system == "x86_64-linux") {
- # NB: cargo-tarpaulin only supports x86_64 systems
- # Check code coverage (note: this will not upload coverage anywhere)
- libquassel-coverage =
- craneLib.cargoTarpaulin { inherit cargoArtifacts src; };
- };
-
packages.default = libquassel;
# apps.default = flake-utils.lib.mkApp {
@@ -136,5 +127,6 @@
gtk3
];
};
- });
+ }
+ );
}