Skip to content

Commit

Permalink
build(nix): add minimal flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
21CSM committed Sep 14, 2024
1 parent 14ac232 commit 8e97449
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Nix
result
result-*

# direnv
.direnv/

# macOS
.DS_Store
100 changes: 100 additions & 0 deletions flake.lock

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

36 changes: 36 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
description = "Dev environment for Rust based on Nix flakes";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
rustToolchain = fenix.packages.${system}.minimal.toolchain;
in
{
devShells.default = pkgs.mkShell {
buildInputs = [
rustToolchain
];
};

checks.default = pkgs.runCommand "check-rust-env" {
buildInputs = [ rustToolchain ];
} ''
if ! command -v rustc > /dev/null || ! command -v cargo > /dev/null; then
exit 1
fi
touch $out
'';
}
);
}

0 comments on commit 8e97449

Please sign in to comment.