about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2025-01-01 07:11:35 +0300
committerVika <vika@fireburn.ru>2025-01-01 07:11:35 +0300
commit56258dad4ce7492df3e06c45865015cbb1e588fe (patch)
tree57e0702c02379219e5e6a564d7ef8207e4fd34c5
parent60a3bc9fe7b1ff2a5cb458f2a233d333dc538eab (diff)
downloadkittybox-56258dad4ce7492df3e06c45865015cbb1e588fe.tar.zst
Add a dev-shell and a check to verify MSRV
This builds the entire crate using my chosen MSRV. Isn't that nice?

Change-Id: I8bbe47cc5db63ab3f27616a9e3576a50d349b89b
-rw-r--r--flake.lock23
-rw-r--r--flake.nix38
2 files changed, 43 insertions, 18 deletions
diff --git a/flake.lock b/flake.lock
index 9c2d147..bf7a454 100644
--- a/flake.lock
+++ b/flake.lock
@@ -54,7 +54,28 @@
       "inputs": {
         "crane": "crane",
         "flake-utils": "flake-utils",
-        "nixpkgs": "nixpkgs"
+        "nixpkgs": "nixpkgs",
+        "rust-overlay": "rust-overlay"
+      }
+    },
+    "rust-overlay": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1735698720,
+        "narHash": "sha256-+skLL6mq/T7s6J5YmSp89ivQOHBPQ40GEU2n8yqp6bs=",
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "rev": "a00807363a8a6cae6c3fa84ff494bf9d96333674",
+        "type": "github"
+      },
+      "original": {
+        "owner": "oxalica",
+        "repo": "rust-overlay",
+        "type": "github"
       }
     },
     "systems": {
diff --git a/flake.nix b/flake.nix
index 31fe004..f820e51 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,30 +1,28 @@
 {
   inputs = {
-    flake-utils = {
-      type = "github";
-      owner = "numtide";
-      repo = "flake-utils";
-      ref = "main";
-    };
-    crane = {
-      url = "github:ipetkov/crane";
-      inputs.nixpkgs.follows = "nixpkgs";
-    };
-    nixpkgs = {
-      type = "github";
-      owner = "nixos";
-      repo = "nixpkgs";
-      ref = "nixos-unstable";
+    flake-utils.url = "github:numtide/flake-utils/main";
+    crane.url = "github:ipetkov/crane";
+    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+    rust-overlay = {
+      url = "github:oxalica/rust-overlay";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
     };
   };
-  outputs = { self, nixpkgs, flake-utils, crane }: let
+  outputs = { self, nixpkgs, flake-utils, crane, rust-overlay }: let
     supportedSystems = ["aarch64-linux" "x86_64-linux"];
     forAllSystems = f: flake-utils.lib.eachSystem supportedSystems f;
   in {
     nixosModules.default = import ./configuration.nix self;
   } // forAllSystems (system: let
-    pkgs = nixpkgs.legacyPackages.${system};
+    pkgs = import nixpkgs {
+      overlays = [ rust-overlay.overlays.default ];
+      localSystem = { inherit system; };
+    };
     crane' = crane.mkLib pkgs;
+    cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
+    crane-msrv' = crane'.overrideToolchain (p: p.rust-bin.stable."${cargoToml.package.rust-version}".default);
 
     kittybox = pkgs.callPackage ./kittybox.nix {
       # TODO: this may break cross-compilation. It may be better to
@@ -54,8 +52,14 @@
       nixos-test-postgres = pkgs.nixosTest (import ./nixos-tests/postgres-smoke-test.nix self);
       webmention-test = pkgs.nixosTest (import ./nixos-tests/webmention-test.nix self);
 
+      msrv-check = (self.packages.${system}.kittybox.override { crane = crane-msrv'; });
     };
 
     devShells.default = pkgs.callPackage ./shell.nix {};
+    devShells.msrv = let
+      rust = pkgs.rust-bin.stable."${cargoToml.package.rust-version}".default;
+    in pkgs.callPackage ./shell.nix {
+      cargo = rust; rustc = rust; rust-analyzer = rust;
+    };
   });
 }