diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2023-11-06 14:33:18 +0100 |
---|---|---|
committer | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2023-11-06 14:33:18 +0100 |
commit | 32da89a1a1dfb314f614213cdd0f574baf873156 (patch) | |
tree | 312e552d4df4f142cf08fba1c5f3d45f61e82575 /pkgs/os-specific/linux | |
parent | 2ee2d62dce74178c62736fe4a8c784ef40476465 (diff) | |
parent | 250c07f960eaefd781df539ee0d877b13da17b97 (diff) | |
download | nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar.gz nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar.bz2 nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar.lz nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar.xz nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.tar.zst nixpkgs-32da89a1a1dfb314f614213cdd0f574baf873156.zip |
Merge branch 'master' into staging-next
Diffstat (limited to 'pkgs/os-specific/linux')
-rw-r--r-- | pkgs/os-specific/linux/isgx/default.nix | 4 | ||||
-rw-r--r-- | pkgs/os-specific/linux/nixos-rebuild/_nixos-rebuild | 165 | ||||
-rw-r--r-- | pkgs/os-specific/linux/nixos-rebuild/default.nix | 3 | ||||
-rwxr-xr-x | pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh | 4 |
4 files changed, 172 insertions, 4 deletions
diff --git a/pkgs/os-specific/linux/isgx/default.nix b/pkgs/os-specific/linux/isgx/default.nix index 6e97532ee5d..c49a0a7b913 100644 --- a/pkgs/os-specific/linux/isgx/default.nix +++ b/pkgs/os-specific/linux/isgx/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchFromGitHub, kernel, kernelAtLeast }: +{ stdenv, lib, fetchFromGitHub, kernel }: stdenv.mkDerivation rec { name = "isgx-${version}-${kernel.version}"; @@ -39,7 +39,7 @@ stdenv.mkDerivation rec { ''; homepage = "https://github.com/intel/linux-sgx-driver"; license = with licenses; [ bsd3 /* OR */ gpl2Only ]; - maintainers = with maintainers; [ oxalica ]; + maintainers = [ ]; platforms = [ "x86_64-linux" ]; }; } diff --git a/pkgs/os-specific/linux/nixos-rebuild/_nixos-rebuild b/pkgs/os-specific/linux/nixos-rebuild/_nixos-rebuild new file mode 100644 index 00000000000..84e8d223bd8 --- /dev/null +++ b/pkgs/os-specific/linux/nixos-rebuild/_nixos-rebuild @@ -0,0 +1,165 @@ +#!/usr/bin/env bash + +# We're faking a `nix build` command-line to re-use Nix's own completion +# for the few options passed through to Nix. +_nixos-rebuild_pretend-nix() { + COMP_LINE="nix build ${COMP_LINE}" + # number of prepended chars + (( COMP_POINT = COMP_POINT + 10)) + + COMP_WORDS=( + nix build + "${COMP_WORDS[@]}" + ) + # Add the amount of prepended words + (( COMP_CWORD = COMP_CWORD + 2)) + _complete_nix "nix" +} + +_nixos-rebuild() { + local curr="$2" + local prev="$3" + local subcommandGiven=0 + local word + local subcommand + + __load_completion nix + + # Arrays are re-ordered by the completion, so it's fine to sort them in logical chunks + local all_args=( + --verbose -v + + # nixos-rebuild options + --fast + --no-build-nix + --profile-name -p # name + --rollback + --specialisation -c # name + --use-remote-sudo + --build-host # host + --target-host # host + # Used with list-generations + --json + + # generation switching options + --install-bootloader + + # nix-channel options + --upgrade + --upgrade-all + + # flakes options + --commit-lock-file + --flake # flake-uri + --override-input # input-name flake-uri + --recreate-lock-file + --update-input + --no-flake + --no-registries + --no-update-lock-file + --no-write-lock-file + + # Nix-copy options + --use-substitutes --substitute-on-destination -s + + # Nix options + --option + --impure + --builders # builder-spec + --show-trace + --keep-failed -K + --keep-going -k + --max-jobs -j # number + --log-format # format + -I # NIX_PATH + ) + + local all_subcommands=( + boot + build + build-vm + build-vm-with-bootloader + dry-activate + dry-build + edit + list-generations + switch + test + ) + + # Suggest arguments that can be consumed under some conditions only + for word in "${COMP_WORDS[@]}"; do + for subcommand in "${all_subcommands[@]}"; do + if [[ "$word" == "$subcommand" ]]; then + subcommandGiven=1 + fi + done + done + + # Fake out a way to complete the second arg to some options + case "${COMP_WORDS[COMP_CWORD-2]}" in + "--override-input") + prev="--override-input_2" + ;; + "--option") + prev="--option_2" + ;; + esac + + case "$prev" in + --max-jobs|-j) + COMPREPLY=( ) + ;; + + --profile-name|-p) + if [[ "$curr" == "" ]]; then + COMPREPLY=( /nix/var/nix/profiles/* ) + else + COMPREPLY=( "$curr"* ) + fi + ;; + + --build-host|--target-host|-t|-h) + _known_hosts_real "$curr" + ;; + + --specialisation|-c) + COMPREPLY=() + ;; + + -I) + _nixos-rebuild_pretend-nix + ;; + --builders) + _nixos-rebuild_pretend-nix + ;; + --flake) + _nixos-rebuild_pretend-nix + ;; + --override-input) + _nixos-rebuild_pretend-nix + ;; + --override-input_2) + _nixos-rebuild_pretend-nix + ;; + --log-format) + _nixos-rebuild_pretend-nix + ;; + --option) + _nixos-rebuild_pretend-nix + ;; + --option_2) + _nixos-rebuild_pretend-nix + ;; + + *) + if [[ "$curr" == -* ]] || (( subcommandGiven )); then + COMPREPLY=( $(compgen -W "${all_args[*]}" -- "$2") ) + else + COMPREPLY=( $(compgen -W "${all_subcommands[*]}" -- "$2") ) + fi + ;; + esac +} + +complete -F _nixos-rebuild nixos-rebuild diff --git a/pkgs/os-specific/linux/nixos-rebuild/default.nix b/pkgs/os-specific/linux/nixos-rebuild/default.nix index 4ff0c8c3291..6c150b1b8cd 100644 --- a/pkgs/os-specific/linux/nixos-rebuild/default.nix +++ b/pkgs/os-specific/linux/nixos-rebuild/default.nix @@ -28,6 +28,9 @@ substituteAll { ]; postInstall = '' installManPage ${./nixos-rebuild.8} + + installShellCompletion \ + --bash ${./_nixos-rebuild} ''; # run some a simple installer tests to make sure nixos-rebuild still works for them diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh index 9e75db6d27b..dddae8da206 100755 --- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh +++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh @@ -117,11 +117,11 @@ while [ "$#" -gt 0 ]; do specialisation="$1" shift 1 ;; - --build-host|h) + --build-host) buildHost="$1" shift 1 ;; - --target-host|t) + --target-host) targetHost="$1" shift 1 ;; |