diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index 85bcbbf4..f11c3f82 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -126,7 +126,7 @@ instance Pretty Binder where = base $ group $ hcat selectors <> nest 2 (hardspace <> pretty assign <> inner) <> pretty semicolon where - inner = + inner = case expr of -- Absorbable term. Always start on the same line, keep semicolon attatched (Term t) | isAbsorbable t -> hardspace <> prettyTermWide t @@ -140,36 +140,36 @@ instance Pretty Binder where (Term _) -> group' False (line <> pretty expr) -- Function call -- Absorb if all arguments except the last fit into the line, start on new line otherwise - (Application f a) -> prettyApp hardline line line' mempty f a + (Application f a) -> prettyApp hardline line mempty mempty f a -- Absorb function declarations but only those with simple parameter(s) (Abstraction _ _ _) | isAbstractionWithAbsorbableTerm expr -> hardspace <> group expr -- With expression with absorbable body: Try to absorb and keep the semicolon attached, spread otherwise - (With _ _ _ (Term t)) | isAbsorbable t -> softline <> group' False (pretty expr <> softline') + (With _ _ _ (Term t)) | isAbsorbable t -> softline <> group expr -- Special case `//` operations to be more compact in some cases -- Case 1: two arguments, LHS is absorbable term, RHS fits onto the last line (Operation (Term t) (Ann [] TUpdate Nothing) b) | isAbsorbable t -> - group' False $ line <> group' True (prettyTermWide t) <> line <> pretty TUpdate <> hardspace <> pretty b <> line' + group' False $ line <> group' True (prettyTermWide t) <> line <> pretty TUpdate <> hardspace <> pretty b -- Case 2a: LHS fits onto first line, RHS is an absorbable term (Operation l (Ann [] TUpdate Nothing) (Term t)) | isAbsorbable t -> - group' False $ line <> pretty l <> line <> group' True (pretty TUpdate <> hardspace <> prettyTermWide t) <> line' + group' False $ line <> pretty l <> line <> group' True (pretty TUpdate <> hardspace <> prettyTermWide t) -- Case 2b: LHS fits onto first line, RHS is a function application (Operation l (Ann [] TUpdate Nothing) (Application f a)) -> - line <> (group $ pretty l) <> line <> prettyApp hardline (pretty TUpdate <> hardspace) line' hardline f a + line <> (group l) <> line <> prettyApp hardline (pretty TUpdate <> hardspace) mempty hardline f a -- Special case `++` operations to be more compact in some cases -- Case 1: two arguments, LHS is absorbable term, RHS fits onto the last line (Operation (Term t) (Ann [] TConcat Nothing) b) | isAbsorbable t -> - group' False $ line <> group' True (prettyTermWide t) <> line <> pretty TConcat <> hardspace <> pretty b <> line' + group' False $ line <> group' True (prettyTermWide t) <> line <> pretty TConcat <> hardspace <> pretty b -- Case 2a: LHS fits onto first line, RHS is an absorbable term (Operation l (Ann [] TConcat Nothing) (Term t)) | isAbsorbable t -> - group' False $ line <> pretty l <> line <> group' True (pretty TConcat <> hardspace <> prettyTermWide t) <> line' + group' False $ line <> pretty l <> line <> group' True (pretty TConcat <> hardspace <> prettyTermWide t) -- Case 2b: LHS fits onto first line, RHS is a function application (Operation l (Ann [] TConcat Nothing) (Application f a)) -> - line <> (group $ pretty l) <> line <> prettyApp hardline (pretty TConcat <> hardspace) line' hardline f a + line <> (group l) <> line <> prettyApp hardline (pretty TConcat <> hardspace) mempty hardline f a -- Everything else: -- If it fits on one line, it fits -- If it fits on one line but with a newline after the `=`, it fits (including semicolon) -- Otherwise, start on new line, expand fully (including the semicolon) - _ -> line <> group' False (pretty expr <> line') + _ -> line <> group expr -- Pretty a set -- while we already pretty eagerly expand sets with more than one element, @@ -457,7 +457,7 @@ instance Pretty Expression where inPart = groupWithStart (Ann [] in_ Nothing) $ hardline -- Take our trailing and inject it between `in` and body <> pretty (concat binderComments ++ leading ++ convertTrailing trailing') - <> pretty expr <> hardline + <> pretty expr pretty (Assert assert cond semicolon expr) = base (pretty assert <> hardspace @@ -465,11 +465,16 @@ instance Pretty Expression where <> absorbSet expr pretty (If if_ cond then_ expr0 else_ expr1) - = base $ group $ + = base $ group' False $ -- `if cond then` if it fits on one line, otherwise `if\n cond\nthen` (with cond indented) groupWithStart 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 @@ -519,8 +524,8 @@ instance Pretty Expression where -- Extract comment before the first operand and move it out, to prevent force-expanding the expression (operationWithoutComment, comment') = mapFirstToken' (\(Ann leading token trailing') -> (Ann [] token trailing', leading)) operation in - pretty comment' <> (group $ - (concat . map prettyOperation . (flatten Nothing)) operationWithoutComment) + pretty comment' <> (group' False $ + ((concat . map prettyOperation . (flatten Nothing)) operationWithoutComment) <> line') pretty (MemberCheck expr qmark sel) = pretty expr <> softline diff --git a/test/diff/apply/out.nix b/test/diff/apply/out.nix index a5e18adb..b8788974 100644 --- a/test/diff/apply/out.nix +++ b/test/diff/apply/out.nix @@ -133,8 +133,7 @@ asdf = 1; # multiline } - argument - ; + argument; name3 = function arg @@ -143,8 +142,7 @@ # multiline } { qwer = 12345; } - argument - ; + argument; } { name4 = @@ -153,8 +151,7 @@ qwer = 12345; qwer2 = 54321; } - argument - ; + argument; } { option1 = @@ -163,8 +160,7 @@ qwer = 12345; qwer2 = 54321; } - lastArg - ; + lastArg; option2 = function arg { asdf = 1; } @@ -172,8 +168,7 @@ qwer = 12345; qwer2 = 54321; } - lastArg - ; + lastArg; option3 = function arg { asdf = 1; } @@ -181,16 +176,14 @@ qwer = 12345; qwer2 = 54321; } - lastArg - ; + lastArg; } # https://github.com/kamadorueda/alejandra/issues/372#issuecomment-1435083516 { outputs = { utils }: # For each supported platform, - utils.lib.eachDefaultSystem (system: { }) - ; + utils.lib.eachDefaultSystem (system: { }); } { escapeSingleline = libStr.escape [ @@ -207,8 +200,7 @@ [ "''\${" "'''" - ] - ; + ]; test = foo [ @@ -224,8 +216,7 @@ 1 2 3 # multiline - ] - ; + ]; looooooooong = (toINI { @@ -248,8 +239,7 @@ aaaaaaaa ; } - sections - ; + sections; } # Test breakup behavior at different line lengths @@ -347,7 +337,6 @@ (lib.take 3) # Quote all entries (map (x: ''"'' + x + ''"'')) - ] - ; + ]; } ] diff --git a/test/diff/attr_set/out.nix b/test/diff/attr_set/out.nix index e7eee7fa..ea7022bd 100644 --- a/test/diff/attr_set/out.nix +++ b/test/diff/attr_set/out.nix @@ -117,8 +117,7 @@ [ # several items - ] - ; + ]; a = [ some @@ -180,8 +179,7 @@ secret-config.ssh-hosts // { foo = "bar"; - } - ; + }; programs.ssh.knownHosts2 = someStuff // @@ -212,8 +210,7 @@ ) // { foo = "bar"; - } - ; + }; programs.ssh.knownHosts4 = someStuff // lib.mapAttrs ( @@ -253,8 +250,7 @@ "${host_name}.lo.m-0.eu" ]; }) - secret-config.ssh-hosts - ; + secret-config.ssh-hosts; programs.ssh.knownHosts7 = someStuff # multiline // lib.mapAttrs ( @@ -278,8 +274,7 @@ "${host_name}.lo.m-0.eu" ]; }) - secret-config.ssh-hosts - ; + secret-config.ssh-hosts; programs.ssh.knownHosts9 = { multi = 1; @@ -294,8 +289,7 @@ "${host_name}.lo.m-0.eu" ]; } - ) - ; + ); programs.ssh.knownHosts10 = { multi = 1; @@ -310,7 +304,6 @@ "${host_name}.lo.m-0.eu" ]; }) - secret-config.ssh-hosts - ; + secret-config.ssh-hosts; } ] diff --git a/test/diff/idioms_lib_1/out.nix b/test/diff/idioms_lib_1/out.nix index c1013cf2..3c4520d9 100644 --- a/test/diff/idioms_lib_1/out.nix +++ b/test/diff/idioms_lib_1/out.nix @@ -6,6 +6,5 @@ msg: # Value to return x: - if pred then trace msg x else x - ; + if pred then trace msg x else x; } diff --git a/test/diff/idioms_lib_2/out.nix b/test/diff/idioms_lib_2/out.nix index 2ec1b7a9..b3307ded 100644 --- a/test/diff/idioms_lib_2/out.nix +++ b/test/diff/idioms_lib_2/out.nix @@ -12,8 +12,7 @@ rec { id = # The value to return x: - x - ; + x; /* The constant function @@ -30,8 +29,7 @@ rec { x: # Value to ignore y: - x - ; + x; /* Pipes a value through a list of functions, left to right. @@ -67,8 +65,7 @@ rec { let reverseApply = x: f: f x; in - builtins.foldl' reverseApply val functions - ; + builtins.foldl' reverseApply val functions; # note please don’t add a function like `compose = flip pipe`. # This would confuse users, because the order of the functions @@ -133,8 +130,7 @@ rec { x: # Right attribute set (higher precedence for equal keys) y: - x // y - ; + x // y; /* Flip the order of the arguments of a binary function. @@ -146,8 +142,7 @@ rec { */ flip = f: a: b: - f b a - ; + f b a; /* Apply function if the supplied argument is non-null. @@ -162,8 +157,7 @@ rec { f: # Argument to check for null before passing it to `f` a: - if a == null then a else f a - ; + if a == null then a else f a; # Pull in some builtins not included elsewhere. inherit (builtins) @@ -200,7 +194,10 @@ rec { let suffixFile = ../.version-suffix; in - if pathExists suffixFile then lib.strings.fileContents suffixFile else "pre-git" + if pathExists suffixFile then + lib.strings.fileContents suffixFile + else + "pre-git" ; /* Attempts to return the the current revision of nixpkgs and @@ -225,8 +222,7 @@ rec { nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" - version - ; + version; /* Determine whether the function is being called from inside a Nix shell. @@ -406,8 +402,7 @@ rec { builtins.concatStringsSep ", " (builtins.map builtins.toString unexpected) } unexpected; valid ones: ${ builtins.concatStringsSep ", " (builtins.map builtins.toString valid) - }" - ; + }"; info = msg: builtins.trace "INFO: ${msg}"; @@ -479,8 +474,7 @@ rec { .${toString d} ; in - lib.concatMapStrings toHexDigit (toBaseDigits 16 i) - ; + lib.concatMapStrings toHexDigit (toBaseDigits 16 i); /* `toBaseDigits base i` converts the positive integer i to a list of its digits in the given base. For example: @@ -508,6 +502,5 @@ rec { in assert (base >= 2); assert (i >= 0); - lib.reverseList (go i) - ; + lib.reverseList (go i); } diff --git a/test/diff/idioms_lib_3/out.nix b/test/diff/idioms_lib_3/out.nix index d1e77fba..cef667ca 100644 --- a/test/diff/idioms_lib_3/out.nix +++ b/test/diff/idioms_lib_3/out.nix @@ -36,8 +36,7 @@ rec { t: v: abort ( "generators.mkValueStringDefault: " + "${t} not supported: ${toPretty { } v}" - ) - ; + ); in if isInt v then toString v @@ -86,8 +85,7 @@ rec { mkValueString ? mkValueStringDefault { }, }: sep: k: v: - "${libStr.escape [ sep ] k}${sep}${mkValueString v}" - ; + "${libStr.escape [ sep ] k}${sep}${mkValueString v}"; ## -- FILE FORMAT GENERATORS -- @@ -109,8 +107,7 @@ rec { ; in attrs: - libStr.concatStrings (lib.concatLists (libAttr.mapAttrsToList mkLines attrs)) - ; + libStr.concatStrings (lib.concatLists (libAttr.mapAttrsToList mkLines attrs)); # Generate an INI-style config file from an # attrset of sections to an attrset of key-value pairs. @@ -153,8 +150,7 @@ rec { # map function to string for each key val mapAttrsToStringsSep = sep: mapFn: attrs: - libStr.concatStringsSep sep (libAttr.mapAttrsToList mapFn attrs) - ; + libStr.concatStringsSep sep (libAttr.mapAttrsToList mapFn attrs); mkSection = sectName: sectValues: '' @@ -164,8 +160,7 @@ rec { ; in # map input to ini sections - mapAttrsToStringsSep "\n" mkSection attrsOfAttrs - ; + mapAttrsToStringsSep "\n" mkSection attrsOfAttrs; # Generate an INI-style config file from an attrset # specifying the global section (no header), and an @@ -266,8 +261,7 @@ rec { let mkKeyValue = mkKeyValueDefault { } " = " k; in - concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (lib.toList v)) - ; + concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (lib.toList v)); # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI gitFlattenAttrs = @@ -283,13 +277,11 @@ rec { ; in attrs: - lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs)) - ; + lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs)); toINI_ = toINI { inherit mkKeyValue mkSectionName; }; in - toINI_ (gitFlattenAttrs attrs) - ; + toINI_ (gitFlattenAttrs attrs); # Generates JSON from an arbitrary (non-function) value. # For more information see the documentation of the builtin. @@ -345,8 +337,7 @@ rec { transform (depth + 1) v ; in - mapAny 0 - ; + mapAny 0; # Pretty print a value, akin to `builtins.trace`. # Should probably be a builtin as well. @@ -412,8 +403,7 @@ rec { [ "''\${" "'''" - ] - ; + ]; singlelineResult = ''"'' + concatStringsSep "\\n" (map escapeSingleline lines) + ''"''; multilineResult = @@ -486,8 +476,7 @@ rec { abort "generators.toPretty: should never happen (v = ${v})" ; in - go indent - ; + go indent; # PLIST handling toPlist = @@ -534,8 +523,7 @@ rec { (literal ind "") (item ind x) (literal ind "") - ] - ; + ]; attrs = ind: x: @@ -543,8 +531,7 @@ rec { (literal ind "") (attr ind x) (literal ind "") - ] - ; + ]; attr = let @@ -563,16 +550,14 @@ rec { ) x ) - ) - ; + ); in '' ${expr "" v} - '' - ; + ''; # Translate a simple Nix expression to Dhall notation. # Note that integers are translated to Integer and never diff --git a/test/diff/idioms_lib_4/out.nix b/test/diff/idioms_lib_4/out.nix index fcdf59ff..b3117bf9 100644 --- a/test/diff/idioms_lib_4/out.nix +++ b/test/diff/idioms_lib_4/out.nix @@ -30,8 +30,7 @@ let name: value: assert type.check value; setType type.name ({ inherit name; } // value) - ) - ; + ); in rec { @@ -359,8 +358,7 @@ rec { significantByte = littleEndian; family = "javascript"; }; - } - ; + }; # GNU build systems assume that older NetBSD architectures are using a.out. gnuNetBSDDefaultExecFormat = @@ -444,8 +442,7 @@ rec { # identity (b == a) - ] - ; + ]; ################################################################################ @@ -742,8 +739,7 @@ rec { mkSystem = components: assert types.parsedPlatform.check components; - setType "system" components - ; + setType "system" components; mkSkeletonFromList = l: @@ -839,9 +835,9 @@ rec { abi = elemAt l 3; }; } - .${toString (length l)} - or (throw "system string has invalid number of hyphen-separated components") - ; + .${toString (length l)} or (throw + "system string has invalid number of hyphen-separated components" + ); # This should revert the job done by config.guess from the gcc compiler. mkSystemFromSkeleton = @@ -901,8 +897,7 @@ rec { ; }; in - mkSystem parsed - ; + mkSystem parsed; mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s)); @@ -937,12 +932,10 @@ rec { optExecFormat = lib.optionalString (kernel.name == "netbsd" && gnuNetBSDDefaultExecFormat cpu != kernel.execFormat) - kernel.execFormat.name - ; + kernel.execFormat.name; optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}"; in - "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}" - ; + "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; ################################################################################ } diff --git a/test/diff/idioms_lib_5/out.nix b/test/diff/idioms_lib_5/out.nix index a5e9ece1..62189229 100644 --- a/test/diff/idioms_lib_5/out.nix +++ b/test/diff/idioms_lib_5/out.nix @@ -19,8 +19,7 @@ let attrs: attrs.name or ( "${attrs.pname or "«name-missing»"}-${attrs.version or "«version-missing»"}" - ) - ; + ); allowUnfree = config.allowUnfree || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"; @@ -29,8 +28,7 @@ let let envVar = builtins.getEnv "NIXPKGS_ALLOW_NONSOURCE"; in - if envVar != "" then envVar != "0" else config.allowNonSource or true - ; + if envVar != "" then envVar != "0" else config.allowNonSource or true; allowlist = config.allowlistedLicenses or config.whitelistedLicenses or [ ]; blocklist = config.blocklistedLicenses or config.blacklistedLicenses or [ ]; @@ -115,8 +113,7 @@ let hasNonSourceProvenance = attrs: - (attrs ? meta.sourceProvenance) && isNonSource attrs.meta.sourceProvenance - ; + (attrs ? meta.sourceProvenance) && isNonSource attrs.meta.sourceProvenance; # Allow granular checks to allow only some non-source-built packages # Example: @@ -167,8 +164,7 @@ let UnsupportedSystem = "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM"; NonSource = "NIXPKGS_ALLOW_NONSOURCE"; } - .${allow_attr} - ; + .${allow_attr}; remediation_phrase = allow_attr: { @@ -177,8 +173,7 @@ let UnsupportedSystem = "packages that are unsupported for this system"; NonSource = "packages not built from source"; } - .${allow_attr} - ; + .${allow_attr}; remediate_predicate = predicateConfigAttr: attrs: '' Alternatively you can configure a predicate to allow specific packages: @@ -257,8 +252,7 @@ let actualOutputs = attrs.outputs or [ "out" ]; missingOutputs = builtins.filter (output: !builtins.elem output actualOutputs) - expectedOutputs - ; + expectedOutputs; in '' The package ${getName attrs} has set meta.outputsToInstall to: ${ @@ -272,8 +266,7 @@ let and is missing the following ouputs: ${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)} - '' - ; + ''; handleEvalIssue = { meta, attrs }: @@ -296,8 +289,7 @@ let handler = if config ? handleEvalIssue then config.handleEvalIssue reason else throw; in - handler msg - ; + handler msg; handleEvalWarning = { meta, attrs }: @@ -318,8 +310,7 @@ let ; isEnabled = lib.findFirst (x: x == reason) null showWarnings; in - if isEnabled != null then builtins.trace msg true else true - ; + if isEnabled != null then builtins.trace msg true else true; # Deep type-checking. Note that calling `type.check` is not enough: see `lib.mkOptionType`'s documentation. # We don't include this in lib for now because this function is flawed: it accepts things like `mkIf true 42`. @@ -332,8 +323,7 @@ let } ]; eval = builtins.tryEval (builtins.deepSeq merged.mergedValue null); in - eval.success - ; + eval.success; # TODO make this into a proper module and use the generic option documentation generation? metaTypes = with lib.types; rec { @@ -349,8 +339,7 @@ let let licenseType = either (attrsOf anything) str; # TODO disallow `str` licenses, use a module in - either licenseType (listOf licenseType) - ; + either licenseType (listOf licenseType); sourceProvenance = listOf lib.types.attrs; maintainers = listOf (attrsOf anything); # TODO use the maintainer type from lib/tests/maintainer-module.nix priority = int; @@ -418,8 +407,7 @@ let meta: lib.optionals config.checkMeta ( lib.remove null (lib.mapAttrsToList checkMetaAttr meta) - ) - ; + ); checkOutputsToInstall = attrs: @@ -428,11 +416,9 @@ let actualOutputs = attrs.outputs or [ "out" ]; missingOutputs = builtins.filter (output: !builtins.elem output actualOutputs) - expectedOutputs - ; + expectedOutputs; in - if config.checkMeta then builtins.length missingOutputs > 0 else false - ; + if config.checkMeta then builtins.length missingOutputs > 0 else false; # Check if a derivation is valid, that is whether it passes checks for # e.g brokenness or license. diff --git a/test/diff/idioms_nixos_1/out.nix b/test/diff/idioms_nixos_1/out.nix index bcc39b22..497dd313 100644 --- a/test/diff/idioms_nixos_1/out.nix +++ b/test/diff/idioms_nixos_1/out.nix @@ -54,8 +54,7 @@ in } ); } - ) - ; + ); # We don't want to evaluate all of linuxPackages for the manual # - some of it might not even evaluate correctly. defaultText = literalExpression "pkgs.linuxPackages"; @@ -275,16 +274,14 @@ in # x86 RTC needed by the stage 2 init script. "rtc_cmos" ] - ) - ; + ); boot.initrd.kernelModules = optionals config.boot.initrd.includeDefaultModules [ # For LVM. "dm_mod" - ] - ; + ]; }) (mkIf (!config.boot.isContainer) { @@ -301,8 +298,7 @@ in ++ optionals config.boot.vesa [ "vga=0x317" "nomodeset" - ] - ; + ]; boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel; diff --git a/test/diff/idioms_nixos_2/out.nix b/test/diff/idioms_nixos_2/out.nix index cb1cd615..d1baf0ef 100644 --- a/test/diff/idioms_nixos_2/out.nix +++ b/test/diff/idioms_nixos_2/out.nix @@ -52,8 +52,7 @@ let post_max_size = cfg.maxUploadSize; memory_limit = cfg.maxUploadSize; } - // cfg.phpOptions // optionalAttrs cfg.caching.apcu { "apc.enable_cli" = "1"; } - ; + // cfg.phpOptions // optionalAttrs cfg.caching.apcu { "apc.enable_cli" = "1"; }; occ = pkgs.writeScriptBin "nextcloud-occ" '' #! ${pkgs.runtimeShell} @@ -344,8 +343,7 @@ in int bool ] - ) - ; + ); default = { "pm" = "dynamic"; "pm.max_children" = "32"; @@ -625,8 +623,7 @@ in ) // { default = true; - } - ; + }; caching = { apcu = mkOption { @@ -824,8 +821,7 @@ in nextcloud25 else nextcloud26 - ) - ; + ); services.nextcloud.phpPackage = if versionOlder cfg.package.version "26" then pkgs.php81 else pkgs.php82; @@ -884,16 +880,14 @@ in } ], ] - '' - ; + ''; showAppStoreSetting = cfg.appstoreEnable != null || cfg.extraApps != { }; renderedAppStoreSetting = let x = cfg.appstoreEnable; in - if x == null then "false" else boolToString x - ; + if x == null then "false" else boolToString x; nextcloudGreaterOrEqualThan = req: versionAtLeast cfg.package.version req; @@ -1025,8 +1019,7 @@ in ${mkExport adminpass} ${occ}/bin/nextcloud-occ maintenance:install \ ${installFlags} - '' - ; + ''; occSetTrustedDomainsCmd = concatStringsSep "\n" ( imap0 (i: v: '' @@ -1107,10 +1100,8 @@ in # an automatic creation of the database user. environment.NC_setup_create_db_user = lib.mkIf (nextcloudGreaterOrEqualThan "26") - "false" - ; - } - ; + "false"; + }; nextcloud-cron = { after = [ "nextcloud-setup.service" ]; environment.NEXTCLOUD_CONFIG_DIR = "${datadir}/config"; diff --git a/test/diff/idioms_pkgs_2/out.nix b/test/diff/idioms_pkgs_2/out.nix index 4b3f8f19..84f50d54 100644 --- a/test/diff/idioms_pkgs_2/out.nix +++ b/test/diff/idioms_pkgs_2/out.nix @@ -25,8 +25,7 @@ stdenv.mkDerivation rec { invariant-under-noXlibs = testEqualDerivation "hello must not be rebuilt when environment.noXlibs is set." hello - (nixos { environment.noXlibs = true; }).pkgs.hello - ; + (nixos { environment.noXlibs = true; }).pkgs.hello; }; meta = with lib; { diff --git a/test/diff/idioms_pkgs_3/out.nix b/test/diff/idioms_pkgs_3/out.nix index 62aea42f..0c64ad51 100644 --- a/test/diff/idioms_pkgs_3/out.nix +++ b/test/diff/idioms_pkgs_3/out.nix @@ -155,7 +155,8 @@ 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; diff --git a/test/diff/idioms_pkgs_4/out.nix b/test/diff/idioms_pkgs_4/out.nix index 95551743..99d6bfa8 100644 --- a/test/diff/idioms_pkgs_4/out.nix +++ b/test/diff/idioms_pkgs_4/out.nix @@ -91,8 +91,7 @@ let [ ../cygwin/rebase-x86_64.sh ] else [ ] - ) - ; + ); # A function that builds a "native" stdenv (one that uses tools in # /usr etc.). @@ -149,8 +148,7 @@ let overrides config ; - } - ; + }; in [ @@ -188,8 +186,7 @@ in nativeLibc = true; }; inherit stdenvNoCC; - } - ; + }; fetchurl = import ../../build-support/fetchurl { inherit lib stdenvNoCC; diff --git a/test/diff/let_in/out.nix b/test/diff/let_in/out.nix index e9a4b377..2ad06c03 100644 --- a/test/diff/let_in/out.nix +++ b/test/diff/let_in/out.nix @@ -5,62 +5,53 @@ let b = 2; c = 3; in - d - ; + d; a = let c = 1; in - f - ; + f; a = let c = 1; in # e - f - ; + f; a = let c = 1; # d in - f - ; + f; a = let c = 1; # d in # e - f - ; + f; a = let # b c = 1; in - f - ; + f; a = let # b c = 1; in # e - f - ; + f; a = let # b c = 1; # d in - f - ; + f; a = let # b c = 1; # d in # e - f - ; + f; a = let @@ -68,8 +59,7 @@ let [ 1 2 - ] - ; + ]; in a diff --git a/test/diff/monsters_1/out.nix b/test/diff/monsters_1/out.nix index 2e38f998..7602ee82 100644 --- a/test/diff/monsters_1/out.nix +++ b/test/diff/monsters_1/out.nix @@ -126,8 +126,7 @@ stdenv.mkDerivation # foo "cypSbqLwSmauOoWOuppWpF3hvrxiqmkLspxAWzvlUC0="; # foo - } - ; + }; # foo cargoDeps # foo @@ -154,8 +153,7 @@ stdenv.mkDerivation # foo "sha256-W4FyqwJpimf0isQRCq9TegpTQPQfsumx40AFQCFG5VQ="; # foo - } - ; + }; # foo nativeBuildInputs # foo diff --git a/test/diff/monsters_4/out.nix b/test/diff/monsters_4/out.nix index e8d6cedc..71d0fdc7 100644 --- a/test/diff/monsters_4/out.nix +++ b/test/diff/monsters_4/out.nix @@ -64,8 +64,7 @@ stdenv.mkDerivation # Foo sha256 # Foo = # Foo "cypSbqLwSmauOoWOuppWpF3hvrxiqmkLspxAWzvlUC0="; # Foo - } - ; # Foo + }; # Foo cargoDeps # Foo = # Foo rustPlatform.fetchCargoTarball # Foo @@ -80,8 +79,7 @@ stdenv.mkDerivation # Foo hash # Foo = # Foo "sha256-W4FyqwJpimf0isQRCq9TegpTQPQfsumx40AFQCFG5VQ="; # Foo - } - ; # Foo + }; # Foo nativeBuildInputs # Foo = # Foo [ @@ -139,8 +137,7 @@ stdenv.mkDerivation # Foo [ # Foo jtojnar # Foo - ] - ; # Foo + ]; # Foo platforms # Foo = # Foo platforms.unix; # Foo diff --git a/test/diff/monsters_5/out.nix b/test/diff/monsters_5/out.nix index 3987bb48..59a5a6ee 100644 --- a/test/diff/monsters_5/out.nix +++ b/test/diff/monsters_5/out.nix @@ -49,8 +49,7 @@ let '' ${concatStringsSep "\n" config.boot.kernelModules} - '' - ; + ''; in { @@ -83,8 +82,7 @@ in literalExpression - "{debug= true;}" - ; + "{debug= true;}"; internal @@ -103,8 +101,7 @@ in which would have separate nixos options. `grep features pkgs/os-specific/linux/kernel/common-config.nix` ''; - } - ; + }; boot.kernelPackages @@ -193,14 +190,11 @@ in super.kernel.features - features - ; + features; } - ) - ; + ); } - ) - ; + ); # We don't want to evaluate all of linuxPackages for the manual # - some of it might not even evaluate correctly. @@ -211,8 +205,7 @@ in literalExpression - "pkgs.linuxPackages" - ; + "pkgs.linuxPackages"; example @@ -220,8 +213,7 @@ in literalExpression - "pkgs.linuxKernel.packages.linux_5_10" - ; + "pkgs.linuxKernel.packages.linux_5_10"; description @@ -239,8 +231,7 @@ in then it also needs to contain an attribute nvidia_x11. ''; - } - ; + }; boot.kernelPatches @@ -256,8 +247,7 @@ in types.listOf - types.attrs - ; + types.attrs; default @@ -271,10 +261,8 @@ in literalExpression - "[ pkgs.kernelPatches.ubuntu_fan_4_4 ]" - ; + "[ pkgs.kernelPatches.ubuntu_fan_4_4 ]"; description = "A list of additional patches to apply to the kernel."; - } - ; + }; }; } diff --git a/test/diff/with/out.nix b/test/diff/with/out.nix index f2ca1004..413c3b48 100644 --- a/test/diff/with/out.nix +++ b/test/diff/with/out.nix @@ -30,8 +30,7 @@ a = with b; # comment - 1 - ; + 1; } { a = with b; 1; @@ -61,7 +60,6 @@ makeBinPath ([ rsync util-linux - ]) - ; + ]); } ]