From 2886114cf60b56cb724d7ec9420d0d5eb60e7fa0 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 5 Apr 2022 19:18:19 +0530 Subject: bump to v0.3.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- default.nix | 12 ++++---- flake.lock | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 14 ++++----- src/parse.rs | 6 ++-- 7 files changed, 200 insertions(+), 20 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Cargo.lock b/Cargo.lock index 287db82..4577d96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "eva" -version = "0.2.7" +version = "0.3.0" dependencies = [ "clap", "directories", diff --git a/Cargo.toml b/Cargo.toml index 4be652d..eab73f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eva" -version = "0.2.7" +version = "0.3.0" authors = ["NerdyPepper "] edition = "2018" description = "Calculator REPL similar to bc(1)" diff --git a/default.nix b/default.nix index a755ba1..b81119c 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ -let - pkgs = import {}; - sources = import ./nix/sources.nix; - naersk = pkgs.callPackage sources.naersk {}; -in - naersk.buildPackage ./. +# The `default.nix` in flake-compat reads `flake.nix` and `flake.lock` from `src` and +# returns an attribute set of the shape `{ defaultNix, shellNix }` + +(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { + src = ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a7c083f --- /dev/null +++ b/flake.lock @@ -0,0 +1,87 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1645251813, + "narHash": "sha256-cQ66tGjnZclBCS3nD26mZ5fUH+3/HnysGffBiWXUSHk=", + "owner": "nix-community", + "repo": "fenix", + "rev": "9892337b588c38ec59466a1c89befce464aae7f8", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1635165013, + "narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1645013224, + "narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1645205556, + "narHash": "sha256-e4lZW3qRyOEJ+vLKFQP7m2Dxh5P44NrnekZYLxlucww=", + "owner": "rust-analyzer", + "repo": "rust-analyzer", + "rev": "acf5874b39f3dc5262317a6074d9fc7285081161", + "type": "github" + }, + "original": { + "owner": "rust-analyzer", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..38bc205 --- /dev/null +++ b/flake.nix @@ -0,0 +1,97 @@ +{ + inputs = { + + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + }; + + outputs = + { self + , nixpkgs + , fenix + , gitignore + }: + 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 = [ self.overlay ]; + }); + + chanspec = { + date = "2022-02-06"; + channel = "nightly"; + sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date + }; + rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec; + + in + { + + overlay = final: prev: { + + eva = with final; + let + pname = "eva"; + packageMeta = (lib.importTOML ./Cargo.toml).package; + rustPlatform = makeRustPlatform { + inherit (rustChannel final) cargo rustc; + }; + in + rustPlatform.buildRustPackage { + inherit pname; + inherit (packageMeta) version; + + src = gitignoreSource ./.; + cargoLock.lockFile = ./Cargo.lock; + }; + + }; + + packages = forAllSystems (system: { + inherit (nixpkgsFor."${system}") eva; + }); + + defaultPackage = + forAllSystems (system: self.packages."${system}".eva); + + devShell = forAllSystems (system: + let + pkgs = nixpkgsFor."${system}"; + toolchain = (rustChannel pkgs).withComponents [ + "rustc" + "cargo" + "rust-std" + "rustfmt" + "clippy" + "rust-src" + ]; + inherit (fenix.packages."${system}") rust-analyzer; + in + pkgs.mkShell { + nativeBuildInputs = [ + pkgs.bacon + pkgs.cargo-insta + rust-analyzer + toolchain + ]; + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }); + + }; +} diff --git a/shell.nix b/shell.nix index c0e1bb0..1ad58f4 100644 --- a/shell.nix +++ b/shell.nix @@ -1,10 +1,6 @@ -{ pkgs ? import {} }: +# The `default.nix` in flake-compat reads `flake.nix` and `flake.lock` from `src` and +# returns an attribute set of the shape `{ defaultNix, shellNix }` -pkgs.mkShell { - buildInputs = with pkgs; [ - cargo - rustc - rustfmt - pkg-config - ]; -} +(import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { + src = ./.; +}).shellNix diff --git a/src/parse.rs b/src/parse.rs index aa8bd4b..74b9841 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -78,12 +78,12 @@ pub fn eval_postfix(postfixed: Vec) -> Result { num_stack.push(op.operate(n1, n2)?); } else { return Err(CalcError::Parser( - "Too many operators, Too little operands".to_string(), + "Too many operators, too few operands".to_string(), )); } } else { return Err(CalcError::Parser( - "Too many operators, Too little operands".to_string(), + "Too many operators, too few operands".to_string(), )); } } @@ -99,7 +99,7 @@ pub fn eval_postfix(postfixed: Vec) -> Result { Ok(num_stack.pop().unwrap()) } else { Err(CalcError::Parser( - "Too many operators, Too little operands".to_string(), + "Too many operators, too few operands".to_string(), )) } } -- cgit v1.2.3