diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-03-31 18:22:20 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-03-31 23:59:58 +0200 |
commit | 43655648a602b5b21e10dc69726d0d351bec8056 (patch) | |
tree | 39a2d11066355556006e7f61cd8cf1044377a21b /templates/rust/flake.nix | |
parent | refactor(rust): Move to template dir (diff) | |
download | flake-templates-43655648a602b5b21e10dc69726d0d351bec8056.tar.gz flake-templates-43655648a602b5b21e10dc69726d0d351bec8056.zip |
feat(rust): Update to my SOTA
Diffstat (limited to '')
-rw-r--r-- | templates/rust/flake.nix | 81 |
1 files changed, 57 insertions, 24 deletions
diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 4512bed..2e65c7d 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -1,30 +1,20 @@ { - description = "<app_description>"; # TODO + description = "TODO"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - # 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; - }; - crane = { - url = "github:ipetkov/crane"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-compat.follows = "flake-compat"; - flake-utils.follows = "flake-utils"; - rust-overlay.follows = "rust-overlay"; }; }; - flake-utils = { - url = "github:numtide/flake-utils"; + + crane = { + url = "github:ipetkov/crane"; inputs = { - systems.follows = "systems"; + nixpkgs.follows = "nixpkgs"; }; }; rust-overlay = { @@ -34,13 +24,29 @@ flake-utils.follows = "flake-utils"; }; }; + + # 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 = { + systems.follows = "systems"; + }; + }; }; outputs = { self, nixpkgs, - crane, flake-utils, + treefmt-nix, + crane, rust-overlay, ... }: @@ -55,27 +61,54 @@ 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; - craneLib = (crane.mkLib pkgs).overrideToolchain rust_minimal; + 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}; + ''; + }; + + treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;}; in { - packages.default = craneBuild; + packages.default = pkgs.symlinkJoin { + inherit (cargo_toml.package) name; - app.default = { - type = "app"; - program = "${self.packages.${system}.default}/bin/<app_name>"; # TODO + paths = [manual craneBuild]; }; + checks = { + inherit craneBuild; + formatting = treefmtEval.config.build.check self; + }; + + formatter = treefmtEval.config.build.wrapper; + devShells.default = pkgs.mkShell { packages = with pkgs; [ cocogitto |