Skip to content

fix flake.nix #170

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 9 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.DS_Store
.idea
.direnv/
/result
54 changes: 48 additions & 6 deletions flake.lock

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

80 changes: 57 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,72 @@
{
description = "Leet your code in command-line.";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.utils.url = "github:numtide/flake-utils";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, utils, ... }:
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};

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

outputs = {
self,
nixpkgs,
utils,
naersk,
rust-overlay,
...
}:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
overlays = [ (import rust-overlay) ];

pkgs = (import nixpkgs) {
inherit system overlays;
};

toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
clippy = toolchain;
};

nativeBuildInputs = with pkgs; [
pkg-config
];

darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];

buildInputs = with pkgs; [
openssl
dbus
sqlite
] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
] ++ darwinBuildInputs;


package = with pkgs; rustPlatform.buildRustPackage rec {
package = naersk'.buildPackage rec {
pname = "leetcode-cli";
version = "0.4.3";
src = fetchCrate {
inherit pname version;
sha256 = "sha256-y5zh93WPWSMDXqYangqrxav+sC0b0zpFIp6ZIew6KMo=";
};
cargoSha256 = "sha256-VktDiLsU+GOsa6ba9JJZGEPTavSKp+aSZm2dfhPEqMs=";
version = "git";

src = ./.;
doCheck = true; # run `cargo test` on build

inherit buildInputs nativeBuildInputs;

# a nightly compiler is required unless we use this cheat code.
RUSTC_BOOTSTRAP = 0;
buildNoDefaultFeatures = true;

# CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable";
CFG_RELEASE_CHANNEL = "stable";
buildFeatures = "git";

meta = with pkgs.lib; {
description = "Leet your code in command-line.";
Expand All @@ -44,9 +75,16 @@
maintainers = with maintainers; [ congee ];
mainProgram = "leetcode";
};

# Env vars
# a nightly compiler is required unless we use this cheat code.
RUSTC_BOOTSTRAP = 0;

# CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable";
CFG_RELEASE_CHANNEL = "stable";
};
in
{
{
defaultPackage = package;
overlay = final: prev: { leetcode-cli = package; };

Expand All @@ -55,11 +93,7 @@
inherit nativeBuildInputs;

buildInputs = buildInputs ++ [
rustc
cargo
rustfmt
clippy
rust-analyzer
toolchain
cargo-edit
cargo-bloat
cargo-audit
Expand Down
10 changes: 10 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[toolchain]
channel = "stable"
components = [
"rustc",
"cargo",
"rustfmt",
"clippy",
"rust-analyzer",
]
profile = "minimal"
Loading