Created
June 10, 2020 17:21
-
-
Save patrl/6c5c7c755f1be1a37c43b3376d848785 to your computer and use it in GitHub Desktop.
Basic nix rust setup
This file contains 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
#!/usr/bin/env bash | |
set -Eeuxo pipefail | |
type git >/dev/null 2>&1 || { echo >&2 "I require git but it's not installed. Aborting."; exit 1; } | |
type nix >/dev/null 2>&1 || { echo >&2 "I require nix but it's not installed. Aborting."; exit 1; } | |
type niv >/dev/null 2>&1 || { echo >&2 "I require niv but it's not installed. Aborting."; exit 1; } | |
type direnv >/dev/null 2>&1 || { echo >&2 "I require direnv but it's not installed. Aborting."; exit 1; } | |
type lorri >/dev/null 2>&1 || { echo >&2 "I require lorri but it's not installed. Aborting."; exit 1; } | |
git init # initialize git repository | |
git ignore rust > .gitignore # create gitignore file from haskell template | |
export GITHUB_TOKEN=${gpg2 -q --for-your-eyes-only --no-tty -d $PASSWORD_STORE_DIR/services/github-token.gpg} | |
niv init # initialize niv | |
niv update nixpkgs -b nixpkgs-unstable | |
niv add mozilla/nixpkgs-mozilla | |
export author="Patrick D. Elliott" | |
export email="patrick.d.elliott@gmail.com" | |
# rust.nix | |
cat <<EOF > ./nix/rust.nix | |
# nix/rust.nix | |
{ sources ? import ./sources.nix }: | |
let | |
pkgs = | |
import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; }; | |
channel = "nightly"; | |
date = "2020-06-10"; | |
targets = [ ]; | |
extensions = [ | |
"clippy" | |
"rls" | |
"rust-docs" | |
"rust-analysis" | |
]; | |
chan = pkgs.rustChannelOfTargets channel date targets; | |
in chan | |
EOF | |
cat << EOF > ./shell.nix | |
# shell.nix | |
let | |
sources = import ./nix/sources.nix; | |
rust = import ./nix/rust.nix { inherit sources; }; | |
pkgs = import sources.nixpkgs { }; | |
in | |
pkgs.mkShell { | |
buildInputs = [ | |
rust | |
]; | |
} | |
EOF | |
# Create direnv file | |
cat << 'EOF' > .envrc | |
eval "\$(lorri direnv)" | |
EOF | |
cargo init | |
git add . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment