diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index 576f200..7f244a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,12 @@ **/target +.DS_Store +.env +.vscode +.idea +**/.~lock* +**/.npmrc +**/.envrc +**/.direnv + +result diff --git a/README.md b/README.md index 145c60a..f27e605 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ cargo install --git https://github.com/tacogips/async-graphql-reverse --branch m ### usage ``` -async-graphql-reverse 0.5.0 +async-graphql-reverse 0.6.0 tacogips USAGE: diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d2ae745 --- /dev/null +++ b/flake.lock @@ -0,0 +1,121 @@ +{ + "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704819371, + "narHash": "sha256-oFUfPWrWGQTZaCM3byxwYwrMLwshDxVGOrMH5cVP/X8=", + "owner": "ipetkov", + "repo": "crane", + "rev": "5c234301a1277e4cc759c23a2a7a00a06ddd7111", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1705472611, + "narHash": "sha256-o9zxn4OPM6ltNmsiIK4Fl1k6aIF73x2wELGeCQYdO0k=", + "owner": "nix-community", + "repo": "fenix", + "rev": "39ef99bcc06101639781bdb5dd69155b7033badd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705543379, + "narHash": "sha256-8wC0vVz/LTqJprbAAvE9P4L01Mi6DJHYwvuM0Uq57og=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3d7dbcfb56a1cff0729280da3f1185044628975b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1705432736, + "narHash": "sha256-uUS5B8ypVevvhjA/2smEOu5s8zK3MBJU5tH0Tze3Kok=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "03336460fcb25a86675aaff9694998f5910ff747", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f6553e0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,94 @@ +{ + description = "my rust project"; + + inputs = + { + nixpkgs.url = "github:NixOS/nixpkgs/release-23.11"; + flake-utils.url = "github:numtide/flake-utils"; + fenix = + { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { self + , nixpkgs + , flake-utils + , fenix + , crane + , + }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ fenix.overlays.default ]; + pkgs = import nixpkgs { inherit system overlays; }; + rust-components = fenix.packages.${system}.fromToolchainFile + { + file = ./rust-toolchain.toml; + #sha256 = nixpkgs.lib.fakeSha256; + sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78="; + }; + + crane-lib = crane.lib.${system}.overrideToolchain rust-components; + rust-src = crane-lib.cleanCargoSource (crane-lib.path ./.); + + crane-build-args = { + src = rust-src; + strictDeps = true; + + buildInputs = [ + # Add additional build inputs here + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + pkgs.libiconv + ]; + }; + root-cargo-artifacts = crane-lib.buildDepsOnly crane-build-args; + + root-crate = crane-lib.buildPackage { + cargoArtifacts = root-cargo-artifacts; + src = rust-src; + cargoToml = ./Cargo.toml; + }; + + # TODO(tacogips) fix clippy warnings later + #crate-clippy = crane-lib.cargoClippy { + # cargoArtifacts = root-cargo-artifacts; + # src = rust-src; + # #cargoClippyExtraArgs = "-- --deny warnings"; + #}; + + in + { + # --- checks --- + checks = { + inherit root-crate; #crate-clippy; + }; + packages. default = root-crate; + + apps.default = flake-utils.lib.mkApp { + drv = root-crate; + }; + + # --- dev shell --- + devShells.default = crane-lib.devShell + { + packages = with pkgs; + [ + nixpkgs-fmt + taplo-cli + cargo-make + rust-analyzer + cachix + ]; + shellHook = '' + ''; + + }; + }); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..43227c5 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.71.0" +components = ["rustfmt", "cargo", "clippy", "rust-src", "rust-analyzer"] diff --git a/src/bin/main.rs b/src/bin/main.rs index 4607c12..69377ce 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -3,7 +3,7 @@ use clap::{Parser, Subcommand}; use env_logger; #[derive(Parser)] -#[clap(version = "0.4.0", author = "tacogips")] +#[clap(version = "0.6.0", author = "tacogips")] struct Opts { #[clap(long, short)] input_schema: String,