From 76893ae125b522174edf344e5b2f7821a7502348 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Fri, 2 Feb 2024 13:15:31 -0800 Subject: [PATCH] chore: remove unused overlays --- ci/fmt.nix | 1 + lib.nix | 37 ++ modules/nixos/access.nix | 1 + modules/nixos/kanidm.nix | 4 +- modules/nixos/network.nix | 3 +- nixos/access/proxmox.nix | 4 +- nixos/base/nixpkgs.nix | 1 - outputs.nix | 6 +- overlays/default.nix | 3 - overlays/lib/default.nix | 7 - overlays/lib/node-import.nix | 21 - overlays/lib/overlay.nix | 16 - overlays/local/default.nix | 35 -- overlays/local/disk-mapper.nix | 46 -- overlays/local/hedgedoc-cli.nix | 27 -- overlays/local/irlsite.nix | 15 - overlays/local/lib.nix | 27 -- overlays/local/oomox.nix | 64 --- overlays/local/pigpio.nix | 60 --- overlays/local/requests-oauth.nix | 32 -- overlays/local/sway-scrot/default.nix | 5 - overlays/local/sway-scrot/sway-scrot.sh | 253 ---------- overlays/local/vm-pinning.nix | 88 ---- overlays/local/vm.nix | 92 ---- overlays/local/waybar-gpg/default.nix | 5 - overlays/local/waybar-gpg/kat-gpg-status.sh | 12 - overlays/local/waybar-konawall/default.nix | 22 - overlays/local/waybar-konawall/status.sh | 13 - overlays/local/waybar-konawall/toggle.sh | 12 - overlays/local/wezterm/default.nix | 127 ----- overlays/local/withings-api.nix | 41 -- overlays/local/xbackbone.nix | 35 -- overlays/nur/default.nix | 6 - ...-option-for-imports_granularity-4669.patch | 446 ------------------ overlays/rustfmt/default.nix | 9 - {overlays/local => packages}/snakeoil.nix | 0 tree.nix | 1 + 37 files changed, 47 insertions(+), 1530 deletions(-) create mode 100644 lib.nix delete mode 100644 overlays/lib/default.nix delete mode 100644 overlays/lib/node-import.nix delete mode 100644 overlays/lib/overlay.nix delete mode 100644 overlays/local/default.nix delete mode 100644 overlays/local/disk-mapper.nix delete mode 100644 overlays/local/hedgedoc-cli.nix delete mode 100644 overlays/local/irlsite.nix delete mode 100644 overlays/local/lib.nix delete mode 100644 overlays/local/oomox.nix delete mode 100644 overlays/local/pigpio.nix delete mode 100644 overlays/local/requests-oauth.nix delete mode 100644 overlays/local/sway-scrot/default.nix delete mode 100755 overlays/local/sway-scrot/sway-scrot.sh delete mode 100644 overlays/local/vm-pinning.nix delete mode 100644 overlays/local/vm.nix delete mode 100644 overlays/local/waybar-gpg/default.nix delete mode 100644 overlays/local/waybar-gpg/kat-gpg-status.sh delete mode 100644 overlays/local/waybar-konawall/default.nix delete mode 100644 overlays/local/waybar-konawall/status.sh delete mode 100644 overlays/local/waybar-konawall/toggle.sh delete mode 100644 overlays/local/wezterm/default.nix delete mode 100644 overlays/local/withings-api.nix delete mode 100644 overlays/local/xbackbone.nix delete mode 100644 overlays/nur/default.nix delete mode 100644 overlays/rustfmt/Implement-One-option-for-imports_granularity-4669.patch delete mode 100644 overlays/rustfmt/default.nix rename {overlays/local => packages}/snakeoil.nix (100%) diff --git a/ci/fmt.nix b/ci/fmt.nix index 2d30d861..fe1abddc 100644 --- a/ci/fmt.nix +++ b/ci/fmt.nix @@ -18,6 +18,7 @@ "overlays/default.nix" "devShells.nix" "shell.nix" + "lib.nix" "outputs.nix" "tree.nix" ]; diff --git a/lib.nix b/lib.nix new file mode 100644 index 00000000..be6507c0 --- /dev/null +++ b/lib.nix @@ -0,0 +1,37 @@ +{ + inputs, + tree, +}: let + nixlib = inputs.nixpkgs.lib; + inherit (nixlib.strings) splitString toLower; + inherit (nixlib.lists) imap0 elemAt; + inherit (nixlib.attrsets) listToAttrs nameValuePair; + inherit (nixlib.strings) substring fixedWidthString; + inherit (nixlib.trivial) flip toHexString bitOr; + + toHexStringLower = v: toLower (toHexString v); + + hexCharToInt = let + hexChars = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f"]; + pairs = imap0 (flip nameValuePair) hexChars; + idx = listToAttrs pairs; + in + char: idx.${char}; + + eui64 = mac: let + parts = map toLower (splitString ":" mac); + part = elemAt parts; + part0 = part: let + nibble1' = hexCharToInt (substring 1 1 part); + nibble1 = bitOr 2 nibble1'; + nibble0 = substring 0 1 part; + in + nibble0 + (fixedWidthString 1 "0" (toHexStringLower nibble1)); + in "${part0 (part 0)}${part 1}:${part 2}ff:fe${part 3}:${part 4}${part 5}"; +in { + inherit tree nixlib; + std = import ./std.nix {inherit inputs;}; + lib = { + inherit eui64 toHexStringLower hexCharToInt; + }; +} diff --git a/modules/nixos/access.nix b/modules/nixos/access.nix index 816da2d5..a1116458 100644 --- a/modules/nixos/access.nix +++ b/modules/nixos/access.nix @@ -218,4 +218,5 @@ in { then config else systemForOrNull hostName; }; + config.lib.access.mkSnakeOil = pkgs.callPackage ../../packages/snakeoil.nix { }; } diff --git a/modules/nixos/kanidm.nix b/modules/nixos/kanidm.nix index 55485357..c86506f8 100644 --- a/modules/nixos/kanidm.nix +++ b/modules/nixos/kanidm.nix @@ -1,11 +1,11 @@ { lib, - pkgs, config, ... }: let inherit (lib) mkIf mkMerge mkBefore mkDefault mkOptionDefault mkEnableOption mkOption; inherit (lib.strings) splitString concatMapStringsSep; + inherit (config.lib.access) mkSnakeOil; cfg = config.services.kanidm; in { options.services.kanidm = with lib.types; { @@ -62,7 +62,7 @@ in { server.unencrypted = { domain = mkBefore [ cfg.server.frontend.domain ]; package = let - cert = pkgs.mkSnakeOil { + cert = mkSnakeOil { name = "kanidm-cert"; inherit (cfg.server.unencrypted) domain; }; diff --git a/modules/nixos/network.nix b/modules/nixos/network.nix index 4c1b9f59..e52d7b13 100644 --- a/modules/nixos/network.nix +++ b/modules/nixos/network.nix @@ -1,11 +1,12 @@ { + inputs, config, lib, ... }: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.modules) mkIf mkMerge mkOptionDefault; - inherit (lib.trivial) eui64; + inherit (inputs.self.lib.lib) eui64; inherit (config) networking services; networkModule = { config, ... }: { options = with lib.types; { diff --git a/nixos/access/proxmox.nix b/nixos/access/proxmox.nix index 4719eb34..889d83e4 100644 --- a/nixos/access/proxmox.nix +++ b/nixos/access/proxmox.nix @@ -1,18 +1,18 @@ { config, lib, - pkgs, ... }: let inherit (lib.options) mkOption; inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.strings) escapeRegex; inherit (lib.lists) singleton optional; + inherit (config.lib.access) mkSnakeOil; inherit (config.services) nginx tailscale; inherit (nginx) virtualHosts; access = config.services.nginx.access.proxmox; proxyPass = "https://reisen.local.${config.networking.domain}:8006/"; - unencrypted = pkgs.mkSnakeOil { + unencrypted = mkSnakeOil { name = "prox-local-cert"; domain = singleton "prox.local.${config.networking.domain}" ++ optional tailscale.enable "prox.tail.${config.networking.domain}"; diff --git a/nixos/base/nixpkgs.nix b/nixos/base/nixpkgs.nix index 20644316..eab9b4bb 100644 --- a/nixos/base/nixpkgs.nix +++ b/nixos/base/nixpkgs.nix @@ -4,7 +4,6 @@ }: { nixpkgs = { overlays = [ - (import ../../overlays/local) inputs.arcexprs.overlays.default ]; config = { diff --git a/outputs.nix b/outputs.nix index 18ae1bbd..7bcfbc21 100644 --- a/outputs.nix +++ b/outputs.nix @@ -50,9 +50,5 @@ in { inherit (outputs) devShells legacyPackages packages checks; inherit (systems) deploy nixosConfigurations; - lib = { - std = import ./std.nix {inherit inputs;}; - nixlib = inputs.nixpkgs.lib; - inherit tree; - }; + lib = import ./lib.nix {inherit tree inputs;}; } diff --git a/overlays/default.nix b/overlays/default.nix index 6b987e90..81f7925e 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -3,9 +3,6 @@ inherit system; overlays = [ - (import ./nur {inherit inputs;}) - (import ./local) - (import ./lib) inputs.deploy-rs.overlay inputs.arcexprs.overlays.default (final: prev: { diff --git a/overlays/lib/default.nix b/overlays/lib/default.nix deleted file mode 100644 index e25d8a45..00000000 --- a/overlays/lib/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -self: super: { - lib = super.lib.extend (self: super: import ./overlay.nix { - inherit super; - lib = self; - isOverlayLib = true; - }); -} diff --git a/overlays/lib/node-import.nix b/overlays/lib/node-import.nix deleted file mode 100644 index cf491d09..00000000 --- a/overlays/lib/node-import.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ lib }: { nixosImports, homeImports, users, hostName, profiles }: with lib; - -let - importLists = { - nixos = nixosImports; - home = homeImports; - }; - replacedLists = mapAttrs - (_: fileList: - map (builtins.replaceStrings [ "HN" ] [ "${hostName}" ]) fileList - ) - importLists; - homeScaffold = user: { - home-manager.users.${user} = { - imports = filter builtins.pathExists replacedLists.home; - }; - }; - scaffoldedUsers = map homeScaffold users; - baseProfile = singleton profiles.base; -in -filter builtins.pathExists replacedLists.nixos ++ baseProfile ++ scaffoldedUsers diff --git a/overlays/lib/overlay.nix b/overlays/lib/overlay.nix deleted file mode 100644 index 030b7b7d..00000000 --- a/overlays/lib/overlay.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs ? import { } -, lib ? pkgs.lib - # for internal use... -, super ? if !isOverlayLib then lib else { } -, self ? if isOverlayLib then lib else { } -, before ? if !isOverlayLib then lib else { } -, isOverlayLib ? false -}@args: -let - lib = before // katlib // self; - katlib = with before; with katlib; with self; - { - nodeImport = import ./node-import.nix { inherit lib; }; - }; -in -katlib diff --git a/overlays/local/default.nix b/overlays/local/default.nix deleted file mode 100644 index dc66dde3..00000000 --- a/overlays/local/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -final: prev: { - lib = prev.lib.extend (import ./lib.nix); - requests-oauth = final.python3Packages.callPackage ./requests-oauth.nix {}; - withings-api = final.python3Packages.callPackage ./withings-api.nix {}; - irlsite = final.callPackage ./irlsite.nix {}; - vips = prev.vips.override {libjxl = null;}; - sway-scrot = final.callPackage ./sway-scrot {}; - vfio-vm = final.callPackage ./vm.nix {}; - vfio-vm-pinning = final.callPackage ./vm-pinning.nix {}; - vfio-disk-mapper = final.callPackage ./disk-mapper.nix {}; - xbackbone = final.callPackage ./xbackbone.nix {}; - waybar-gpg = final.callPackage ./waybar-gpg {}; - waybar-konawall = final.callPackage ./waybar-konawall {}; - hedgedoc-cli = final.callPackage ./hedgedoc-cli.nix {}; - gensokyoZone = final.callPackage ./gensokyoZone {}; - kittywitCh = final.callPackage ./gensokyoZone/kittywitch.nix {}; - oomox = final.callPackage ./oomox.nix {}; - wezterm = final.callPackage ./wezterm { - inherit (final.darwin.apple_sdk.frameworks) Cocoa CoreGraphics Foundation UserNotifications; - }; - mkSnakeOil = final.callPackage ./snakeoil.nix { }; - terraform-providers = - prev.terraform-providers - // { - tailscale = final.terraform-providers.mkProvider rec { - owner = "tailscale"; - provider-source-address = "registry.terraform.io/${owner}/${owner}"; - repo = "terraform-provider-tailscale"; - rev = "v${version}"; - hash = "sha256-/qC8TOtoVoBTWeAFpt2TYE8tlYBCCcn/mzVQ/DN51YQ="; - vendorHash = "sha256-8EIxqKkVO706oejlvN79K8aEZAF5H2vZRdr5vbQa0l4="; - version = "0.13.5"; - }; - }; -} diff --git a/overlays/local/disk-mapper.nix b/overlays/local/disk-mapper.nix deleted file mode 100644 index 3a7318bc..00000000 --- a/overlays/local/disk-mapper.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ pkgs, writeShellScriptBin }: - -writeShellScriptBin "disk-mapper-part" '' - set -x - DISK=$1 - DM_NAME=$(basename $DISK) - if [[ ! -e /dev/mapper/$DM_NAME ]]; then - DISK_ID=''${2-$(printf %s "$DM_NAME" | sha256sum)} - DISK_TYPE=7 # NTFS - MBR_FILE=$(mktemp -t vm-$DM_NAME-XXXXXXXX.mbr) - BLOCK=$(basename $(readlink $DISK)) - BLOCK_START=$(cat /sys/class/block/$BLOCK/start) - BLOCK_SIZE=$(cat /sys/class/block/$BLOCK/size) - DISK_SIZE=$(((BLOCK_SIZE + 2048 + 2047) / 2048 * 2048)) - dd if=/dev/zero of=$MBR_FILE bs=512 count=2048 status=none - - LDEV=$(losetup --show -f $MBR_FILE) - END_GUARD=$((DISK_SIZE - 2048 - BLOCK_SIZE)) - if [[ $END_GUARD -ne 0 ]]; then - END_GUARD="$((BLOCK_SIZE + 2048)) $END_GUARD zero" - else - END_GUARD= - fi - dmsetup create $DM_NAME < /dev/null 2>&1; then - RESULT="OK" - else - RESULT="NOT FOUND" - fi - echo " $COMMAND: $RESULT" -} - -takeScreenshot() { - FILE=$1 - GEOM=$2 - OUTPUT=$3 - if [ "$SWAY" = "yes" ]; then - if [ ! -z "$OUTPUT" ]; then - grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim" - elif [ -z "$GEOM" ]; then - grim "$FILE" || die "Unable to invoke grim" - else - grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" - fi - else - if [ "$GEOM" = "maim-cur" ]; then - maim -i $(xdotool getactivewindow) "$FILE" - elif [ "$GEOM" = "maim-s" ]; then - maim -s "$FILE" - elif [ "$GEOM" = "maim-out" ]; then - maim -g "$OUTPUT" "$FILE" - elif [ "$GEOM" = "maim-screen" ]; then - maim "$FILE" - fi - fi -} - -if [ "$ACTION" = "check" ] ; then - echo "Checking if required tools are installed. If something is missing, install it to your system and make it available in PATH..." - check grim - check slurp - check $MSGER - check $COPIER - check jq - check notify-send - exit -elif [ "$SUBJECT" = "area" ] ; then - GEOM=$(slurp -d) - # Check if user exited slurp without selecting the area - if [ -z "$GEOM" ]; then - exit - fi - WHAT="Area" -elif [ "$SUBJECT" = "active" ] ; then - if [ "$SWAY" = "yes" ]; then - FOCUSED=$($MSGER -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') - GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') - APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') - WHAT="$APP_ID window" - else - GEOM="maim-cur" - fi -elif [ "$SUBJECT" = "screen" ] ; then - if [ "$SWAY" = "yes" ]; then - GEOM="" - WHAT="Screen" - else - GEOM="maim-screen"; - fi -elif [ "$SUBJECT" = "output" ] ; then - if [ "$SWAY" = "yes" ]; then - GEOM="" - OUTPUT=$($MSGER -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') - WHAT="$OUTPUT" - else -MONITORS=$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*') -# Get the location of the mouse -XMOUSE=$(xdotool getmouselocation | awk -F "[: ]" '{print $2}') -YMOUSE=$(xdotool getmouselocation | awk -F "[: ]" '{print $4}') - -for mon in ${MONITORS}; do - # Parse the geometry of the monitor - MONW=$(echo ${mon} | awk -F "[x+]" '{print $1}') - MONH=$(echo ${mon} | awk -F "[x+]" '{print $2}') - MONX=$(echo ${mon} | awk -F "[x+]" '{print $3}') - MONY=$(echo ${mon} | awk -F "[x+]" '{print $4}') - # Use a simple collision check - if (( ${XMOUSE} >= ${MONX} )); then - if (( ${XMOUSE} <= ${MONX}+${MONW} )); then - if (( ${YMOUSE} >= ${MONY} )); then - if (( ${YMOUSE} <= ${MONY}+${MONH} )); then - # We have found our monitor! - GEOM="maim-out" - OUTPUT="${MONW}x${MONH}+${MONX}+${MONY}" - break - fi - fi - fi - fi -done - fi -elif [ "$SUBJECT" = "window" ] ; then - if [ "$SWAY" = "yes" ]; then - GEOM=$($MSGER -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) - else - GEOM="maim-s" - fi - # Check if user exited slurp without selecting the area - if [ -z "$GEOM" ]; then - exit - fi - WHAT="Window" -else - die "Unknown subject to take a screen shot from" "$SUBJECT" -fi - -if [ "$ACTION" = "copy" ] ; then - takeScreenshot - "$GEOM" "$OUTPUT" | $COPIERIMG || die "Clipboard error" - echo $FILE - notifyOk "$WHAT copied to buffer" -elif [ "$ACTION" = "copys" ]; then - if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then - TITLE="Screenshot of $SUBJECT" - MESSAGE=$(basename "$FILE") - notifyOk "$MESSAGE" "$TITLE" - echo $FILE - cat "$FILE" | $COPIER || die "Clipboard error" - else - notifyError "Error taking screenshot with grim" - fi -elif [ "$ACTION" = "upload" ]; then - if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then - RESPONSE="$(curl -s -F "token=$TOKEN" -F "upload=@\"$FILE\"" https://files.kittywit.ch/upload)"; - if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK" ]]; then - URL="$(echo "${RESPONSE}" | jq -r '.url')/raw"; - echo "${URL}" | $COPIER; - echo "${URL}"; - notify-send "Upload completed!" "${URL}"; - exit 0; - else - MESSAGE="$(echo "${RESPONSE}" | jq -r '.message')"; - if [ $? -ne 0 ]; then - echo "Unexpected response:"; - echo "${RESPONSE}"; - exit 1; - fi - if [ "${DESKTOP_SESSION}" != "" ]; then - notify-send "Error!" "${MESSAGE}"; - else - echo "Error! ${MESSAGE}"; - fi - exit 1; - fi - else - notifyError "Error taking screenshot with grim" - fi -else - if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then - TITLE="Screenshot of $SUBJECT" - MESSAGE=$(basename "$FILE") - notifyOk "$MESSAGE" "$TITLE" - echo $FILE - else - notifyError "Error taking screenshot with grim" - fi -fi diff --git a/overlays/local/vm-pinning.nix b/overlays/local/vm-pinning.nix deleted file mode 100644 index b2340857..00000000 --- a/overlays/local/vm-pinning.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ pkgs, writeShellScriptBin }: - -writeShellScriptBin "win10-vm-pinning" '' -set -eu - -CPUSET=/sys/fs/cgroup/cpuset -#CPUSET=/dev/cpuset - -cpuset_move() { - local FROM=$1 - local TO=$2 - for proc in $(cat $CPUSET/$FROM/tasks); do - echo $proc > $CPUSET/$TO/tasks || true - done 2> /dev/null -} - -echo 1 > $CPUSET/cpuset.sched_load_balance - -if [[ ! -d $CPUSET/qemu ]]; then - mkdir $CPUSET/qemu - echo 0 > $CPUSET/qemu/cpuset.sched_load_balance -fi - -if [[ ! -d $CPUSET/system ]]; then - mkdir $CPUSET/system - echo 1 > $CPUSET/system/cpuset.sched_load_balance -fi - -cpuset_move qemu . -cpuset_move system . - -echo "" > $CPUSET/qemu/cpuset.cpus - -if [[ $# -lt 1 ]]; then - exit 0 -fi - -QEMU_PID=$1 -shift - -echo "0-1,6-7" > $CPUSET/system/cpuset.cpus -cat < $CPUSET/cpuset.mems > $CPUSET/system/cpuset.mems -cat < $CPUSET/cpuset.mems > $CPUSET/qemu/cpuset.mems - -echo "2-5,8-11" > $CPUSET/qemu/cpuset.cpus -#echo "1-3,5-7" > $CPUSET/qemu/cpuset.cpus -#echo "0,1,2" > $CPUSET/qemu/cpuset.cpus - -cpuset_move . system - -echo 1 > $CPUSET/qemu/cpuset.cpu_exclusive - -chrt -f -p 1 $QEMU_PID - -for task in /proc/$QEMU_PID/task/*; do - TASKNAME=$(grep -F "Name:" $task/status | cut -d $'\t' -f2) - TASK=$(basename $task) - - case $TASKNAME in - worker | qemu-system-*) - echo worker is $TASKNAME - ;; - IO*) - regex="IO iothread([0-9]*)" - if [[ $TASKNAME =~ $regex ]]; then - chrt -f -p 1 $TASK - fi - ;; - CPU*) - regex="CPU ([0-9]*)/KVM" - if [[ $TASKNAME =~ $regex ]]; then - CPU_ID=''${BASH_REMATCH[1]} - echo $TASK > $CPUSET/qemu/tasks - CPU_PIN=$((CPU_ID / 2 + (CPU_ID % 2) * 6 + 2)) - #CPU_PIN=$((CPU_ID * 2)) - taskset -p --cpu-list $CPU_PIN $TASK - chrt -f -p 1 $TASK - else - echo unknown CPU $TASKNAME - exit 1 - fi - ;; - *) - echo unknown task $TASKNAME - ;; - esac - done -'' diff --git a/overlays/local/vm.nix b/overlays/local/vm.nix deleted file mode 100644 index 71748c8b..00000000 --- a/overlays/local/vm.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ pkgs, writeShellScriptBin }: - -writeShellScriptBin "win10-vm" '' - cat ${pkgs.OVMF.fd}/FV/OVMF_VARS.fd > /tmp/OVMF_VARS.fd - exec ${pkgs.qemu-vfio}/bin/qemu-system-x86_64 -name guest=win10,debug-threads=on \ - -blockdev '{"driver":"file","filename":"${pkgs.OVMF.fd}/FV/OVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \ - -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \ - -blockdev '{"driver":"file","filename":"/tmp/OVMF_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ - -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \ - -machine pc-q35-5.1,accel=kvm,usb=off,vmport=off,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \ - -monitor stdio \ - -cpu host,topoext=on,host-cache-info=on,+invtsc,smep=off,hv_time,hv_relaxed,hv_spinlocks=0x1fff,hv_vendor_id=ab12341234ab$,hv_vapic,-amd-stibp \ - -m 12288 \ - -mem-path /dev/hugepages1G/qemu-win10-vm -mem-prealloc \ - -smp 8,sockets=1,dies=1,cores=4,threads=2 \ - -object iothread,id=iothread1 \ - -object iothread,id=iothread2 \ - -object iothread,id=iothread3 \ - -object iothread,id=iothread4 \ - -uuid 96052919-6a83-4e9f-8e9b-628de3e27cc1 \ - -display none \ - -no-user-config \ - -nodefaults \ - -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=delay \ - -no-hpet -no-shutdown \ - -global ICH9-LPC.disable_s3=1 \ - -global ICH9-LPC.disable_s4=1 \ - -boot strict=on \ - -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ - -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ - -device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ - -device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ - -device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ - -device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ - -device pcie-root-port,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ - -device pcie-pci-bridge,id=pci.8,bus=pci.4,addr=0x0 \ - -device pcie-root-port,port=0x17,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x7 \ - -device pcie-root-port,port=0x8,chassis=10,id=pci.10,bus=pcie.0,multifunction=on,addr=0x1 \ - -device pcie-root-port,port=0xa,chassis=11,id=pci.11,bus=pcie.0,addr=0x1.0x1 \ - -device pcie-root-port,port=0xa,chassis=12,id=pci.12,bus=pcie.0,addr=0x1.0x2 \ - -device pcie-root-port,port=0xb,chassis=13,id=pci.13,bus=pcie.0,addr=0x1.0x3 \ - -device pcie-root-port,port=0xc,chassis=14,id=pci.14,bus=pcie.0,addr=0x1.0x4 \ - -device pcie-root-port,port=0xd,chassis=15,id=pci.15,bus=pcie.0,addr=0x1.0x5 \ - -device pcie-root-port,port=0xe,chassis=16,id=pci.16,bus=pcie.0,addr=0x1.0x6 \ - -device pcie-root-port,port=0xf,chassis=17,id=pci.17,bus=pcie.0,addr=0x1.0x7 \ - -device pcie-root-port,port=0x18,chassis=18,id=pci.18,bus=pcie.0,multifunction=on,addr=0x3 \ - -device pcie-root-port,port=0x19,chassis=19,id=pci.19,bus=pcie.0,addr=0x3.0x1 \ - -device pcie-root-port,port=0x1a,chassis=20,id=pci.20,bus=pcie.0,addr=0x3.0x2 \ - -device pcie-root-port,port=0x1b,chassis=21,id=pci.21,bus=pcie.0,addr=0x3.0x3 \ - -device pcie-root-port,port=0x1c,chassis=22,id=pci.22,bus=pcie.0,addr=0x3.0x4 \ - -device pcie-root-port,port=0x1d,chassis=23,id=pci.23,bus=pcie.0,multifunction=on,addr=0x3.0x5 \ - -device pcie-pci-bridge,id=pci.24,bus=pci.10,addr=0x0 \ - -device ich9-usb-ehci1,id=usb -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on -device ich9-usb-uhci2,masterbus=usb.0,firstport=2 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4 \ - -device qemu-xhci,id=usb3,p2=4,p3=8 \ - -device virtio-scsi-pci,id=scsi0,bus=pci.6,addr=0x0 \ - -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ - -device ich9-intel-hda,id=sound0 \ - -device hda-output,audiodev=pa1 \ - -device hda-micro,audiodev=pa1 \ - -audiodev pa,id=pa1,server=/run/user/1000/pulse/native,out.buffer-length=4000,timer-period=1000 \ - -blockdev '{"driver":"host_device","filename":"/dev/disk/by-id/ata-HFS256G32TNF-N3A0A_MJ8BN15091150BM1Z","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ - -blockdev '{"node-name":"libvirt-2-format","read-only":false,"discard":"unmap","driver":"raw","file":"libvirt-2-storage"}' \ - -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-2-format,id=scsi0-0-0-0,bootindex=2 \ - -blockdev '{"driver":"host_device","filename":"/dev/mapper/ata-ST2000DM008-2FR102_WK301C3H-part2","aio":"native","node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},"auto-read-only":true,"discard":"unmap"}' \ - -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,device_id=drive-scsi0-0-0-1,drive=libvirt-1-format,id=scsi0-0-0-1,bootindex=3 \ - -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"raw","file":"libvirt-1-storage"}' \ - -netdev user,id=smbnet0,restrict=no,net=10.1.2.0/24,host=10.1.2.1,smb=/home/kat/shared/,smbserver=10.1.2.2 \ - -device virtio-net-pci,netdev=smbnet0,id=net1,mac=2b:c6:c4:ac:67:ba \ - -device vfio-pci,host=0000:29:00.0,id=hostdev0,bus=pci.7,addr=0x0 \ - -device vfio-pci,host=0000:29:00.1,id=hostdev1,bus=pci.9,addr=0x0 \ - -device vfio-pci,host=0000:28:00.0,id=hostdev3,bus=pci.11,addr=0x0 \ - -device vfio-pci,host=0000:2b:00.3,id=hostdev4,bus=pci.19,addr=0x0 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.5,addr=0x0 \ - -chardev socket,path=/tmp/vfio-qmp,server,nowait,id=qmp0 \ - -mon chardev=qmp0,id=qmp,mode=control \ - -chardev socket,path=/tmp/vfio-qga,server,nowait,id=qga0 \ - -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \ - -set device.scsi0-0-0-0.rotation_rate=1 \ - -cpu host,hv_time,kvm=off,hv_vendor_id=null,-hypervisor \ - -msg timestamp=on "$@"'' - -# -device vfio-pci,host=0000:21:00.0,id,addr=0x0 \ -# -device virtio-net-pci,netdev=hostnet0,id=net0,mac=5b:f2:eb:3c:0b:46 \ -# -netdev bridge,id=hostnet0,br=br,helper=$(type -P qemu-bridge-helper) \ -# -vcpu vcpunum=0,affinity=0 \ -# -vcpu vcpunum=1,affinity=1 \ -# -vcpu vcpunum=2,affinity=2 \ -# -vcpu vcpunum=3,affinity=3 \ -# -vcpu vcpunum=4,affinity=6 \ -# -vcpu vcpunum=5,affinity=7 \ -# -vcpu vcpunum=6,affinity=8 \ -# -vcpu vcpunum=7,affinity=9 \ diff --git a/overlays/local/waybar-gpg/default.nix b/overlays/local/waybar-gpg/default.nix deleted file mode 100644 index 2956a58b..00000000 --- a/overlays/local/waybar-gpg/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ wrapShellScriptBin, pkgs }: - -wrapShellScriptBin "kat-gpg-status" ./kat-gpg-status.sh { - depsRuntimePath = with pkgs; [ coreutils-full gawk gnugrep gnupg ]; -} diff --git a/overlays/local/waybar-gpg/kat-gpg-status.sh b/overlays/local/waybar-gpg/kat-gpg-status.sh deleted file mode 100644 index 0a8fceec..00000000 --- a/overlays/local/waybar-gpg/kat-gpg-status.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -eu -set -o pipefail - -if gpg --card-status &> /dev/null; then - user="$(gpg --card-status | grep 'Login data' | awk '{print $NF}')"; - status='{"text": "", "alt": "User: '"$user"'", "class": "enabled"}' -else - status='{"text": "", "alt": "No card is connected.", "class": "disabled"}' -fi - -echo $status diff --git a/overlays/local/waybar-konawall/default.nix b/overlays/local/waybar-konawall/default.nix deleted file mode 100644 index 602f3dc3..00000000 --- a/overlays/local/waybar-konawall/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ stdenv, wrapShellScriptBin, pkgs }: - -let - toggle = wrapShellScriptBin "konawall-toggle" ./toggle.sh { }; - status = wrapShellScriptBin "konawall-status" ./status.sh { }; -in -stdenv.mkDerivation { - pname = "konawall-toggle"; - version = "0.0.1"; - propagatedBuildInputs = with pkgs; [ - gawk - coreutils-full - bash - ]; - unpackPhase = "true"; - installPhase = '' - mkdir -p $out/bin - cp ${status}/bin/konawall-status $out/bin/konawall-status - cp ${toggle}/bin/konawall-toggle $out/bin/konawall-toggle - chmod +x $out/bin/konawall-{status,toggle} - ''; -} diff --git a/overlays/local/waybar-konawall/status.sh b/overlays/local/waybar-konawall/status.sh deleted file mode 100644 index 5e7c69a5..00000000 --- a/overlays/local/waybar-konawall/status.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -eu -set -o pipefail - -sleep 0.5s - -if systemctl --user is-active konawall-rotation.timer --quiet; then - status='{"text": "", "alt": "Konawall is enabled.", "class": "enabled"}' -else - status='{"text": "", "alt": "Konawall is disabled.", "class": "disabled"}' -fi - -echo $status diff --git a/overlays/local/waybar-konawall/toggle.sh b/overlays/local/waybar-konawall/toggle.sh deleted file mode 100644 index 0802906e..00000000 --- a/overlays/local/waybar-konawall/toggle.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -eu -set -o pipefail - - -if systemctl --user is-active konawall-rotation.timer --quiet; then - systemctl --user stop konawall-rotation.timer -else - systemctl --user start konawall-rotation.timer -fi - -pkill -SIGRTMIN+8 waybar diff --git a/overlays/local/wezterm/default.nix b/overlays/local/wezterm/default.nix deleted file mode 100644 index e623d003..00000000 --- a/overlays/local/wezterm/default.nix +++ /dev/null @@ -1,127 +0,0 @@ -{ stdenv -, rustPlatform -, lib -, fetchFromGitHub -, ncurses -, perl -, pkg-config -, python3 -, fontconfig -, openssl -, libGL -, libX11 -, libxcb -, libxkbcommon -, xcbutil -, xcbutilimage -, xcbutilkeysyms -, xcbutilwm -, wayland -, zlib -, CoreGraphics -, Cocoa -, Foundation -, UserNotifications -, libiconv -, nixosTests -, runCommand -}: - -rustPlatform.buildRustPackage rec { - pname = "wezterm"; - version = "20220624-141144-bd1b7c5d"; - - src = fetchFromGitHub { - owner = "wez"; - repo = pname; - rev = "cb89f2c36e08e74512ee7b8e1aff3bf461f774c2"; - fetchSubmodules = true; - sha256 = "sha256-Pmd5I2p2BDhJ3Mm7uGZjWYladZN2x8MMtquP4+TVtJ0="; - }; - - postPatch = '' - echo ${version} > .tag - - # tests are failing with: Unable to exchange encryption keys - rm -r wezterm-ssh/tests - ''; - - cargoSha256 = "sha256-0jhJzz3lrQf+7vv373J1HfzzVw+eottdto/ephnz4HM="; - - nativeBuildInputs = [ - pkg-config - python3 - ncurses # tic for terminfo - ] ++ lib.optional stdenv.isDarwin perl; - - buildInputs = [ - fontconfig - zlib - ] ++ lib.optionals stdenv.isLinux [ - libX11 - libxcb - libxkbcommon - openssl - wayland - xcbutil - xcbutilimage - xcbutilkeysyms - xcbutilwm # contains xcb-ewmh among others - ] ++ lib.optionals stdenv.isDarwin [ - Cocoa - CoreGraphics - UserNotifications - Foundation - libiconv - ]; - - postInstall = '' - mkdir -p $out/nix-support - echo "${passthru.terminfo}" >> $out/nix-support/propagated-user-env-packages - - # desktop icon - install -Dm644 assets/icon/terminal.png $out/share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png - install -Dm644 assets/wezterm.desktop $out/share/applications/org.wezfurlong.wezterm.desktop - install -Dm644 assets/wezterm.appdata.xml $out/share/metainfo/org.wezfurlong.wezterm.appdata.xml - - # helper scripts - install -Dm644 assets/shell-integration/wezterm.sh -t $out/etc/profile.d - ''; - - preFixup = lib.optionalString stdenv.isLinux '' - patchelf --add-needed "${libGL}/lib/libEGL.so.1" $out/bin/wezterm-gui - '' + lib.optionalString stdenv.isDarwin '' - mkdir -p "$out/Applications" - OUT_APP="$out/Applications/WezTerm.app" - cp -r assets/macos/WezTerm.app "$OUT_APP" - rm $OUT_APP/*.dylib - cp -r assets/shell-integration/* "$OUT_APP" - ln -s $out/bin/{wezterm,wezterm-mux-server,wezterm-gui,strip-ansi-escapes} "$OUT_APP" - ''; - - passthru = { - tests = { - all-terminfo = nixosTests.allTerminfo; - terminal-emulators = nixosTests.terminal-emulators.wezterm; - }; - terminfo = runCommand "wezterm-terminfo" - { - nativeBuildInputs = [ - ncurses - ]; - } '' - mkdir -p $out/share/terminfo $out/nix-support - tic -x -o $out/share/terminfo ${src}/termwiz/data/wezterm.terminfo - ''; - }; - - meta = with lib; { - description = "A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust"; - homepage = "https://wezfurlong.org/wezterm"; - license = licenses.mit; - maintainers = with maintainers; [ SuperSandro2000 ]; - platforms = platforms.unix; - # Fails on missing UserNotifications framework while linking - broken = stdenv.isDarwin; - }; -} diff --git a/overlays/local/withings-api.nix b/overlays/local/withings-api.nix deleted file mode 100644 index 320db805..00000000 --- a/overlays/local/withings-api.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ lib -, buildPythonPackage -, pythonOlder -, fetchPypi -, poetry -, arrow -, requests-oauth -, requests-oauthlib -, typing-extensions -, pydantic -}: - -buildPythonPackage rec { - pname = "withings-api"; - version = "2.4.0"; - format = "pyproject"; - - disabled = pythonOlder "3.6"; - - src = fetchPypi { - pname = "withings_api"; # source and whl distribution use _ instead of - - inherit version; - sha256 = "sha256-vQ6MKeD4g4QTkXx638FW53mTkx78af7NQXF00kxgM10="; - }; - - propagatedBuildInputs = [ - poetry - arrow - requests-oauth - requests-oauthlib - typing-extensions - pydantic - ]; - - meta = { - description = "Library for the Withings Health API"; - homepage = "https://github.com/vangorra/python_withings_api"; - license = lib.licenses.mit; - maintainers = with lib.maintainers; [ kittywitch ]; - }; -} diff --git a/overlays/local/xbackbone.nix b/overlays/local/xbackbone.nix deleted file mode 100644 index 6f3f69dc..00000000 --- a/overlays/local/xbackbone.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ lib -, stdenv -, php -, fetchurl -, unzip -}: - -stdenv.mkDerivation rec { - pname = "XBackBone"; - version = "3.5.0"; - - nativeBuildInputs = [ - unzip - ]; - - src = fetchurl { - url = "https://github.com/SergiX44/XBackBone/releases/download/${version}/release-v${version}.zip"; - sha256 = "17p180yhsgjsm9pa5vkmqfrk71avss33vw2bjb6py90dwknbkipl"; - }; - - sourceRoot = "."; - - installPhase = '' - mkdir -p $out - mv * $out - ''; - - meta = { - description = "A lightweight file manager with full ShareX, Screencloud support and more"; - homepage = "https://xbackbone.app/"; - license = lib.licenses.agpl3; - maintainers = [ lib.maintainers.kittywitch ]; - platforms = lib.platforms.unix; - }; -} diff --git a/overlays/nur/default.nix b/overlays/nur/default.nix deleted file mode 100644 index 8b6fc8b3..00000000 --- a/overlays/nur/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ inputs }: final: prev: { - nur = import inputs.nur { - nurpkgs = final; - pkgs = final; - }; -} diff --git a/overlays/rustfmt/Implement-One-option-for-imports_granularity-4669.patch b/overlays/rustfmt/Implement-One-option-for-imports_granularity-4669.patch deleted file mode 100644 index eda6d6f8..00000000 --- a/overlays/rustfmt/Implement-One-option-for-imports_granularity-4669.patch +++ /dev/null @@ -1,446 +0,0 @@ -From 179af0e572c1f5e9e124fea96bf8597e3212967d Mon Sep 17 00:00:00 2001 -SPDX-FileCopyrightText: Yusuke Tanaka -SPDX-License-Identifier: Apache-2.0 -From: Yusuke Tanaka -Date: Sat, 30 Jan 2021 14:50:28 +0900 -Subject: [PATCH] Implement `One` option for imports_granularity (#4669) - -This option merges all imports into a single `use` statement as long as -they have the same visibility. ---- - src/tools/rustfmt/Configurations.md | 19 ++- - src/tools/rustfmt/src/config/options.rs | 2 + - src/tools/rustfmt/src/imports.rs | 146 +++++++++++++++--- - src/tools/rustfmt/src/reorder.rs | 1 + - .../tests/source/imports_granularity_one.rs | 60 +++++++ - .../tests/target/imports_granularity_one.rs | 79 ++++++++++ - 6 files changed, 288 insertions(+), 19 deletions(-) - create mode 100644 src/tools/rustfmt/tests/source/imports_granularity_one.rs - create mode 100644 src/tools/rustfmt/tests/target/imports_granularity_one.rs - -diff --git a/src/tools/rustfmt/Configurations.md b/src/tools/rustfmt/Configurations.md -index 37cb7474130..601f6eeb9bd 100644 ---- a/src/tools/rustfmt/Configurations.md -+++ b/src/tools/rustfmt/Configurations.md -@@ -1665,7 +1665,7 @@ pub enum Foo {} - How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity. - - - **Default value**: `Preserve` --- **Possible values**: `Preserve`, `Crate`, `Module`, `Item` -+- **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One` - - **Stable**: No - - #### `Preserve` (default): -@@ -1719,6 +1719,23 @@ use qux::h; - use qux::i; - ``` - -+#### `One`: -+ -+Merge all imports into a single `use` statement as long as they have the same visibility. -+ -+```rust -+pub use foo::{x, y}; -+use { -+ bar::{ -+ a, -+ b::{self, f, g}, -+ c, -+ d::e, -+ }, -+ qux::{h, i}, -+}; -+``` -+ - ## `merge_imports` - - This option is deprecated. Use `imports_granularity = "Crate"` instead. -diff --git a/src/tools/rustfmt/src/config/options.rs b/src/tools/rustfmt/src/config/options.rs -index 3b91021813c..db15ee97a40 100644 ---- a/src/tools/rustfmt/src/config/options.rs -+++ b/src/tools/rustfmt/src/config/options.rs -@@ -125,6 +125,8 @@ pub enum ImportGranularity { - Module, - /// Use one `use` statement per imported item. - Item, -+ /// Use one `use` statement including all items. -+ One, - } - - #[config_type] -diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs -index 0f635fe1ccb..f5e780eb1ec 100644 ---- a/src/tools/rustfmt/src/imports.rs -+++ b/src/tools/rustfmt/src/imports.rs -@@ -138,6 +138,29 @@ fn remove_alias(&self) -> UseSegment { - } - } - -+ // Check if self == other with their aliases removed. -+ fn equal_except_alias(&self, other: &Self) -> bool { -+ match (self, other) { -+ (UseSegment::Ident(ref s1, _), UseSegment::Ident(ref s2, _)) => s1 == s2, -+ (UseSegment::Slf(_), UseSegment::Slf(_)) -+ | (UseSegment::Super(_), UseSegment::Super(_)) -+ | (UseSegment::Crate(_), UseSegment::Crate(_)) -+ | (UseSegment::Glob, UseSegment::Glob) => true, -+ (UseSegment::List(ref list1), UseSegment::List(ref list2)) => list1 == list2, -+ _ => false, -+ } -+ } -+ -+ fn get_alias(&self) -> Option<&str> { -+ match self { -+ UseSegment::Ident(_, a) -+ | UseSegment::Slf(a) -+ | UseSegment::Super(a) -+ | UseSegment::Crate(a) => a.as_deref(), -+ _ => None, -+ } -+ } -+ - fn from_path_segment( - context: &RewriteContext<'_>, - path_seg: &ast::PathSegment, -@@ -561,6 +584,7 @@ fn share_prefix(&self, other: &UseTree, shared_prefix: SharedPrefix) -> bool { - SharedPrefix::Module => { - self.path[..self.path.len() - 1] == other.path[..other.path.len() - 1] - } -+ SharedPrefix::One => true, - } - } - } -@@ -602,7 +626,7 @@ fn flatten(self) -> Vec { - fn merge(&mut self, other: &UseTree, merge_by: SharedPrefix) { - let mut prefix = 0; - for (a, b) in self.path.iter().zip(other.path.iter()) { -- if *a == *b { -+ if a.equal_except_alias(b) { - prefix += 1; - } else { - break; -@@ -637,14 +661,20 @@ fn merge_rest( - return Some(new_path); - } - } else if len == 1 { -- let rest = if a.len() == len { &b[1..] } else { &a[1..] }; -- return Some(vec![ -- b[0].clone(), -- UseSegment::List(vec![ -- UseTree::from_path(vec![UseSegment::Slf(None)], DUMMY_SP), -- UseTree::from_path(rest.to_vec(), DUMMY_SP), -- ]), -- ]); -+ let (common, rest) = if a.len() == len { -+ (&a[0], &b[1..]) -+ } else { -+ (&b[0], &a[1..]) -+ }; -+ let mut list = vec![UseTree::from_path( -+ vec![UseSegment::Slf(common.get_alias().map(ToString::to_string))], -+ DUMMY_SP, -+ )]; -+ match rest { -+ [UseSegment::List(rest_list)] => list.extend(rest_list.clone()), -+ _ => list.push(UseTree::from_path(rest.to_vec(), DUMMY_SP)), -+ } -+ return Some(vec![b[0].clone(), UseSegment::List(list)]); - } else { - len -= 1; - } -@@ -659,18 +689,54 @@ fn merge_rest( - } - - fn merge_use_trees_inner(trees: &mut Vec, use_tree: UseTree, merge_by: SharedPrefix) { -- let similar_trees = trees -- .iter_mut() -- .filter(|tree| tree.share_prefix(&use_tree, merge_by)); -+ struct SimilarTree<'a> { -+ similarity: usize, -+ path_len: usize, -+ tree: &'a mut UseTree, -+ } -+ -+ let similar_trees = trees.iter_mut().filter_map(|tree| { -+ if tree.share_prefix(&use_tree, merge_by) { -+ // In the case of `SharedPrefix::One`, `similarity` is used for deciding with which -+ // tree `use_tree` should be merge. -+ // In other cases `similarity` won't be used, so set it to `0` as a dummy value. -+ let similarity = if merge_by == SharedPrefix::One { -+ tree.path -+ .iter() -+ .zip(&use_tree.path) -+ .take_while(|(a, b)| a.equal_except_alias(b)) -+ .count() -+ } else { -+ 0 -+ }; -+ -+ let path_len = tree.path.len(); -+ Some(SimilarTree { -+ similarity, -+ tree, -+ path_len, -+ }) -+ } else { -+ None -+ } -+ }); -+ - if use_tree.path.len() == 1 && merge_by == SharedPrefix::Crate { -- if let Some(tree) = similar_trees.min_by_key(|tree| tree.path.len()) { -- if tree.path.len() == 1 { -+ if let Some(tree) = similar_trees.min_by_key(|tree| tree.path_len) { -+ if tree.path_len == 1 { - return; - } - } -- } else if let Some(tree) = similar_trees.max_by_key(|tree| tree.path.len()) { -- if tree.path.len() > 1 { -- tree.merge(&use_tree, merge_by); -+ } else if merge_by == SharedPrefix::One { -+ if let Some(sim_tree) = similar_trees.max_by_key(|tree| tree.similarity) { -+ if sim_tree.similarity > 0 { -+ sim_tree.tree.merge(&use_tree, merge_by); -+ return; -+ } -+ } -+ } else if let Some(sim_tree) = similar_trees.max_by_key(|tree| tree.path_len) { -+ if sim_tree.path_len > 1 { -+ sim_tree.tree.merge(&use_tree, merge_by); - return; - } - } -@@ -888,6 +954,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, mut shape: Shape) -> Option flatten_use_trees(normalized_items), -+ ImportGranularity::One => merge_use_trees(normalized_items, SharedPrefix::One), - ImportGranularity::Preserve => normalized_items, - }; - -diff --git a/src/tools/rustfmt/tests/source/imports_granularity_one.rs b/src/tools/rustfmt/tests/source/imports_granularity_one.rs -new file mode 100644 -index 00000000000..c21707df395 ---- /dev/null -+++ b/src/tools/rustfmt/tests/source/imports_granularity_one.rs -@@ -0,0 +1,60 @@ -+// rustfmt-imports_granularity: One -+ -+use b; -+use a::ac::{aca, acb}; -+use a::{aa::*, ab}; -+ -+use a as x; -+use b::ba; -+use a::{aa, ab}; -+ -+use a::aa::aaa; -+use a::ab::aba as x; -+use a::aa::*; -+ -+use a::aa; -+use a::ad::ada; -+#[cfg(test)] -+use a::{ab, ac::aca}; -+use b; -+#[cfg(test)] -+use b::{ -+ ba, bb, -+ bc::bca::{bcaa, bcab}, -+}; -+ -+pub use a::aa; -+pub use a::ae; -+use a::{ab, ac, ad}; -+use b::ba; -+pub use b::{bb, bc::bca}; -+ -+use a::aa::aaa; -+use a::ac::{aca, acb}; -+use a::{aa::*, ab}; -+use b::{ -+ ba, -+ bb::{self, bba}, -+}; -+ -+use crate::a; -+use crate::b::ba; -+use c::ca; -+ -+use super::a; -+use c::ca; -+use super::b::ba; -+ -+use crate::a; -+use super::b; -+use c::{self, ca}; -+ -+use a::{ -+ // some comment -+ aa::{aaa, aab}, -+ ab, -+ // another comment -+ ac::aca, -+}; -+use b as x; -+use a::ad::ada; -diff --git a/src/tools/rustfmt/tests/target/imports_granularity_one.rs b/src/tools/rustfmt/tests/target/imports_granularity_one.rs -new file mode 100644 -index 00000000000..78ec5e7325c ---- /dev/null -+++ b/src/tools/rustfmt/tests/target/imports_granularity_one.rs -@@ -0,0 +1,79 @@ -+// rustfmt-imports_granularity: One -+ -+use { -+ a::{ -+ aa::*, -+ ab, -+ ac::{aca, acb}, -+ }, -+ b, -+}; -+ -+use { -+ a::{self as x, aa, ab}, -+ b::ba, -+}; -+ -+use a::{ -+ aa::{aaa, *}, -+ ab::aba as x, -+}; -+ -+#[cfg(test)] -+use a::{ab, ac::aca}; -+#[cfg(test)] -+use b::{ -+ ba, bb, -+ bc::bca::{bcaa, bcab}, -+}; -+use { -+ a::{aa, ad::ada}, -+ b, -+}; -+ -+pub use { -+ a::{aa, ae}, -+ b::{bb, bc::bca}, -+}; -+use { -+ a::{ab, ac, ad}, -+ b::ba, -+}; -+ -+use { -+ a::{ -+ aa::{aaa, *}, -+ ab, -+ ac::{aca, acb}, -+ }, -+ b::{ -+ ba, -+ bb::{self, bba}, -+ }, -+}; -+ -+use { -+ crate::{a, b::ba}, -+ c::ca, -+}; -+ -+use { -+ super::{a, b::ba}, -+ c::ca, -+}; -+ -+use { -+ super::b, -+ crate::a, -+ c::{self, ca}, -+}; -+ -+use { -+ a::{ -+ aa::{aaa, aab}, -+ ab, -+ ac::aca, -+ ad::ada, -+ }, -+ b as x, -+}; --- -2.32.0 - diff --git a/overlays/rustfmt/default.nix b/overlays/rustfmt/default.nix deleted file mode 100644 index 2a9d606a..00000000 --- a/overlays/rustfmt/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -final: prev: { - rustfmt = prev.rustfmt.overrideAttrs ({ patches ? [ ], ... }: { - patches = patches ++ [ - # Adds an option variant that merges all use statements into a single block. - # Taken from https://github.com/rust-lang/rustfmt/pull/4680 - ./Implement-One-option-for-imports_granularity-4669.patch - ]; - }); -} diff --git a/overlays/local/snakeoil.nix b/packages/snakeoil.nix similarity index 100% rename from overlays/local/snakeoil.nix rename to packages/snakeoil.nix diff --git a/tree.nix b/tree.nix index 67e8f807..622b4bef 100644 --- a/tree.nix +++ b/tree.nix @@ -12,6 +12,7 @@ "flake" "std" "inputs" + "lib" ]; }; packages = {