Skip to content

Commit

Permalink
chore(flake): enable nix flake support
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyliu16 committed Nov 21, 2024
1 parent 844b82e commit 01d07ef
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .#
82 changes: 82 additions & 0 deletions flake.lock

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

67 changes: 67 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
description = "Only Provide the support of qemu";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
(import rust-overlay)
(_: super: {
rust-toolchain =
let
rust = super.rust-bin;
in
if builtins.pathExists ./rust-toolchain.toml then
rust.fromRustupToolchainFile ./rust-toolchain.toml
else if builtins.pathExists ./rust-toolchain then
rust.fromRustupToolchainFile ./rust-toolchain
else
# rust.nightly.latest.default;
# The rust-toolchain when i make this file, which maybe change
(rust.nightly.latest.default.override {
extensions = [ "rust-src" "llvm-tools-preview" "rustfmt" "clippy" "cargo" ];
targets = [ "x86_64-unknown-linux-gnu" ];
});
})
];
pkgs = import nixpkgs {
inherit system overlays;
};
in {
devShells.default = with pkgs; mkShell {
buildInputs = [
# Require of repos
gnumake

# Require of rust-overlay
openssl
pkg-config
eza
fd

# Development Tools
ripgrep
zellij
fzf

rust-toolchain
];

shellHook = ''
alias ls=eza
alias find=fd
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
'';
};
}
);
}

0 comments on commit 01d07ef

Please sign in to comment.