From 63f107e5d11ada8ba4c1c2436ff9c628e675453c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 3 Apr 2021 12:26:43 +0530 Subject: [PATCH] Use Nushell from Nixpkgs unstable --- .github/workflows/ci.yml | 5 ---- Makefile | 18 +++++++------- contrib/ranger.py | 3 ++- shell.nix | 51 ++++++++++++++++++++-------------------- src/shell.rs | 5 ++++ 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40695f2..389d06b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,11 +19,6 @@ jobs: with: crate: cargo-audit version: latest - - uses: actions-rs/install@v0.1 - if: ${{ matrix.os != 'windows-latest' }} - with: - crate: nu - version: latest - uses: cachix/install-nix-action@v12 if: ${{ matrix.os != 'windows-latest' }} with: diff --git a/Makefile b/Makefile index f0cd743..ff63650 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif ifeq ($(NIX), true) build: - nix-shell --run 'cargo build $(build_flags) $(ci_color_always)' + nix-shell --pure --run 'cargo build $(build_flags) $(ci_color_always)' else build: cargo build $(build_flags) $(ci_color_always) @@ -24,7 +24,7 @@ endif ifeq ($(NIX), true) clean: - nix-shell --run 'cargo clean $(ci_color_always)' + nix-shell --pure --run 'cargo clean $(ci_color_always)' else clean: cargo clean $(ci_color_always) @@ -32,7 +32,7 @@ endif ifeq ($(NIX), true) install: - nix-shell --run 'cargo install --path=. $(ci_color_always)' + nix-shell --pure --run 'cargo install --path=. $(ci_color_always)' else install: cargo install --path=. $(ci_color_always) @@ -40,11 +40,11 @@ endif ifeq ($(NIX), true) test: - nix-shell --run 'cargo fmt -- --check --files-with-diff $(ci_color_always)' - nix-shell --run 'cargo check --all-features $(build_flags) $(ci_color_always)' - nix-shell --run 'cargo clippy --all-features $(build_flags) $(ci_color_always) -- --deny warnings --deny clippy::all' - nix-shell --run 'cargo test --all-features --no-fail-fast $(build_flags) $(ci_color_always)' - nix-shell --run 'cargo audit --deny warnings $(ci_color_always) --ignore=RUSTSEC-2020-0095' + nix-shell --pure --run 'cargo fmt -- --check --files-with-diff $(ci_color_always)' + nix-shell --pure --run 'cargo check --all-features $(build_flags) $(ci_color_always)' + nix-shell --pure --run 'cargo clippy --all-features $(build_flags) $(ci_color_always) -- --deny warnings --deny clippy::all' + nix-shell --pure --run 'cargo test --all-features --no-fail-fast $(build_flags) $(ci_color_always)' + nix-shell --pure --run 'cargo audit --deny warnings $(ci_color_always) --ignore=RUSTSEC-2020-0095' else test: cargo fmt -- --check --files-with-diff $(ci_color_always) @@ -56,7 +56,7 @@ endif ifeq ($(NIX), true) uninstall: - nix-shell --run 'cargo uninstall $(ci_color_always)' + nix-shell --pure --run 'cargo uninstall $(ci_color_always)' else uninstall: cargo uninstall $(ci_color_always) diff --git a/contrib/ranger.py b/contrib/ranger.py index b757036..e091b30 100644 --- a/contrib/ranger.py +++ b/contrib/ranger.py @@ -1,8 +1,9 @@ import os.path +import subprocess + import ranger.api import ranger.core.fm import ranger.ext.signals -import subprocess hook_init_old = ranger.api.hook_init diff --git a/shell.nix b/shell.nix index 8d53eb3..dab73c3 100644 --- a/shell.nix +++ b/shell.nix @@ -1,29 +1,30 @@ -{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz") {} }: - let - python-pkgs = pkgs.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]); + pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz") {}; + pkgsMaster = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/470e4a9bbc98b171a7e733dfc9e62531f7b9ceca.tar.gz") {}; + pkgsPython = pkgs.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]); in -pkgs.mkShell { - name = "env"; - buildInputs = [ - pkgs.bash - pkgs.cargo - pkgs.cargo-audit - pkgs.dash - pkgs.fish - pkgs.fzf - pkgs.git - # pkgs.nushell # FIXME: too outdated - pkgs.powershell - pkgs.rustc - pkgs.shellcheck - pkgs.shfmt - pkgs.xonsh - pkgs.zsh - python-pkgs - ]; +pkgs.mkShell + { + name = "env"; + buildInputs = [ + pkgsMaster.nushell + pkgsPython + pkgs.bash + pkgs.cargo + pkgs.cargo-audit + pkgs.dash + pkgs.fish + pkgs.fzf + pkgs.git + pkgs.powershell + pkgs.rustc + pkgs.rustfmt + pkgs.shellcheck + pkgs.shfmt + pkgs.xonsh + pkgs.zsh + ]; - # Set Environment Variables - RUST_BACKTRACE = 1; -} + RUST_BACKTRACE = 1; + } diff --git a/src/shell.rs b/src/shell.rs index d012bbe..19a544e 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -157,7 +157,12 @@ mod tests { fn nushell_nushell_#i() { let opts = dbg!(&opts()[i]); let source = Nushell(opts).render().unwrap(); + + let tempdir = tempfile::tempdir().unwrap(); + let tempdir = tempdir.path().to_str().unwrap(); + let assert = Command::new("nu") + .env("HOME", tempdir) .args(&["--commands", &source]) .assert() .success()