From e0f9192d43a870b52fdb04a313d928fb22ee0ba7 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 16 Sep 2024 22:17:46 +0100 Subject: add derivation to build tbsp --- flake.nix | 102 +++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/flake.nix b/flake.nix index 4f69fe8..50f9efc 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,5 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; gitignore = { @@ -9,55 +8,70 @@ }; rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; }; - }; - outputs = - { self - , nixpkgs - , gitignore - , rust-overlay - }: - let - inherit (gitignore.lib) gitignoreSource; - - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = forAllSystems (system: + outputs = { + self, + nixpkgs, + gitignore, + rust-overlay, + }: let + inherit (gitignore.lib) gitignoreSource; + + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { - inherit system; - overlays = [rust-overlay.overlays.default]; + inherit system; + overlays = [rust-overlay.overlays.default self.overlays.default]; }); + in { + overlays.default = final: prev: { + tbsp = with final; let + pname = "tbsp"; + packageMeta = (lib.importTOML ./Cargo.toml).package; + rustPlatform = makeRustPlatform { + inherit (final) cargo rustc; + }; + in + rustPlatform.buildRustPackage { + inherit pname; + inherit (packageMeta) version; - in - { - - devShell = forAllSystems (system: - let - pkgs = nixpkgsFor."${system}"; - in - pkgs.mkShell { - nativeBuildInputs = [ - pkgs.cargo-watch - pkgs.bacon - pkgs.rustfmt - pkgs.cargo - - pkgs.rust-bin.nightly.latest.default - pkgs.rust-bin.nightly.latest.rust-analyzer - pkgs.lld - pkgs.trunk - - - pkgs.mermaid-cli - ]; - RUST_LOG = "info"; - RUST_BACKTRACE = 1; - }); + src = self; + cargoLock.lockFile = ./Cargo.lock; + + meta = with lib; { + description = "tree-based source processing language"; + homepage = "https://git.peppe.rs/languages/tbsp/about"; + license = licenses.mit; + }; + }; }; -} + defaultPackage = forAllSystems (system: nixpkgsFor."${system}".tbsp); + formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); + devShell = forAllSystems (system: let + pkgs = nixpkgsFor."${system}"; + in + pkgs.mkShell { + nativeBuildInputs = [ + pkgs.cargo-watch + pkgs.bacon + pkgs.rustfmt + pkgs.cargo + + pkgs.rust-bin.nightly.latest.default + pkgs.rust-bin.nightly.latest.rust-analyzer + + pkgs.mermaid-cli + ]; + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }); + }; +} -- cgit v1.2.3