Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/.direnv
/result
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ curl -fsSL https://raw.githubusercontent.com/unhappychoice/steamfetch/main/insta
brew install unhappychoice/tap/steamfetch
```

### Nix

Try it without installing via Nix

```bash
nix run github:unhappychoice/steamfetch
```

To pass arguments, add `--` to the end of the `nix run` invocation

```bash
nix run github:unhappychoice/steamfetch -- --demo # Everything after `--` is passed as an argument to steamfetch
```

### Download Binary

Download the latest release from [GitHub Releases](https://github.com/unhappychoice/steamfetch/releases).
Expand Down
98 changes: 98 additions & 0 deletions flake.lock

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

97 changes: 97 additions & 0 deletions flake.nix
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" ];
}
);
Comment on lines +33 to +43
Copy link

@coderabbitai coderabbitai bot Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if rust-toolchain.toml exists in the repo and what channel it specifies
echo "=== Checking for rust-toolchain.toml ==="
fd -t f 'rust-toolchain' --max-depth 1
echo "---"
if [ -f rust-toolchain.toml ]; then
  echo "Contents:"
  cat rust-toolchain.toml
elif [ -f rust-toolchain ]; then
  echo "Contents of rust-toolchain:"
  cat rust-toolchain
else
  echo "No rust-toolchain file found - nightly fallback WILL be used"
fi

echo ""
echo "=== Checking Cargo.toml for rust-version (MSRV) ==="
rg -n 'rust-version' Cargo.toml || echo "No rust-version field found"

Repository: unhappychoice/steamfetch

Length of output: 254


🏁 Script executed:

#!/bin/bash
# Verify the flake.nix devShell configuration around line 88
echo "=== Checking flake.nix lines 80-95 for RUST_SRC_PATH ==="
sed -n '80,95p' flake.nix

Repository: unhappychoice/steamfetch

Length of output: 542


🏁 Script executed:

#!/bin/bash
# Verify lines 30-40 in flake.nix to confirm rust-src is commented out
echo "=== Checking flake.nix lines 28-42 for rust-src status ==="
sed -n '28,42p' flake.nix

Repository: unhappychoice/steamfetch

Length of output: 671


Uncomment rust-src extension; nightly fallback will cause issues.

Two confirmed problems:

  1. Line 38: rust-src is commented out, but the devShell (line 87) sets RUST_SRC_PATH = "${rust-toolchain}/lib/rustlib/src/rust/library" assuming it exists. Since rust-toolchain.toml is absent, the nightly fallback will be used and won't include rust-src, causing RUST_SRC_PATH to point to a nonexistent path and breaking rust-analyzer.

  2. With no rust-toolchain.toml and no rust-version in Cargo.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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 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" ];
}
);
# 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.stable.latest.default.override {
extensions = [ "rust-src" ];
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 30 - 40, The rust-src extension is commented out in
the rust-toolchain fallback which breaks RUST_SRC_PATH in the devShell and
causes rust-analyzer issues; update the rust-toolchain fallback (the expression
assigning rust-toolchain) to enable the rust-src extension (uncomment or add
"extensions = [ \"rust-src\" ]" inside toolchain.default.override) so the
selected nightly includes source files, and also add guidance to require an
explicit rust-toolchain.toml or rust-version in Cargo.toml to avoid always using
the latest nightly (reference: rust-toolchain, rust-src, RUST_SRC_PATH,
devShell, rust-toolchain.toml, Cargo.toml).

Copy link
Contributor Author

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!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@of-the-stars You're absolutely right about flake.lock pinning! I overlooked that detail. The nightly version will indeed be locked until you explicitly run nix 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-src extension on line 38. Since the devShell references RUST_SRC_PATH on line 87, you'll need to uncomment that line:

extensions = [ "rust-src" ];

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-src is included so rust-analyzer works properly in the dev shell. 🙂


# 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/.
'';
}
);
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;
}
);
}