diff options
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | default.nix | 12 | ||||
-rw-r--r-- | flake.lock | 87 | ||||
-rw-r--r-- | flake.nix | 97 | ||||
-rw-r--r-- | shell.nix | 14 | ||||
-rw-r--r-- | src/parse.rs | 6 |
7 files changed, 200 insertions, 20 deletions
@@ -173,7 +173,7 @@ dependencies = [ | |||
173 | 173 | ||
174 | [[package]] | 174 | [[package]] |
175 | name = "eva" | 175 | name = "eva" |
176 | version = "0.2.7" | 176 | version = "0.3.0" |
177 | dependencies = [ | 177 | dependencies = [ |
178 | "clap", | 178 | "clap", |
179 | "directories", | 179 | "directories", |
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "eva" | 2 | name = "eva" |
3 | version = "0.2.7" | 3 | version = "0.3.0" |
4 | authors = ["NerdyPepper <[email protected]>"] | 4 | authors = ["NerdyPepper <[email protected]>"] |
5 | edition = "2018" | 5 | edition = "2018" |
6 | description = "Calculator REPL similar to bc(1)" | 6 | 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 @@ | |||
1 | let | 1 | # The `default.nix` in flake-compat reads `flake.nix` and `flake.lock` from `src` and |
2 | pkgs = import <nixpkgs> {}; | 2 | # returns an attribute set of the shape `{ defaultNix, shellNix }` |
3 | sources = import ./nix/sources.nix; | 3 | |
4 | naersk = pkgs.callPackage sources.naersk {}; | 4 | (import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { |
5 | in | 5 | src = ./.; |
6 | naersk.buildPackage ./. | 6 | }).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 @@ | |||
1 | { | ||
2 | "nodes": { | ||
3 | "fenix": { | ||
4 | "inputs": { | ||
5 | "nixpkgs": [ | ||
6 | "nixpkgs" | ||
7 | ], | ||
8 | "rust-analyzer-src": "rust-analyzer-src" | ||
9 | }, | ||
10 | "locked": { | ||
11 | "lastModified": 1645251813, | ||
12 | "narHash": "sha256-cQ66tGjnZclBCS3nD26mZ5fUH+3/HnysGffBiWXUSHk=", | ||
13 | "owner": "nix-community", | ||
14 | "repo": "fenix", | ||
15 | "rev": "9892337b588c38ec59466a1c89befce464aae7f8", | ||
16 | "type": "github" | ||
17 | }, | ||
18 | "original": { | ||
19 | "owner": "nix-community", | ||
20 | "repo": "fenix", | ||
21 | "type": "github" | ||
22 | } | ||
23 | }, | ||
24 | "gitignore": { | ||
25 | "inputs": { | ||
26 | "nixpkgs": [ | ||
27 | "nixpkgs" | ||
28 | ] | ||
29 | }, | ||
30 | "locked": { | ||
31 | "lastModified": 1635165013, | ||
32 | "narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=", | ||
33 | "owner": "hercules-ci", | ||
34 | "repo": "gitignore.nix", | ||
35 | "rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1", | ||
36 | "type": "github" | ||
37 | }, | ||
38 | "original": { | ||
39 | "owner": "hercules-ci", | ||
40 | "repo": "gitignore.nix", | ||
41 | "type": "github" | ||
42 | } | ||
43 | }, | ||
44 | "nixpkgs": { | ||
45 | "locked": { | ||
46 | "lastModified": 1645013224, | ||
47 | "narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=", | ||
48 | "owner": "nixos", | ||
49 | "repo": "nixpkgs", | ||
50 | "rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970", | ||
51 | "type": "github" | ||
52 | }, | ||
53 | "original": { | ||
54 | "owner": "nixos", | ||
55 | "ref": "nixpkgs-unstable", | ||
56 | "repo": "nixpkgs", | ||
57 | "type": "github" | ||
58 | } | ||
59 | }, | ||
60 | "root": { | ||
61 | "inputs": { | ||
62 | "fenix": "fenix", | ||
63 | "gitignore": "gitignore", | ||
64 | "nixpkgs": "nixpkgs" | ||
65 | } | ||
66 | }, | ||
67 | "rust-analyzer-src": { | ||
68 | "flake": false, | ||
69 | "locked": { | ||
70 | "lastModified": 1645205556, | ||
71 | "narHash": "sha256-e4lZW3qRyOEJ+vLKFQP7m2Dxh5P44NrnekZYLxlucww=", | ||
72 | "owner": "rust-analyzer", | ||
73 | "repo": "rust-analyzer", | ||
74 | "rev": "acf5874b39f3dc5262317a6074d9fc7285081161", | ||
75 | "type": "github" | ||
76 | }, | ||
77 | "original": { | ||
78 | "owner": "rust-analyzer", | ||
79 | "ref": "nightly", | ||
80 | "repo": "rust-analyzer", | ||
81 | "type": "github" | ||
82 | } | ||
83 | } | ||
84 | }, | ||
85 | "root": "root", | ||
86 | "version": 7 | ||
87 | } | ||
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..38bc205 --- /dev/null +++ b/flake.nix | |||
@@ -0,0 +1,97 @@ | |||
1 | { | ||
2 | inputs = { | ||
3 | |||
4 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
5 | |||
6 | fenix = { | ||
7 | url = "github:nix-community/fenix"; | ||
8 | inputs.nixpkgs.follows = "nixpkgs"; | ||
9 | }; | ||
10 | |||
11 | gitignore = { | ||
12 | url = "github:hercules-ci/gitignore.nix"; | ||
13 | inputs.nixpkgs.follows = "nixpkgs"; | ||
14 | }; | ||
15 | |||
16 | }; | ||
17 | |||
18 | outputs = | ||
19 | { self | ||
20 | , nixpkgs | ||
21 | , fenix | ||
22 | , gitignore | ||
23 | }: | ||
24 | let | ||
25 | inherit (gitignore.lib) gitignoreSource; | ||
26 | |||
27 | supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
28 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
29 | nixpkgsFor = forAllSystems (system: | ||
30 | import nixpkgs { | ||
31 | inherit system; | ||
32 | overlays = [ self.overlay ]; | ||
33 | }); | ||
34 | |||
35 | chanspec = { | ||
36 | date = "2022-02-06"; | ||
37 | channel = "nightly"; | ||
38 | sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date | ||
39 | }; | ||
40 | rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec; | ||
41 | |||
42 | in | ||
43 | { | ||
44 | |||
45 | overlay = final: prev: { | ||
46 | |||
47 | eva = with final; | ||
48 | let | ||
49 | pname = "eva"; | ||
50 | packageMeta = (lib.importTOML ./Cargo.toml).package; | ||
51 | rustPlatform = makeRustPlatform { | ||
52 | inherit (rustChannel final) cargo rustc; | ||
53 | }; | ||
54 | in | ||
55 | rustPlatform.buildRustPackage { | ||
56 | inherit pname; | ||
57 | inherit (packageMeta) version; | ||
58 | |||
59 | src = gitignoreSource ./.; | ||
60 | cargoLock.lockFile = ./Cargo.lock; | ||
61 | }; | ||
62 | |||
63 | }; | ||
64 | |||
65 | packages = forAllSystems (system: { | ||
66 | inherit (nixpkgsFor."${system}") eva; | ||
67 | }); | ||
68 | |||
69 | defaultPackage = | ||
70 | forAllSystems (system: self.packages."${system}".eva); | ||
71 | |||
72 | devShell = forAllSystems (system: | ||
73 | let | ||
74 | pkgs = nixpkgsFor."${system}"; | ||
75 | toolchain = (rustChannel pkgs).withComponents [ | ||
76 | "rustc" | ||
77 | "cargo" | ||
78 | "rust-std" | ||
79 | "rustfmt" | ||
80 | "clippy" | ||
81 | "rust-src" | ||
82 | ]; | ||
83 | inherit (fenix.packages."${system}") rust-analyzer; | ||
84 | in | ||
85 | pkgs.mkShell { | ||
86 | nativeBuildInputs = [ | ||
87 | pkgs.bacon | ||
88 | pkgs.cargo-insta | ||
89 | rust-analyzer | ||
90 | toolchain | ||
91 | ]; | ||
92 | RUST_LOG = "info"; | ||
93 | RUST_BACKTRACE = 1; | ||
94 | }); | ||
95 | |||
96 | }; | ||
97 | } | ||
@@ -1,10 +1,6 @@ | |||
1 | { pkgs ? import <nixpkgs> {} }: | 1 | # The `default.nix` in flake-compat reads `flake.nix` and `flake.lock` from `src` and |
2 | # returns an attribute set of the shape `{ defaultNix, shellNix }` | ||
2 | 3 | ||
3 | pkgs.mkShell { | 4 | (import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { |
4 | buildInputs = with pkgs; [ | 5 | src = ./.; |
5 | cargo | 6 | }).shellNix |
6 | rustc | ||
7 | rustfmt | ||
8 | pkg-config | ||
9 | ]; | ||
10 | } | ||
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<Token>) -> Result<f64, CalcError> { | |||
78 | num_stack.push(op.operate(n1, n2)?); | 78 | num_stack.push(op.operate(n1, n2)?); |
79 | } else { | 79 | } else { |
80 | return Err(CalcError::Parser( | 80 | return Err(CalcError::Parser( |
81 | "Too many operators, Too little operands".to_string(), | 81 | "Too many operators, too few operands".to_string(), |
82 | )); | 82 | )); |
83 | } | 83 | } |
84 | } else { | 84 | } else { |
85 | return Err(CalcError::Parser( | 85 | return Err(CalcError::Parser( |
86 | "Too many operators, Too little operands".to_string(), | 86 | "Too many operators, too few operands".to_string(), |
87 | )); | 87 | )); |
88 | } | 88 | } |
89 | } | 89 | } |
@@ -99,7 +99,7 @@ pub fn eval_postfix(postfixed: Vec<Token>) -> Result<f64, CalcError> { | |||
99 | Ok(num_stack.pop().unwrap()) | 99 | Ok(num_stack.pop().unwrap()) |
100 | } else { | 100 | } else { |
101 | Err(CalcError::Parser( | 101 | Err(CalcError::Parser( |
102 | "Too many operators, Too little operands".to_string(), | 102 | "Too many operators, too few operands".to_string(), |
103 | )) | 103 | )) |
104 | } | 104 | } |
105 | } | 105 | } |