about summary refs log tree commit diff stats
path: root/flake.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-06 15:45:11 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-06 15:45:11 +0200
commita6baea06697f6c76c695dc4198099deb8ba916e0 (patch)
tree476a3865f6b4bef04751ba20534813a58892811b /flake.nix
parentchore: Initial commit (diff)
downloadback-a6baea06697f6c76c695dc4198099deb8ba916e0.zip
feat(treewide): Prepare for first release
This commit contains many changes, as they were developed alongside
`git-bug-rs` and unfortunately not separately committed.

A toplevel summary would include:
- Appropriate redirects,
- The templating moved to `vy` (as this works with rustfmt formatting),
- Search support (via `git-bug-rs`),
- And better layout in the link section.
Diffstat (limited to '')
-rw-r--r--flake.nix91
1 files changed, 18 insertions, 73 deletions
diff --git a/flake.nix b/flake.nix
index 7389429..b6df3c8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -21,25 +21,9 @@
       };
     };
 
-    crane = {
-      url = "github:ipetkov/crane";
-      inputs = {};
-    };
-    rust-overlay = {
-      url = "github:oxalica/rust-overlay";
-      inputs = {
-        nixpkgs.follows = "nixpkgs";
-      };
-    };
-
-    # inputs for following
     systems = {
       url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
     };
-    flake-compat = {
-      url = "github:edolstra/flake-compat";
-      flake = false;
-    };
     flake-utils = {
       url = "github:numtide/flake-utils";
       inputs = {
@@ -53,81 +37,42 @@
     nixpkgs,
     flake-utils,
     treefmt-nix,
-    crane,
-    rust-overlay,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (system: let
-      pkgs = import nixpkgs {
-        inherit system;
-        overlays = [(import rust-overlay)];
-      };
-
-      nightly = true;
-      rust_minimal =
-        if nightly
-        then pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal)
-        else pkgs.rust-bin.stable.latest.minimal;
-      rust_default =
-        if nightly
-        then pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)
-        else pkgs.rust-bin.stable.latest.default;
-
-      cargo_toml = craneLib.cleanCargoToml {cargoToml = ./Cargo.toml;};
-      pname = cargo_toml.package.name;
-
-      craneLib = (crane.mkLib pkgs).overrideToolchain rust_minimal;
-      craneBuild = craneLib.buildPackage {
-        src = craneLib.cleanCargoSource ./.;
-
-        doCheck = true;
-      };
-
-      manual = pkgs.stdenv.mkDerivation {
-        name = "${pname}-manual";
-        inherit (cargo_toml.package) version;
-
-        src = ./docs;
-        nativeBuildInputs = with pkgs; [pandoc];
-
-        buildPhase = ''
-          mkdir --parents $out/docs;
-
-          pandoc "./${pname}.1.md" -s -t man > $out/docs/${pname}.1
-        '';
-
-        installPhase = ''
-          install -D $out/docs/${pname}.1  $out/share/man/man1/${pname};
-        '';
-      };
+      pkgs = nixpkgs.legacyPackages."x86_64-linux";
 
       treefmtEval = import ./treefmt.nix {
         inherit treefmt-nix pkgs;
-        rustfmt = rust_default;
       };
-    in {
-      packages.default = pkgs.symlinkJoin {
-        inherit (cargo_toml.package) name;
 
-        paths = [manual craneBuild];
-      };
+      rustfmt = pkgs.writeShellScriptBin "rustfmt" ''
+        # Avoid the duplicated edition flag, that rust-analyzer passes.
+        if [ "$1" = "--edition" ] && [ "$2" == "2024" ]; then
+            shift 2
+        fi
 
+        ${pkgs.lib.getExe pkgs.rustfmt} ${builtins.concatStringsSep " " treefmtEval.config.settings.formatter.rustfmt.options} "$@"
+      '';
+    in {
       checks = {
-        inherit craneBuild;
         formatting = treefmtEval.config.build.check self;
       };
 
       formatter = treefmtEval.config.build.wrapper;
 
       devShells.default = pkgs.mkShell {
-        packages = with pkgs; [
-          cocogitto
-          git-bug
+        packages = [
+          pkgs.cocogitto
+          pkgs.git-bug
 
-          rust_default
-          cargo-edit
+          pkgs.rustc
+          pkgs.cargo
+          pkgs.clippy
+          rustfmt
+          pkgs.cargo-edit
 
-          reuse
+          pkgs.reuse
         ];
       };
     });