From ae58eb80d2f6a0610ffdae9dd32b9fbc69125e6a Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Wed, 5 Jun 2019 21:44:49 +0200 Subject: [PATCH] nix-script: remove --- modules/module-list.nix | 1 - modules/programs/nix-script.nix | 47 ------ pkgs/nix-tools/nix-script.sh | 267 -------------------------------- 3 files changed, 315 deletions(-) delete mode 100644 modules/programs/nix-script.nix delete mode 100755 pkgs/nix-tools/nix-script.sh diff --git a/modules/module-list.nix b/modules/module-list.nix index dd23bc31..04ddd5b3 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -53,7 +53,6 @@ ./programs/man.nix ./programs/info ./programs/nix-index - ./programs/nix-script.nix ./programs/ssh ./programs/tmux.nix ./programs/vim.nix diff --git a/modules/programs/nix-script.nix b/modules/programs/nix-script.nix deleted file mode 100644 index d9701388..00000000 --- a/modules/programs/nix-script.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = config.programs.nix-script; - - nix-script = pkgs.substituteAll { - inherit (cfg) name; - src = ../../pkgs/nix-tools/nix-script.sh; - dir = "bin"; - isExecutable = true; - }; - -in - -{ - options = { - - programs.nix-script.enable = mkOption { - type = types.bool; - default = false; - description = '' - Whether to enable the nix script. - ''; - }; - - programs.nix-script.name = mkOption { - type = types.str; - default = "nix"; - description = '' - Name to use for the nix script. - ''; - }; - - }; - - config = mkIf cfg.enable { - - environment.systemPackages = - [ # Nix wrapper script - nix-script - ]; - - }; -} diff --git a/pkgs/nix-tools/nix-script.sh b/pkgs/nix-tools/nix-script.sh deleted file mode 100755 index c26ee5c5..00000000 --- a/pkgs/nix-tools/nix-script.sh +++ /dev/null @@ -1,267 +0,0 @@ -#! @shell@ -set -e -set -o pipefail - - -showUsage() { - echo "usage: nix [--version] [--help]" >&2 - echo " [] [-- ]" >&2 - echo "actions: {i | instantiate | e | eval | drv}" >&2 - echo " {b | build | out}" >&2 - echo " {s | shell | zsh}" >&2 - echo " {h | hash}" >&2 - echo " {store | q | query | r | realise | gc | add | delete}" >&2 - echo " {repl}" >&2 - echo " {-q | -i | -e | -u}" >&2 - exit ${@:-1} -} - -# Parse the command line. -origArgs=("$@") -extraNixFlags=() -srcArgs=() -pkgArgs=() -exprArg= -action= - -while [ "$#" -gt 0 ]; do - i="$1"; shift 1 - case "$i" in - -h|--help) - showUsage 0 - ;; - --version|v|version) - action='version' - ;; - i|instantiate) - action='instantiate' - ;; - e|eval) - action='instantiate' - extraNixFlags+=('--eval') - ;; - drv) - action='instantiate' - extraNixFlags+=('-Q' '--indirect' '--add-root' "$PWD/result.drv") - ;; - b|build) - action='build' - extraNixFlags+=('--no-out-link') - ;; - out) - action='build' - extraNixFlags+=('-Q') - ;; - s|shell) - action='shell' - extraNixFlags+=('-Q') - ;; - zsh) - action='shell' - extraNixFlags+=('--run' 'zsh') - ;; - h|hash) - action='hash' - extraNixFlags+=('--type' 'sha256') - ;; - store) - action='store' - ;; - q|query) - action='store' - extraNixFlags+=('--query') - ;; - r|realise) - action='store' - extraNixFlags+=('--realise') - ;; - gc) - action='store' - extraNixFlags+=('--gc' '--max-freed' '32G') - ;; - add) - action='store' - extraNixFlags+=('--add') - ;; - delete) - action='store' - extraNixFlags+=('--delete') - ;; - repl) - action='repl' - ;; - -q) - action='env' - extraNixFlags+=("$i") - ;; - -iA|-i|-e|-u) - action='env' - extraNixFlags+=("$i") - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - j="$1"; shift 1 - extraNixFlags+=("$i" "$j") - ;; - -j[0-9]*) - extraNixFlags+=("$i") - ;; - --add-root) - # nix-instantiate - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - j="$1"; shift 1 - extraNixFlags+=("$i" "$j") - ;; - --option|--arg|--argstr) - # nix-instantiate - if [ -z "$1" -o -z "$2" ]; then - echo "$0: \`$i' requires two arguments" - exit 1 - fi - j="$1"; shift 1 - k="$1"; shift 1 - extraNixFlags+=("$i" "$j" "$k") - ;; - --max-jobs|-j|--cores|--attr|-A|-I|--drv-link|--out-link|-o) - # nix-build - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - j="$1"; shift 1 - extraNixFlags+=("$i" "$j") - ;; - --command|--run|-i) - # nix-shell - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - j="$1"; shift 1 - extraNixFlags+=("$i" "$j") - ;; - --packages|-p) - # nix-shell - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - pkgArgs+=("$i") - while [ "$#" -gt 0 ]; do - case "$1" in - -*|*.nix|'<'*'>'|'./'*|'/'*|'http://'*|'https://'*) - break - ;; - *) - j="$1"; shift 1 - pkgArgs+=("$j") - ;; - esac - done - ;; - -r|--max-freed) - # nix-store - if [ -z "$1" ]; then - echo "$0: \`$i' requires an argument" - exit 1 - fi - j="$1"; shift 1 - extraNixFlags+=("$i" "$j") - ;; - --) - break - ;; - -*) - extraNixFlags+=("$i") - ;; - './.'|'<'*'>'|'http://'*|'https://'*) - pkgArgs+=("$i") - ;; - *'.drv') - drvArgs+=("$(readlink "$i")") - ;; - *'.nix'|'./'*|'/'*) - srcArgs+=("$i") - ;; - *) - echo "Unknown option: $i" >&2 - showUsage 129 - ;; - esac -done - -if [ -z "$action" ]; then action='repl'; fi - -if [ -z "$pkgArgs" ]; then - if [ -f ./default.nix ]; then pkgArgs+=('./.'); fi - pkgArgs+=('') -fi - -exprArg="$@" -for f in ${srcArgs[@]}; do - exprArg="${exprArg:+with }callPackage $f {}${exprArg:+; $exprArg}" -done -for p in ${pkgArgs[@]}; do - exprArg="${exprArg:+with }import $p {}${exprArg:+; $exprArg}" -done - -if [ "$action" = version ]; then - version=$(nix-env --version | awk '{print $3}') - echo "$0 (Nix) $version" - exit 0 -fi - -if [ "${traceExpr:-0}" -eq 1 ]; then - if [ "$#" -eq 0 -a -z "$srcArgs" ]; then - echo "nix-$action ${pkgArgs[@]} ${srcArgs[@]} ${drvArgs[@]} ${extraNixFlags[@]}" >&2 - else - echo "nix-$action ${extraNixFlags[@]} -E '$exprArg'" >&2 - fi -fi - -if [ "$action" = instantiate ]; then - if [ "$#" -eq 0 -a -z "$srcArgs" ]; then - exec nix-instantiate ${pkgArgs[@]} ${extraNixFlags[@]} - fi - exec nix-instantiate ${extraNixFlags[@]} -E "$exprArg" -fi - -if [ "$action" = build ]; then - if [ "$#" -eq 0 -a -z "$srcArgs" ]; then - exec nix-build ${pkgArgs[@]} ${extraNixFlags[@]} - fi - exec nix-build ${extraNixFlags[@]} -E "$exprArg" -fi - -if [ "$action" = shell ]; then - if [ -n "$drvArgs" ]; then - exec nix-shell ${drvArgs[@]} ${extraNixFlags[@]} - fi - if [ "$#" -eq 0 -a -z "$srcArgs" ]; then - exec nix-shell ${pkgArgs[@]} ${extraNixFlags[@]} - fi - exec nix-shell ${extraNixFlags[@]} -E "$exprArg" -fi - -if [ "$action" = hash ]; then - exec nix-hash ${srcArgs[@]} ${extraNixFlags[@]} -fi - -if [ "$action" = store ]; then - if [ -n "$drvArgs" ]; then - exec nix-shell ${drvArgs[@]} ${extraNixFlags[@]} - fi - exec nix-store ${srcArgs[@]} ${extraNixFlags[@]} -fi - -if [ "$action" = env ]; then - exec nix-env -f '' ${extraNixFlags[@]} -fi - -if [ "$action" = repl ]; then - exec nix-repl '' ${pkgArgs[@]} ${srcArgs[@]} -fi