From 8d9b97fdde8b1af79fc7f663ae829c035e5669d0 Mon Sep 17 00:00:00 2001 From: piegames Date: Wed, 11 Oct 2023 15:47:24 +0200 Subject: [PATCH] Put semicolons on same line again --- src/Nixfmt/Pretty.hs | 7 +---- test/diff/attr_set/out.nix | 9 ++---- test/diff/idioms_lib_2/out.nix | 24 ++++++---------- test/diff/idioms_lib_3/out.nix | 42 ++++++++++------------------ test/diff/idioms_lib_4/out.nix | 39 +++++++++----------------- test/diff/idioms_lib_5/out.nix | 48 +++++++++++--------------------- test/diff/idioms_nixos_1/out.nix | 6 ++-- test/diff/idioms_nixos_2/out.nix | 9 ++---- test/diff/idioms_pkgs_3/out.nix | 30 +++++++------------- test/diff/idioms_pkgs_4/out.nix | 12 +++----- test/diff/monsters_5/out.nix | 6 ++-- 11 files changed, 76 insertions(+), 156 deletions(-) diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index 115bf017..24a5406c 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -451,11 +451,6 @@ instance Pretty Expression where group (pretty if_ <> line <> nest 2 (pretty cond) <> line <> pretty then_) <> (surroundWith line $ nest 2 $ group expr0) <> pretty else_ <> absorbElse expr1 - -- This trailing line' is a bit of a hack. It makes sure that the semicolon in binders gets placed onto - -- a new line if the items ends with a (multiline) if. - -- Normally this should only be the case when in binders as this might interfere with other syntax constructs, - -- but because our style always puts a new line after multiline Ifs it turns out to work just fine ^^ - <> line' pretty (Abstraction (IDParameter param) colon body) = pretty param <> pretty colon <> absorbAbs 1 body @@ -503,7 +498,7 @@ instance Pretty Expression where line <> pretty (moveTrailingCommentUp op') <> nest 2 (absorbOperation expr) in group' False $ - ((concat . map prettyOperation . (flatten Nothing)) operation) <> line' + (concat . map prettyOperation . (flatten Nothing)) operation pretty (MemberCheck expr qmark sel) = pretty expr <> softline diff --git a/test/diff/attr_set/out.nix b/test/diff/attr_set/out.nix index ea7022bd..77774632 100644 --- a/test/diff/attr_set/out.nix +++ b/test/diff/attr_set/out.nix @@ -133,8 +133,7 @@ ++ (optionals condition [ more items - ]) - ; + ]); b = with pkgs; [ a lot @@ -195,8 +194,7 @@ secret-config.ssh-hosts // { foo = "bar"; - } - ; + }; programs.ssh.knownHosts3 = lib.mapAttrs ( host_name: publicKey: { @@ -225,8 +223,7 @@ ) // { foo = "bar"; - } - ; + }; programs.ssh.knownHosts5 = someStuff // lib.mapAttrs ( diff --git a/test/diff/idioms_lib_2/out.nix b/test/diff/idioms_lib_2/out.nix index b2c94033..8d60856b 100644 --- a/test/diff/idioms_lib_2/out.nix +++ b/test/diff/idioms_lib_2/out.nix @@ -196,8 +196,7 @@ rec { if pathExists suffixFile then lib.strings.fileContents suffixFile else - "pre-git" - ; + "pre-git"; /* Attempts to return the the current revision of nixpkgs and returns the supplied default value otherwise. @@ -216,8 +215,7 @@ rec { else if lib.pathExists revisionFile then lib.fileContents revisionFile else - default - ; + default; nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" @@ -263,8 +261,7 @@ rec { else if a > b then 1 else - 0 - ; + 0; /* Split type into two subtypes by predicate `p`, take all elements of the first subtype to be less than all the elements of the @@ -300,8 +297,7 @@ rec { else if p b then 1 else - no a b - ; + no a b; /* Reads a JSON file. @@ -352,8 +348,7 @@ rec { abort "NIX_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors." ) else - msg: builtins.trace "warning: ${msg}" - ; + msg: builtins.trace "warning: ${msg}"; /* Like warn, but only warn when the first argument is `true`. @@ -436,8 +431,7 @@ rec { if f ? __functor then f.__functionArgs or (lib.functionArgs (f.__functor f)) else - builtins.functionArgs f - ; + builtins.functionArgs f; /* Check whether something is a function or something annotated with function args. @@ -470,8 +464,7 @@ rec { "14" = "E"; "15" = "F"; } - .${toString d} - ; + .${toString d}; in lib.concatMapStrings toHexDigit (toBaseDigits 16 i); @@ -496,8 +489,7 @@ rec { r = i - ((i / base) * base); q = (i - r) / base; in - [ r ] ++ go q - ; + [ r ] ++ go q; in assert (base >= 2); assert (i >= 0); diff --git a/test/diff/idioms_lib_3/out.nix b/test/diff/idioms_lib_3/out.nix index cef667ca..91a693e2 100644 --- a/test/diff/idioms_lib_3/out.nix +++ b/test/diff/idioms_lib_3/out.nix @@ -69,8 +69,7 @@ rec { else if isFloat v then libStr.floatToString v else - err "this value is" (toString v) - ; + err "this value is" (toString v); # Generate a line of key k and value v, separated by # character sep. If sep appears in k, it is escaped. @@ -103,8 +102,7 @@ rec { if listsAsDuplicateKeys then k: v: map (mkLine k) (if lib.isList v then v else [ v ]) else - k: v: [ (mkLine k v) ] - ; + k: v: [ (mkLine k v) ]; in attrs: libStr.concatStrings (lib.concatLists (libAttr.mapAttrsToList mkLines attrs)); @@ -156,8 +154,7 @@ rec { '' [${mkSectionName sectName}] '' - + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues - ; + + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues; in # map input to ini sections mapAttrsToStringsSep "\n" mkSection attrsOfAttrs; @@ -216,8 +213,7 @@ rec { else (toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } globalSection) + "\n" ) - + (toINI { inherit mkSectionName mkKeyValue listsAsDuplicateKeys; } sections) - ; + + (toINI { inherit mkSectionName mkKeyValue listsAsDuplicateKeys; } sections); # Generate a git-config file from an attrset. # @@ -252,8 +248,7 @@ rec { if containsQuote || subsections == [ ] then name else - ''${section} "${subsection}"'' - ; + ''${section} "${subsection}"''; # generation for multiple ini values mkKeyValue = @@ -273,8 +268,7 @@ rec { else if length path > 1 then { ${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value; } else - { ${head path} = value; } - ; + { ${head path} = value; }; in attrs: lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs)); @@ -321,8 +315,7 @@ rec { else const "" else - id - ; + id; mapAny = with builtins; depth: v: @@ -334,8 +327,7 @@ rec { else if isList v then map evalNext v else - transform (depth + 1) v - ; + transform (depth + 1) v; in mapAny 0; @@ -368,16 +360,14 @@ rec { ${indent} '' else - " " - ; + " "; outroSpace = if multiline then '' ${indent}'' else - " " - ; + " "; in if isInt v then toString v @@ -417,8 +407,7 @@ rec { + introSpace + concatStringsSep introSpace (lib.init escapedLines) + (if lastLine == "" then outroSpace else introSpace + lastLine) - + "''" - ; + + "''"; in if multiline && length lines > 1 then multilineResult else singlelineResult else if true == v then @@ -473,8 +462,7 @@ rec { + outroSpace + "}" else - abort "generators.toPretty: should never happen (v = ${v})" - ; + abort "generators.toPretty: should never happen (v = ${v})"; in go indent; @@ -502,8 +490,7 @@ rec { else if isFloat x then float ind x else - abort "generators.toPlist: should never happen (v = ${v})" - ; + abort "generators.toPlist: should never happen (v = ${v})"; literal = ind: x: ind + x; @@ -586,6 +573,5 @@ rec { else if v == null then abort "generators.toDhall: cannot convert a null to Dhall" else - builtins.toJSON v - ; + builtins.toJSON v; } diff --git a/test/diff/idioms_lib_4/out.nix b/test/diff/idioms_lib_4/out.nix index e8bdec00..3953f448 100644 --- a/test/diff/idioms_lib_4/out.nix +++ b/test/diff/idioms_lib_4/out.nix @@ -75,8 +75,7 @@ rec { types.significantByte.check x.significantByte else !(x ? significantByte) - ) - ; + ); }; types.cpuType = enum (attrValues cpuTypes); @@ -371,8 +370,7 @@ rec { then execFormats.aout else - execFormats.elf - ; + execFormats.elf; # Determine when two CPUs are compatible with each other. That is, # can code built for system B run on system A? For that to happen, @@ -509,8 +507,7 @@ rec { check = x: types.execFormat.check x.execFormat - && all types.kernelFamily.check (attrValues x.families) - ; + && all types.kernelFamily.check (attrValues x.families); }; types.kernel = enum (attrValues kernels); @@ -609,8 +606,7 @@ rec { watchos = kernels.ios; tvos = kernels.ios; win32 = kernels.windows; - } - ; + }; ################################################################################ @@ -732,8 +728,7 @@ rec { types.cpuType.check cpu && types.vendor.check vendor && types.kernel.check kernel - && types.abi.check abi - ; + && types.abi.check abi; }; isSystem = isType "system"; @@ -754,8 +749,7 @@ rec { abi = "unknown"; } else - throw "Target specification with 1 components is ambiguous" - ; + throw "Target specification with 1 components is ambiguous"; "2" = # We only do 2-part hacks for things Nix already supports if elemAt l 1 == "cygwin" then { @@ -784,8 +778,7 @@ rec { { cpu = elemAt l 0; kernel = elemAt l 1; - } - ; + }; "3" = # cpu-kernel-environment if @@ -824,12 +817,10 @@ rec { if elemAt l 2 == "mingw32" then "windows" # autotools breaks on -gnu for window else - elemAt l 2 - ; + elemAt l 2; } else - throw "Target specification with 3 components is ambiguous" - ; + throw "Target specification with 3 components is ambiguous"; "4" = { cpu = elemAt l 0; vendor = elemAt l 1; @@ -868,16 +859,14 @@ rec { else if isWindows parsed then vendors.pc else - vendors.unknown - ; + vendors.unknown; kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin" else if hasPrefix "netbsd" args.kernel then getKernel "netbsd" else - getKernel args.kernel - ; + getKernel args.kernel; abi = if args ? abi then getAbi args.abi @@ -893,8 +882,7 @@ rec { else abis.gnu else - abis.unknown - ; + abis.unknown; }; in mkSystem parsed; @@ -916,8 +904,7 @@ rec { else if kernel.families ? darwin then "${cpu.name}-darwin" else - "${cpu.name}-${kernelName kernel}" - ; + "${cpu.name}-${kernelName kernel}"; tripleFromSystem = { diff --git a/test/diff/idioms_lib_5/out.nix b/test/diff/idioms_lib_5/out.nix index 33c80ba2..61424dc6 100644 --- a/test/diff/idioms_lib_5/out.nix +++ b/test/diff/idioms_lib_5/out.nix @@ -37,8 +37,7 @@ let if lib.mutuallyExclusive allowlist blocklist then true else - throw "allowlistedLicenses and blocklistedLicenses are not mutually exclusive." - ; + throw "allowlistedLicenses and blocklistedLicenses are not mutually exclusive."; hasLicense = attrs: attrs ? meta.license; @@ -48,8 +47,7 @@ let hasLicense attrs && lib.lists.any (l: builtins.elem l allowlist) ( lib.lists.toList attrs.meta.license - ) - ; + ); hasBlocklistedLicense = assert areLicenseListsValid; @@ -57,16 +55,14 @@ let hasLicense attrs && lib.lists.any (l: builtins.elem l blocklist) ( lib.lists.toList attrs.meta.license - ) - ; + ); allowBroken = config.allowBroken || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"; allowUnsupportedSystem = config.allowUnsupportedSystem - || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1" - ; + || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1"; isUnfree = licenses: lib.lists.any (l: !l.free or true) licenses; @@ -106,8 +102,7 @@ let attrs: !(isMarkedInsecure attrs) || allowInsecurePredicate attrs - || builtins.getEnv "NIXPKGS_ALLOW_INSECURE" == "1" - ; + || builtins.getEnv "NIXPKGS_ALLOW_INSECURE" == "1"; isNonSource = sourceTypes: lib.lists.any (t: !t.isSource) sourceTypes; @@ -131,8 +126,7 @@ let attrs: hasNonSourceProvenance attrs && !allowNonSource - && !allowNonSourcePredicate attrs - ; + && !allowNonSourcePredicate attrs; showLicenseOrSourceType = value: toString (map (v: v.shortName or "unknown") (lib.lists.toList value)); @@ -242,8 +236,7 @@ let ]; } - '' - ; + ''; remediateOutputsToInstall = attrs: @@ -283,8 +276,7 @@ let Package ‘${getName attrs}’ in ${pos_str meta} ${errormsg}, refusing to evaluate. '' - + (builtins.getAttr reason remediation) attrs - ; + + (builtins.getAttr reason remediation) attrs; handler = if config ? handleEvalIssue then config.handleEvalIssue reason else throw; @@ -306,8 +298,7 @@ let "Package ${getName attrs} in ${pos_str meta} ${errormsg}, continuing anyway." + (lib.optionalString (remediationMsg != "") '' - ${remediationMsg}'') - ; + ${remediationMsg}''); isEnabled = lib.findFirst (x: x == reason) null showWarnings; in if isEnabled != null then builtins.trace msg true else true; @@ -362,8 +353,7 @@ let x == { } || ( # Accept {} for tests that are unsupported isDerivation x && x ? meta.timeout - ) - ; + ); merge = lib.options.mergeOneOption; } ); @@ -403,8 +393,7 @@ let else '' key 'meta.${k}' is unrecognized; expected one of: - [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]'' - ; + [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]''; checkMeta = meta: lib.optionals config.checkMeta ( @@ -529,8 +518,7 @@ let # ----- else { valid = "yes"; } - ) - ; + ); # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not @@ -578,8 +566,7 @@ let ++ outputs )) ] - ++ lib.optional (hasOutput "man") "man" - ; + ++ lib.optional (hasOutput "man") "man"; } // attrs.meta or { } # Fill `meta.position` to identify the source location of the package. @@ -602,10 +589,8 @@ let lib.all (d: d.meta.available or true) references else true - ) - ; - } - ; + ); + }; assertValidity = { meta, attrs }: @@ -627,8 +612,7 @@ let yes = true; } .${validity.valid}; - } - ; + }; in { inherit assertValidity commonMeta; diff --git a/test/diff/idioms_nixos_1/out.nix b/test/diff/idioms_nixos_1/out.nix index 497dd313..2d26acba 100644 --- a/test/diff/idioms_nixos_1/out.nix +++ b/test/diff/idioms_nixos_1/out.nix @@ -371,8 +371,7 @@ in (isYes "MODULES") (isYes "BINFMT_ELF") ] - ++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT")) - ; + ++ (optional (randstructSeed != "") (isYes "GCC_PLUGIN_RANDSTRUCT")); # nixpkgs kernels are assumed to have all required features assertions = @@ -387,8 +386,7 @@ in assertion = attrs.assertion cfg; inherit (attrs) message; }) - config.system.requiredKernelConfig - ; + config.system.requiredKernelConfig; }) ]; } diff --git a/test/diff/idioms_nixos_2/out.nix b/test/diff/idioms_nixos_2/out.nix index 2baaeef3..3a01554d 100644 --- a/test/diff/idioms_nixos_2/out.nix +++ b/test/diff/idioms_nixos_2/out.nix @@ -37,8 +37,7 @@ let ++ optional cfg.caching.redis redis ++ optional cfg.caching.memcached memcached ) - ++ cfg.phpExtraExtensions all - ; # Enabled by user + ++ cfg.phpExtraExtensions all; # Enabled by user extraConfig = toKeyValue phpOptions; }; @@ -803,8 +802,7 @@ in See on how to achieve this. For more context, here is the implementing pull request: https://github.com/NixOS/nixpkgs/pull/198470 - '') - ; + ''); services.nextcloud.package = with pkgs; @@ -1134,8 +1132,7 @@ in "listen.owner" = config.services.nginx.user; "listen.group" = config.services.nginx.group; } - // cfg.poolSettings - ; + // cfg.poolSettings; extraConfig = cfg.poolConfig; }; }; diff --git a/test/diff/idioms_pkgs_3/out.nix b/test/diff/idioms_pkgs_3/out.nix index 0c64ad51..d10db2a6 100644 --- a/test/diff/idioms_pkgs_3/out.nix +++ b/test/diff/idioms_pkgs_3/out.nix @@ -155,8 +155,7 @@ assert stdenv.cc.libc or null != null; assert pipewireSupport -> !waylandSupport || !webrtcSupport - -> throw "${pname}: pipewireSupport requires both wayland and webrtc support." -; + -> throw "${pname}: pipewireSupport requires both wayland and webrtc support."; let inherit (lib) enableFeature; @@ -182,8 +181,7 @@ let if ltoSupport then buildPackages.rustc.llvmPackages.bintools else - stdenv.cc.bintools - ; + stdenv.cc.bintools; } ); @@ -264,16 +262,14 @@ buildStdenv.mkDerivation ({ lib.optional (lib.versionAtLeast version "111") ./env_var_for_system_dir-ff111.patch ++ lib.optional (lib.versionAtLeast version "96") ./no-buildconfig-ffx96.patch - ++ extraPatches - ; + ++ extraPatches; postPatch = '' rm -rf obj-x86_64-pc-linux-gnu patchShebangs mach build '' - + extraPostPatch - ; + + extraPostPatch; # Ignore trivial whitespace changes in patches, this fixes compatibility of # ./env_var_for_system_dir.patch with Firefox >=65 without having to track @@ -310,8 +306,7 @@ buildStdenv.mkDerivation ({ patchelf ] ++ lib.optionals pgoSupport [ xvfb-run ] - ++ extraNativeBuildInputs - ; + ++ extraNativeBuildInputs; setOutputFlags = false; # `./mach configure` doesn't understand `--*dir=` flags. @@ -382,8 +377,7 @@ buildStdenv.mkDerivation ({ '' + lib.optionalString (enableOfficialBranding && !stdenv.is32bit) '' export MOZILLA_OFFICIAL=1 - '' - ; + ''; # firefox has a different definition of configurePlatforms from nixpkgs, see configureFlags configurePlatforms = [ ]; @@ -453,8 +447,7 @@ buildStdenv.mkDerivation ({ ] ++ lib.optional enableOfficialBranding "--enable-official-branding" ++ lib.optional (branding != null) "--with-branding=${branding}" - ++ extraConfigureFlags - ; + ++ extraConfigureFlags; buildInputs = [ @@ -505,8 +498,7 @@ buildStdenv.mkDerivation ({ libdrm ] ++ lib.optional jemallocSupport jemalloc - ++ extraBuildInputs - ; + ++ extraBuildInputs; profilingPhase = lib.optionalString pgoSupport '' # Package up Firefox for profiling @@ -554,8 +546,7 @@ buildStdenv.mkDerivation ({ '' + '' cd mozobj - '' - ; + ''; postInstall = '' @@ -570,8 +561,7 @@ buildStdenv.mkDerivation ({ # Needed to find Mozilla runtime gappsWrapperArgs+=(--argv0 "$out/bin/.${binaryName}-wrapped") - '' - ; + ''; postFixup = lib.optionalString crashreporterSupport '' patchelf --add-rpath "${ diff --git a/test/diff/idioms_pkgs_4/out.nix b/test/diff/idioms_pkgs_4/out.nix index 99d6bfa8..5e0a7b34 100644 --- a/test/diff/idioms_pkgs_4/out.nix +++ b/test/diff/idioms_pkgs_4/out.nix @@ -16,8 +16,7 @@ let if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash" else - "/bin/bash" - ; + "/bin/bash"; path = (lib.optionals (system == "i686-solaris") [ "/usr/gnu" ]) @@ -27,8 +26,7 @@ let "/" "/usr" "/usr/local" - ] - ; + ]; prehookBase = '' # Disable purity tests; it's allowed (even needed) to link to @@ -123,8 +121,7 @@ let else if system == "x86_64-cygwin" then prehookCygwin else - prehookBase - ; + prehookBase; extraNativeBuildInputs = extraNativeBuildInputs @@ -135,8 +132,7 @@ let extraNativeBuildInputsCygwin else [ ] - ) - ; + ); initialPath = extraPath ++ path; diff --git a/test/diff/monsters_5/out.nix b/test/diff/monsters_5/out.nix index 59a5a6ee..d64c4253 100644 --- a/test/diff/monsters_5/out.nix +++ b/test/diff/monsters_5/out.nix @@ -132,8 +132,7 @@ in = mergeEqualOption; - } - ; + }; apply @@ -179,8 +178,7 @@ in ++ - kernelPatches - ; + kernelPatches; features