From 96c5e5929a862c52449a5ae8e9453bac0ed77b1d Mon Sep 17 00:00:00 2001 From: NormalFall Date: Thu, 16 May 2024 18:09:53 -0400 Subject: [PATCH] Add nix-shell --- .gitignore | 1 + .nix-shell-history-hook.sh | 10 +++ flake.lock | 130 +++++++++++++++++++++++++++++++++++++ flake.nix | 33 ++++++++++ 4 files changed, 174 insertions(+) create mode 100755 .nix-shell-history-hook.sh create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..ce68215 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.nix-shell-history \ No newline at end of file diff --git a/.nix-shell-history-hook.sh b/.nix-shell-history-hook.sh new file mode 100755 index 0000000..f572cb1 --- /dev/null +++ b/.nix-shell-history-hook.sh @@ -0,0 +1,10 @@ +# ~/.nix-shell-history-hook.sh +export HISTFILE=.nix-shell-history # Set a custom history file for nix-shell +export HISTSIZE=10000 # Set the number of commands to remember +export HISTFILESIZE=20000 # Set the maximum size of the history file + +# Ensure history is appended to the history file +shopt -s histappend + +# Promptly write history after each command +PROMPT_COMMAND='history -a' diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7852ff7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715787315, + "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1715825775, + "narHash": "sha256-7np2/EEr5Xm8IuKWQ43q8AA1Lb6Us2BW6rYMxGrInIg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "55f468b3d49c5d3321e85f2f9b1158476a2a90fb", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9f6e99c --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "test"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + probe-rs + (rust-bin.fromRustupToolchainFile ./rust-toolchain.toml) + ]; + + shellHook = '' + source .nix-shell-history.sh + alias flash="cargo flash --chip RP2040" + ''; + }; + } + ); +} \ No newline at end of file