[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
This commit is contained in:
KFears 2024-09-21 01:07:23 +04:00
parent be67a8a4e2
commit 0c3ca2bf16
No known key found for this signature in database
20 changed files with 79 additions and 37 deletions

View file

@ -1,2 +1,2 @@
[build]
rustflags=["--cfg", "tokio_unstable"]
rustflags=["--cfg", "tokio_unstable"]

View file

@ -1 +1 @@
target
target

42
.editorconfig Normal file
View file

@ -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

2
.envrc
View file

@ -1 +1 @@
use flake
use flake

View file

@ -142,7 +142,7 @@ In general, it's a good idea to test on the closest you can get to the desired t
<details>
<summary><strong>Adding a planner for specific hardware?</strong></summary>
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
<details>
<summary><strong>Adding a distro?</strong></summary>
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
<details>
<summary><strong>Adding a distro?</strong></summary>
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:

View file

@ -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

View file

@ -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).

View file

@ -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)

View file

@ -1,3 +1,3 @@
[toolchain]
channel = "stable"
components = [ "rustfmt" ]
components = [ "rustfmt" ]

View file

@ -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.
We use the same method and definitions as https://github.com/nix-community/nix-installers/tree/master/selinux.

View file

@ -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
semodule_package -o nix.pp -m nix.mod -f nix.fc

View file

@ -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
/nix/var/nix/profiles(/per-user/[^/]+)?/[^/]+ system_u:object_r:usr_t:s0

View file

@ -8,4 +8,4 @@ require {
type etc_t;
type var_run_t;
type systemd_unit_file_t;
}
}

View file

@ -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(),
)

View file

@ -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::<Vec<_>>().join("\n"))]
MultipleChildren(Vec<ActionError>),

View file

@ -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\

View file

@ -141,7 +141,7 @@ impl CommandExecute for Uninstall {
if let Err(e) = plan.check_compatible() {
let version = plan.version;
eprintln!(
"{}",
"{}",
format!("\
{e}\n\
\n\

View file

@ -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::<Vec<_>>().join("\n"))]
SelfTest(Vec<SelfTestError>),
@ -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::<Vec<_>>().join("\n"))]
ActionRevert(Vec<ActionError>),
@ -109,4 +109,4 @@ impl HasExpectedErrors for NixInstallerError {
},
}
}
}
}

View file

@ -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
Remove-Item $InstallRoot

View file

@ -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