-
Notifications
You must be signed in to change notification settings - Fork 0
Add Rust template #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a4a125
First iteration of template
lucperkins c9f2dca
Add Rust template checks
lucperkins 389a5dc
Move package builder function out of overlay
lucperkins f4006ed
Add cargo-* tools and overlay for crane
lucperkins f49921a
Use only Nixpkgs machinery
lucperkins 9d87fbf
Fill out the description and welcome text
lucperkins fc1c325
Add note for stable/unstable Nixpkgs
lucperkins 9807c99
Add Nix formatter
lucperkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Rust artifacts | ||
| /target/ | ||
|
|
||
| # Nix artifacts | ||
| result* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [package] | ||
| name = "rust-flake-template" | ||
| version = "0.1.0" | ||
| edition = "2024" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| { | ||
| description = "A Rust flake template that you can adapt to your own environment"; | ||
|
|
||
| # Flake inputs | ||
| inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; # Stable Nixpkgs (use 0.1 for unstable) | ||
|
|
||
| # Flake outputs | ||
| outputs = | ||
| { self, ... }@inputs: | ||
| let | ||
| # The systems supported for this flake's outputs | ||
| supportedSystems = [ | ||
| "x86_64-linux" # 64-bit Intel/AMD Linux | ||
| "aarch64-linux" # 64-bit ARM Linux | ||
| "x86_64-darwin" # 64-bit Intel macOS | ||
| "aarch64-darwin" # 64-bit ARM macOS | ||
| ]; | ||
|
|
||
| # Helper for providing system-specific attributes | ||
| forEachSupportedSystem = | ||
| f: | ||
| inputs.nixpkgs.lib.genAttrs supportedSystems ( | ||
| system: | ||
| f { | ||
| # Provides a system-specific, configured Nixpkgs | ||
| pkgs = import inputs.nixpkgs { | ||
| inherit system; | ||
| # Enable using unfree packages | ||
| config.allowUnfree = true; | ||
| }; | ||
| } | ||
| ); | ||
| in | ||
| { | ||
| # Development environments output by this flake | ||
| devShells = forEachSupportedSystem ( | ||
| { pkgs }: | ||
| { | ||
| # Run `nix develop` to activate this environment or `direnv allow` if you have direnv installed | ||
| default = pkgs.mkShell { | ||
| # The Nix packages provided in the environment | ||
| packages = with pkgs; [ | ||
| cargo | ||
| rustc | ||
| clippy | ||
| rustfmt | ||
| rust-analyzer # Rust language server for IDEs | ||
| # Uncomment the lines below for some helpful tools: | ||
| # cargo-edit # Commands like `cargo add` and `cargo rm` | ||
| # bacon # For iterative development | ||
| # cargo-nextest # Rust testing tool | ||
| # cargo-audit # Check dependencies for vulnerabilities | ||
| # cargo-outdated # Show which dependencies have updates available | ||
| # cargo-deny # Lint your dependency graph | ||
| # cargo-expand # Show macro expansions | ||
| ]; | ||
|
|
||
| # Set any environment variables for your development environment | ||
| env = { | ||
| RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; | ||
| }; | ||
|
|
||
| # Add any shell logic you want executed when the environment is activated | ||
| shellHook = '' | ||
| echo "Rust toolchain 🦀" | ||
| cargo --version | ||
| ''; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| # Package outputs | ||
| packages = forEachSupportedSystem ( | ||
| { pkgs }: | ||
| { | ||
| # Build the package using Nixpkgs' built-in Rust helpers | ||
| default = | ||
| let | ||
| # Get information about the package from Cargo.toml | ||
| meta = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package; | ||
| in | ||
| pkgs.rustPlatform.buildRustPackage { | ||
| inherit (meta) name version; | ||
| src = builtins.path { | ||
| path = ./.; | ||
| }; | ||
| cargoLock.lockFile = ./Cargo.lock; | ||
| }; | ||
| } | ||
| ); | ||
|
|
||
| # Nix formatter | ||
|
|
||
| # This applies the formatter that follows RFC 166, which defines a standard format: | ||
| # https://github.com/NixOS/rfcs/pull/166 | ||
|
|
||
| # To format all Nix files: | ||
| # git ls-files -z '*.nix' | xargs -0 -r nix fmt | ||
| # To check formatting: | ||
| # git ls-files -z '*.nix' | xargs -0 -r nix develop --command nixfmt --check | ||
| formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| fn main() { | ||
| println!("Hello from the Rust template!"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.