diff --git a/.gitignore b/.gitignore index d97f62e..67e0e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .DS_Store .idea .direnv/ +/result diff --git a/flake.lock b/flake.lock index a62c24a..8d2d0df 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,32 @@ { "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1721727458, + "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", + "owner": "nix-community", + "repo": "naersk", + "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1703499205, - "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { @@ -18,10 +38,32 @@ }, "root": { "inputs": { + "naersk": "naersk", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "utils": "utils" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728700003, + "narHash": "sha256-Ox1pvEHxLK6lAdaKQW21Zvk65SPDag+cD8YA444R/og=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "fc1e58ebabe0cef4442eedea07556ff0c9eafcfe", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -42,11 +84,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index dccdd6c..936e777 100644 --- a/flake.nix +++ b/flake.nix @@ -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."; @@ -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; }; @@ -55,11 +93,7 @@ inherit nativeBuildInputs; buildInputs = buildInputs ++ [ - rustc - cargo - rustfmt - clippy - rust-analyzer + toolchain cargo-edit cargo-bloat cargo-audit diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..2a19081 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,10 @@ +[toolchain] +channel = "stable" +components = [ + "rustc", + "cargo", + "rustfmt", + "clippy", + "rust-analyzer", +] +profile = "minimal"
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: