Skip to content

Commit

Permalink
feat: add Nix flake via ipetkov/crane
Browse files Browse the repository at this point in the history
  • Loading branch information
t56k committed Mar 12, 2024
1 parent 7c0f628 commit 20f9ef5
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export RUST_BACKTRACE=1

use flake .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
*.snap.new
/gitu.log
.direnv
result
106 changes: 106 additions & 0 deletions flake.lock

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

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";

rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};

flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, crane, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
craneLib = crane.lib.${system};

pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};

gitu = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
doCheck = false;
buildInputs = with pkgs; [ openssl ];
nativeBuildInputs = with pkgs; [ pkg-config ];
};
in {
checks = { inherit gitu; };

packages.default = gitu;
apps.default = flake-utils.lib.mkApp { drv = gitu; };

devShells.default = craneLib.devShell {
checks = self.checks.${system};
inputsFrom = [ gitu ];
packages = with pkgs; [ cargo-insta clippy rust-analyzer rustfmt ];
};
});
}

0 comments on commit 20f9ef5

Please sign in to comment.