Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/nix #28

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
**/target
.DS_Store

.env
.vscode
.idea
**/.~lock*
**/.npmrc
**/.envrc
**/.direnv

result
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
121 changes: 121 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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 = ''
'';

};
});
}
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.71.0"
components = ["rustfmt", "cargo", "clippy", "rust-src", "rust-analyzer"]
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down