From 0c3ca2bf16f0d21f13147b52b219db6587b6f89d Mon Sep 17 00:00:00 2001 From: KFears Date: Sat, 21 Sep 2024 01:07:23 +0400 Subject: [PATCH] [DetSys#1182] treewide: add editorconfig and fix This commit isn't cherry-picked from upstream. Instead, the .editorconfig file was copied as-is from the upstream PR. Then, `eclint -fix .` was ran to make everything conform to editorconfig. This should be identical in impact, but it saves a lot of headache from resolving useless merge conflicts. Upstream-PR: https://github.com/DeterminateSystems/nix-installer/pull/1182 Change-Id: I22f03d18b3d685ff16b08bf8df0720e0f796d501 --- .cargo/config.toml | 2 +- .dockerignore | 2 +- .editorconfig | 42 +++++++++++++++++++++++++++ .envrc | 2 +- CONTRIBUTING.md | 6 ++-- LICENSE | 2 +- README.md | 2 +- build-all.xsh | 6 ++-- rust-toolchain.toml | 2 +- src/action/linux/selinux/README.md | 2 +- src/action/linux/selinux/build.sh | 2 +- src/action/linux/selinux/nix.fc | 2 +- src/action/linux/selinux/nix.te | 2 +- src/action/macos/create_nix_volume.rs | 2 +- src/action/mod.rs | 2 +- src/cli/subcommand/install.rs | 4 +-- src/cli/subcommand/uninstall.rs | 2 +- src/error.rs | 6 ++-- tests/windows/test-wsl.ps1 | 18 ++++++------ upload-to-lix.xsh | 8 ++--- 20 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 .editorconfig diff --git a/.cargo/config.toml b/.cargo/config.toml index c19c930..5deba45 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ [build] -rustflags=["--cfg", "tokio_unstable"] \ No newline at end of file +rustflags=["--cfg", "tokio_unstable"] diff --git a/.dockerignore b/.dockerignore index 1de5659..eb5a316 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1 @@ -target \ No newline at end of file +target diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bc80073 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,42 @@ +root = true + +# Unix-style newlines with a newline ending every file, utf-8 charset +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# Rust +[*.rs] +indent_style = space + +# Misc +[*.{yaml,yml,nix,json,sh,service,socket,toml,te}] +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.md] +insert_final_newline = true +indent_style = space + +[*.plist] +indent_style = tab + +[*.ps1] +indent_style = space +indent_size = 4 + +[Cargo.lock] +indent_style = space +indent_size = 1 + +# selinux +[*.pp] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = unset +trim_trailing_whitespace = unset diff --git a/.envrc b/.envrc index 8392d15..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake \ No newline at end of file +use flake diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37b37d9..e00840a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,7 +142,7 @@ In general, it's a good idea to test on the closest you can get to the desired t
Adding a planner for specific hardware? -Please include an full guide on how to create the best known virtual testing environment for that device. +Please include an full guide on how to create the best known virtual testing environment for that device. **A link is not sufficient, it may break.** Please provide a full summary of steps to take, link to any original source and give them credit if it is appropriate. @@ -200,7 +200,7 @@ nix build .#hydraJobs.vm-test.rhel-v7.x86_64-linux.all -L -j 4
Adding a distro? -Notice how `rhel-v7` has a `v7`, not just `7`? That's so the test output shows correctly, as Nix will interpret the first `-\d` (eg `-7`, `-123213`) as a version, and not show it in the output. +Notice how `rhel-v7` has a `v7`, not just `7`? That's so the test output shows correctly, as Nix will interpret the first `-\d` (eg `-7`, `-123213`) as a version, and not show it in the output. Using `v7` instead turns: @@ -284,7 +284,7 @@ nix build .#hydraJobs.container-test.ubuntu-v22_04.x86_64-linux.docker -L
Adding a distro? -Notice how `ubuntu-v20_02` has a `v20`, not just `20`? That's so the test output shows correctly, as Nix will interpret the first `-\d` (eg `-20`, `-123213`) as a version, and not show it in the output. +Notice how `ubuntu-v20_02` has a `v20`, not just `20`? That's so the test output shows correctly, as Nix will interpret the first `-\d` (eg `-20`, `-123213`) as a version, and not show it in the output. Using `v20` instead turns: diff --git a/LICENSE b/LICENSE index 5ab7695..602bfc9 100644 --- a/LICENSE +++ b/LICENSE @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an diff --git a/README.md b/README.md index ded6f1e..2053b03 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The Lix Installer -A fast, friendly, and reliable tool to help you use Lix, the community implementation of the nix tooling. +A fast, friendly, and reliable tool to help you use Lix, the community implementation of the nix tooling. Based on the [Determinate Installer](https://install.determinate.systems). diff --git a/build-all.xsh b/build-all.xsh index 9ab3e89..809179f 100755 --- a/build-all.xsh +++ b/build-all.xsh @@ -1,6 +1,6 @@ #! /usr/bin/env nix-shell #! nix-shell -i xonsh -p xonsh rustup cargo-zigbuild zig -# +# # vim: ts=4 sw=4 et # # If the shebang line above was necessary, you probably should have used @@ -45,7 +45,7 @@ for platform in TARGET_PLATFORMS: if platform not in $(rustup target list --installed): printerr(f"ERROR: You don't have a rustup toolchain for {platform}! Install it with `rustup target add {platform}`") all_targets_present = False - + if not all_targets_present: printerr("Failing out; install the platforms above and retry.") sys.exit(-2) @@ -54,7 +54,7 @@ if not all_targets_present: printerr("> Building any platforms that need updating.") for platform in TARGET_PLATFORMS: - # Build... + # Build... printerr(f"> Building for target {platform}") cargo zigbuild --quiet --release --target=@(platform) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ffa1197..9993e93 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] channel = "stable" -components = [ "rustfmt" ] \ No newline at end of file +components = [ "rustfmt" ] diff --git a/src/action/linux/selinux/README.md b/src/action/linux/selinux/README.md index 9da2f85..d7e3b10 100644 --- a/src/action/linux/selinux/README.md +++ b/src/action/linux/selinux/README.md @@ -6,4 +6,4 @@ To refresh the output `pp` file: ## Method -We use the same method and definitions as https://github.com/nix-community/nix-installers/tree/master/selinux. \ No newline at end of file +We use the same method and definitions as https://github.com/nix-community/nix-installers/tree/master/selinux. diff --git a/src/action/linux/selinux/build.sh b/src/action/linux/selinux/build.sh index b44b15f..13076c7 100755 --- a/src/action/linux/selinux/build.sh +++ b/src/action/linux/selinux/build.sh @@ -2,4 +2,4 @@ #! nix-shell -i bash ../../../../shell.nix checkmodule -M -m -c 5 -o nix.mod nix.te -semodule_package -o nix.pp -m nix.mod -f nix.fc \ No newline at end of file +semodule_package -o nix.pp -m nix.mod -f nix.fc diff --git a/src/action/linux/selinux/nix.fc b/src/action/linux/selinux/nix.fc index 32cc479..85de520 100644 --- a/src/action/linux/selinux/nix.fc +++ b/src/action/linux/selinux/nix.fc @@ -5,4 +5,4 @@ /nix/store/[^/]+/etc(/.*)? system_u:object_r:etc_t:s0 /nix/store/[^/]+/share(/.*)? system_u:object_r:usr_t:s0 /nix/var/nix/daemon-socket(/.*)? system_u:object_r:var_run_t:s0 -/nix/var/nix/profiles(/per-user/[^/]+)?/[^/]+ system_u:object_r:usr_t:s0 \ No newline at end of file +/nix/var/nix/profiles(/per-user/[^/]+)?/[^/]+ system_u:object_r:usr_t:s0 diff --git a/src/action/linux/selinux/nix.te b/src/action/linux/selinux/nix.te index f8ea7b1..00b4077 100644 --- a/src/action/linux/selinux/nix.te +++ b/src/action/linux/selinux/nix.te @@ -8,4 +8,4 @@ require { type etc_t; type var_run_t; type systemd_unit_file_t; -} \ No newline at end of file +} diff --git a/src/action/macos/create_nix_volume.rs b/src/action/macos/create_nix_volume.rs index 9c4fec5..7a12547 100644 --- a/src/action/macos/create_nix_volume.rs +++ b/src/action/macos/create_nix_volume.rs @@ -128,7 +128,7 @@ impl Action for CreateNixVolume { fn tracing_synopsis(&self) -> String { format!( "Create an{maybe_encrypted} APFS volume `{name}` for Nix on `{disk}` and add it to `/etc/fstab` mounting on `/nix`", - maybe_encrypted = if self.encrypt { " encrypted" } else { "" }, + maybe_encrypted = if self.encrypt { " encrypted" } else { "" }, name = self.name, disk = self.disk.display(), ) diff --git a/src/action/mod.rs b/src/action/mod.rs index 74b277b..d23103f 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -353,7 +353,7 @@ pub enum ActionErrorKind { if let Some(source) = err.source() { format!("{err}\n{source}\n") } else { - format!("{err}\n") + format!("{err}\n") } }).collect::>().join("\n"))] MultipleChildren(Vec), diff --git a/src/cli/subcommand/install.rs b/src/cli/subcommand/install.rs index 1764db0..5c71d3b 100644 --- a/src/cli/subcommand/install.rs +++ b/src/cli/subcommand/install.rs @@ -127,7 +127,7 @@ impl CommandExecute for Install { Some(existing_receipt) => { if let Err(e) = existing_receipt.check_compatible() { eprintln!( - "{}", + "{}", format!("\ {e}\n\ \n\ @@ -210,7 +210,7 @@ impl CommandExecute for Install { Some(existing_receipt) => { if let Err(e) = existing_receipt.check_compatible() { eprintln!( - "{}", + "{}", format!("\ {e}\n\ \n\ diff --git a/src/cli/subcommand/uninstall.rs b/src/cli/subcommand/uninstall.rs index 3de52ab..c23b84d 100644 --- a/src/cli/subcommand/uninstall.rs +++ b/src/cli/subcommand/uninstall.rs @@ -141,7 +141,7 @@ impl CommandExecute for Uninstall { if let Err(e) = plan.check_compatible() { let version = plan.version; eprintln!( - "{}", + "{}", format!("\ {e}\n\ \n\ diff --git a/src/error.rs b/src/error.rs index 26225b3..bc1787e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -19,7 +19,7 @@ pub enum NixInstallerError { if let Some(source) = err.source() { format!("{err}\n{source}\n") } else { - format!("{err}\n") + format!("{err}\n") } }).collect::>().join("\n"))] SelfTest(Vec), @@ -28,7 +28,7 @@ pub enum NixInstallerError { if let Some(source) = err.source() { format!("{err}\n{source}\n") } else { - format!("{err}\n") + format!("{err}\n") } }).collect::>().join("\n"))] ActionRevert(Vec), @@ -109,4 +109,4 @@ impl HasExpectedErrors for NixInstallerError { }, } } -} \ No newline at end of file +} diff --git a/tests/windows/test-wsl.ps1 b/tests/windows/test-wsl.ps1 index cc7c42f..b3ab958 100644 --- a/tests/windows/test-wsl.ps1 +++ b/tests/windows/test-wsl.ps1 @@ -24,21 +24,21 @@ $InstallRoot = "$TemporaryDirectory\wsl-$Name" Write-Output "Creating WSL distribution $DistroName from $Image at $InstallRoot..." wsl --import $DistroName $InstallRoot $Image if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } Write-Output "Preparing $DistroName for nix-installer..." wsl --distribution $DistroName bash --login -c "apt update --quiet" if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } wsl --distribution $DistroName bash --login -c "apt install --quiet --yes curl build-essential" if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } wsl --distribution $DistroName bash --login -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --quiet" if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } if ($Systemd) { @@ -46,7 +46,7 @@ if ($Systemd) { New-Item -Path "\\wsl$\$DistroName\etc\wsl.conf" -ItemType "file" -Value $wslConf wsl --shutdown if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } } @@ -58,18 +58,18 @@ $MaybeInitChoice = switch ($Systemd) { } wsl --distribution $DistroName bash --login -c "/root/.cargo/bin/cargo run --quiet --manifest-path /nix-installer/Cargo.toml -- install linux --no-confirm $MaybeInitChoice" if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } Write-Output "Testing installed Nix on $DistroName..." wsl --distribution $DistroName bash --login -c "nix run nixpkgs#hello" if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } Write-Output "Unregistering $DistroName and removing $InstallRoot..." wsl --unregister $DistroName if ($LastExitCode -ne 0) { - exit $LastExitCode + exit $LastExitCode } -Remove-Item $InstallRoot \ No newline at end of file +Remove-Item $InstallRoot diff --git a/upload-to-lix.xsh b/upload-to-lix.xsh index 8d7a520..7582f9a 100755 --- a/upload-to-lix.xsh +++ b/upload-to-lix.xsh @@ -1,12 +1,12 @@ #! /usr/bin/env nix-shell #! nix-shell -i xonsh -p xonsh awscli2 -# +# # vim: ts=4 sw=4 et # # If the shebang line above was necessary, you probably should have used # the flake, instead. But that's okay! You're valid. <3 # -""" Lix installer uploader. +""" Lix installer uploader. Uploads our installers and install script to an S3 instance. """ @@ -33,7 +33,7 @@ printerr = functools.partial(print, file=sys.stderr) parser = argparse.ArgumentParser(description="upload a lix-installer binary") parser.add_argument("tag", help="the tag name to use while uploading") parser.add_argument("folder", help="the results folder to use for uploading") -parser.add_argument("--make-default", help="makes this version the default for new installations", +parser.add_argument("--make-default", help="makes this version the default for new installations", action="store_true") parser.add_argument("-E", "--endpoint", help="the endpoint URL to use for S3", default="https://s3.lix.systems") parser.add_argument("-R", "--region", help="the region to use for the S3 upload", default="garage") @@ -92,7 +92,7 @@ if tag_exists: $RAISE_SUBPROC_ERROR=True # Copy the core inner pieces... -printerr(f"\n>> Uploading tag '{tag}' from folder '{folder}'.") +printerr(f"\n>> Uploading tag '{tag}' from folder '{folder}'.") for in_filename, out_filename in TARGET_PLATFORMS.items(): aws s3 @(aws_args) cp @(folder)/lix-installer-@(in_filename) @(target_path)/lix-installer-@(out_filename) --acl public-read