From 7d5cce374c3402b6bcc8169d325fd342c2f8d506 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:31:41 +0200 Subject: [PATCH] feat: use nixfmt --- .pre-commit-config.yaml | 6 ++ flake.nix | 25 ++++--- packages/winapps-launcher/default.nix | 90 +++++++++++----------- packages/winapps/default.nix | 103 ++++++++++++++------------ 4 files changed, 122 insertions(+), 102 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5f2edb..76a6cd0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ ci: autoupdate_branch: "rewrite" + skip: [nixfmt] repos: - repo: https://github.com/Lucas-C/pre-commit-hooks @@ -48,3 +49,8 @@ repos: rev: v0.10.0.1 hooks: - id: shellcheck + + - repo: https://github.com/NixOS/nixfmt + rev: d0c0cda4fe6b7ae2b9aa37f3ee15e6412573eb01 + hooks: + - id: nixfmt diff --git a/flake.nix b/flake.nix index 596e431..5bf6d8f 100644 --- a/flake.nix +++ b/flake.nix @@ -6,19 +6,22 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { - nixpkgs, - flake-utils, - ... - }: + outputs = + { + nixpkgs, + flake-utils, + ... + }: flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = import nixpkgs {inherit system;}; - in { - formatter = pkgs.alejandra; + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + formatter = pkgs.nixfmt-rfc-style; - packages.winapps = pkgs.callPackage ./packages/winapps {}; - packages.winapps-launcher = pkgs.callPackage ./packages/winapps-launcher {}; + packages.winapps = pkgs.callPackage ./packages/winapps { }; + packages.winapps-launcher = pkgs.callPackage ./packages/winapps-launcher { }; } ); } diff --git a/packages/winapps-launcher/default.nix b/packages/winapps-launcher/default.nix index 0b1cece..362f428 100644 --- a/packages/winapps-launcher/default.nix +++ b/packages/winapps-launcher/default.nix @@ -7,60 +7,64 @@ callPackage, yad, ... -}: let +}: +let rev = "eaa660d39bf3f49b136c98c87c35e3e12f118f8f"; hash = "sha256-7lkx/O4dOdVqAPX6s2IkkM6Ggbzmz9sm++20BBeoUQ4="; in - stdenv.mkDerivation rec { - pname = "winapps-launcher"; - version = "git+${rev}"; +stdenv.mkDerivation rec { + pname = "winapps-launcher"; + version = "git+${rev}"; - src = fetchFromGitHub { - owner = "winapps-org"; - repo = "WinApps-Launcher"; + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "WinApps-Launcher"; - inherit rev hash; - }; + inherit rev hash; + }; - nativeBuildInputs = [makeWrapper]; - buildInputs = [yad (callPackage ../winapps {})]; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ + yad + (callPackage ../winapps { }) + ]; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - mkdir -p $out - cp -r ./Icons $out/Icons + mkdir -p $out + cp -r ./Icons $out/Icons - sed -E -i \ - -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ - WinAppsLauncher.sh + sed -E -i \ + -e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \ + WinAppsLauncher.sh - install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher - install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg + install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher + install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg - wrapProgram $out/bin/winapps-launcher \ - --set LIBVIRT_DEFAULT_URI "qemu:///system" \ - --prefix PATH : "${lib.makeBinPath buildInputs}" + wrapProgram $out/bin/winapps-launcher \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" - runHook postInstall - ''; + runHook postInstall + ''; - desktopItems = [ - (makeDesktopItem { - name = "winapps"; - exec = "winapps-launcher"; - icon = "winapps"; - comment = meta.description; - desktopName = "WinApps"; - categories = ["Utility"]; - }) - ]; + desktopItems = [ + (makeDesktopItem { + name = "winapps"; + exec = "winapps-launcher"; + icon = "winapps"; + comment = meta.description; + desktopName = "WinApps"; + categories = [ "Utility" ]; + }) + ]; - meta = with lib; { - homepage = "https://github.com/winapps-org/WinApps-Launcher"; - description = "Graphical launcher for WinApps. Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; - mainProgram = "winapps-launcher"; - platforms = platforms.linux; - license = licenses.gpl3; - }; - } + meta = with lib; { + homepage = "https://github.com/winapps-org/WinApps-Launcher"; + description = "Graphical launcher for WinApps. Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps-launcher"; + platforms = platforms.linux; + license = licenses.gpl3; + }; +} diff --git a/packages/winapps/default.nix b/packages/winapps/default.nix index 986c6dc..9730c67 100644 --- a/packages/winapps/default.nix +++ b/packages/winapps/default.nix @@ -9,67 +9,74 @@ netcat-gnu, iproute2, ... -}: let +}: +let rev = "7bae17e3a3607e6b93c7cfc4155dfbdca7bba005"; hash = "sha256-PP4POMwHCsAdiCxZkjXlON84F0Mg3Pd5bHEI6tC+Sds="; in - stdenv.mkDerivation rec { - pname = "winapps"; - version = "git+${rev}"; +stdenv.mkDerivation rec { + pname = "winapps"; + version = "git+${rev}"; - src = fetchFromGitHub { - owner = "winapps-org"; - repo = "winapps"; + src = fetchFromGitHub { + owner = "winapps-org"; + repo = "winapps"; - inherit rev hash; - }; + inherit rev hash; + }; - nativeBuildInputs = [makeWrapper]; - buildInputs = [freerdp3 libnotify dialog netcat-gnu iproute2]; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ + freerdp3 + libnotify + dialog + netcat-gnu + iproute2 + ]; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - patchShebangs install/inquirer.sh + mkdir -p $out + mkdir -p $out/src - mkdir -p $out - mkdir -p $out/src + patchShebangs install/inquirer.sh - cp -r ./ $out/src/ + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + bin/winapps - install -m755 -D bin/winapps $out/bin/winapps - install -m755 -D setup.sh $out/bin/winapps-setup + sed -E -i \ + -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ + -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ + -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ + -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ + -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ + -e 's|./setup.sh|winapps-setup|g' \ + -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ + -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ + -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ + ./setup.sh - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - $out/bin/winapps + cp -r ./ $out/src/ - sed -E -i \ - -e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \ - -e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \ - -e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \ - -e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \ - -e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \ - -e 's|./setup.sh|winapps-setup|g' \ - -e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \ - -e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \ - -e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \ - $out/bin/winapps-setup + install -m755 -D bin/winapps $out/bin/winapps + install -m755 -D setup.sh $out/bin/winapps-setup - for f in winapps-setup winapps; do - wrapProgram $out/bin/$f \ - --set LIBVIRT_DEFAULT_URI "qemu:///system" \ - --prefix PATH : "${lib.makeBinPath buildInputs}" - done + for f in winapps-setup winapps; do + wrapProgram $out/bin/$f \ + --set LIBVIRT_DEFAULT_URI "qemu:///system" \ + --prefix PATH : "${lib.makeBinPath buildInputs}" + done - runHook postInstall - ''; + runHook postInstall + ''; - meta = with lib; { - homepage = "https://github.com/winapps-org/winapps"; - description = "Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; - mainProgram = "winapps"; - platforms = platforms.linux; - license = licenses.gpl3; - }; - } + meta = with lib; { + homepage = "https://github.com/winapps-org/winapps"; + description = "Run Windows applications (including Microsoft 365 and Adobe Creative Cloud) on GNU/Linux with KDE, GNOME or XFCE, integrated seamlessly as if they were native to the OS. Wayland is currently unsupported."; + mainProgram = "winapps"; + platforms = platforms.linux; + license = licenses.agpl3Plus; + }; +}