-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Added nix support #29
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
unhappychoice
merged 4 commits into
unhappychoice:main
from
of-the-stars:feature/nix-support
Mar 1, 2026
+215
−0
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| 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 |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| /target | ||
| /.direnv | ||
| /result |
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
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,97 @@ | ||
| { | ||
| description = "Steamfetch nix flake"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
| crane.url = "github:ipetkov/crane"; | ||
| rust-overlay = { | ||
| url = "github:oxalica/rust-overlay"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
| }; | ||
|
|
||
| outputs = | ||
| { | ||
| self, | ||
| nixpkgs, | ||
| flake-utils, | ||
| crane, | ||
| rust-overlay, | ||
| }: | ||
| flake-utils.lib.eachDefaultSystem ( | ||
| system: | ||
| let | ||
| pkgs = import nixpkgs { | ||
| inherit system; | ||
| overlays = [ (import rust-overlay) ]; | ||
| }; | ||
|
|
||
| # Builds the rust components from the toolchain file, or defaults back to the latest nightly build | ||
| rust-toolchain = | ||
| if builtins.pathExists ./rust-toolchain.toml then | ||
| pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml | ||
| else | ||
| pkgs.rust-bin.selectLatestNightlyWith ( | ||
| toolchain: | ||
| toolchain.default.override { | ||
| extensions = [ "rust-src" ]; | ||
| } | ||
| ); | ||
|
|
||
| # Instantiates custom craneLib using toolchain | ||
| craneLib = (crane.mkLib pkgs).overrideToolchain rust-toolchain; | ||
|
|
||
| src = craneLib.cleanCargoSource ./.; | ||
| pname = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; }.pname; | ||
|
|
||
| # Common arguments shared between buildPackage and buildDepsOnly | ||
| commonArgs = { | ||
| inherit src; | ||
| strictDeps = true; | ||
|
|
||
| buildInputs = with pkgs; [ | ||
| openssl | ||
| ]; | ||
|
|
||
| nativeBuildInputs = with pkgs; [ | ||
| pkg-config | ||
| ]; | ||
| }; | ||
|
|
||
| cargoArtifacts = craneLib.buildDepsOnly (commonArgs); | ||
|
|
||
| crane-package = craneLib.buildPackage ( | ||
| commonArgs | ||
| // { | ||
| inherit cargoArtifacts; | ||
| postInstall = '' | ||
| mkdir -p $out/bin | ||
| cp ./target/release/libsteam_api.* $out/bin/. | ||
| ''; | ||
of-the-stars marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| ); | ||
| in | ||
| { | ||
| devShells.default = pkgs.mkShell { | ||
| # Inherits buildInputs from crane-package | ||
| inputsFrom = [ crane-package ]; | ||
|
|
||
| # Additional packages for the dev environment | ||
| packages = with pkgs; [ | ||
| ]; | ||
|
|
||
| shellHook = ""; | ||
|
|
||
| env = { | ||
| # Needed for rust-analyzer | ||
| RUST_SRC_PATH = "${rust-toolchain}/lib/rustlib/src/rust/library"; | ||
| }; | ||
| }; | ||
|
|
||
| packages.default = crane-package; | ||
|
|
||
| formatter = pkgs.nixfmt-tree; | ||
| } | ||
| ); | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: unhappychoice/steamfetch
Length of output: 254
🏁 Script executed:
Repository: unhappychoice/steamfetch
Length of output: 542
🏁 Script executed:
Repository: unhappychoice/steamfetch
Length of output: 671
Uncomment
rust-srcextension; nightly fallback will cause issues.Two confirmed problems:
Line 38:
rust-srcis commented out, but the devShell (line 87) setsRUST_SRC_PATH = "${rust-toolchain}/lib/rustlib/src/rust/library"assuming it exists. Sincerust-toolchain.tomlis absent, the nightly fallback will be used and won't includerust-src, causingRUST_SRC_PATHto point to a nonexistent path and breaking rust-analyzer.With no
rust-toolchain.tomland norust-versioninCargo.toml, the project will always use the latest nightly Rust. This is likely unintended and may cause unexpected build failures or compatibility issues.Proposed fix
rust-toolchain = if builtins.pathExists ./rust-toolchain.toml then pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml else - pkgs.rust-bin.selectLatestNightlyWith ( - toolchain: - toolchain.default.override { - # extensions = [ "rust-src" ]; - } - ); + pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + };📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did catch the flake description, so I'll change that. I assumed it was alright to use the latest nightly build and have it be pinned via
flake.lock, but if you think it should be the default stable toolchain instead LMK!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@of-the-starsYou're absolutely right aboutflake.lockpinning! I overlooked that detail. The nightly version will indeed be locked until you explicitly runnix flake update, so it won't cause unexpected changes. That's a perfectly reasonable approach for Nix users.The main issue is still the commented-out
rust-srcextension on line 38. Since the devShell referencesRUST_SRC_PATHon line 87, you'll need to uncomment that line:As for nightly vs stable, that's your call! If the project builds fine with nightly and you prefer it, go ahead and keep it. Just make sure
rust-srcis included so rust-analyzer works properly in the dev shell. 🙂