Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorconfig #1182

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
rustflags=["--cfg", "tokio_unstable"]
rustflags=["--cfg", "tokio_unstable"]
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
target
target
42 changes: 42 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use flake
use flake
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.ci-store
.direnv
result*
src/action/linux/selinux/nix.mod
src/action/linux/selinux/nix.mod
116 changes: 51 additions & 65 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,55 @@ contributing to other serious Rust ecosystem projects. You may already know
the process and expectations of you, this document shouldn't contain any
surprises.


# What kinds of contributions are needed?

`nix-installer` can benefit from all kinds of contributions:

* Bug reports
* Code improvements
* Registry additions
* Dependency updates or dependency feature trimming
* New features (Please create an issue first!)
* Documentation
* Graphical/visual asset improvement
* Kind words or recommendation on your own site, repo, stream, or social media
- Bug reports
- Code improvements
- Registry additions
- Dependency updates or dependency feature trimming
- New features (Please create an issue first!)
- Documentation
- Graphical/visual asset improvement
- Kind words or recommendation on your own site, repo, stream, or social media
account
* Onboarding others to using `nix-installer`

- Onboarding others to using `nix-installer`

# What are the expectations you can have of the maintainers?

You can expect us to:

* Follow the [Contributor Covenant](CODE_OF_CONDUCT.md), just like you
* Help diagnose bug reports (for supported platforms using supported
- Follow the [Contributor Covenant](CODE_OF_CONDUCT.md), just like you
- Help diagnose bug reports (for supported platforms using supported
languages)
* Give constructive feedback on pull requests
* Merge pull requests which:
+ Have been approved of by at least 1 maintainer
+ Pass all tests
+ Have no complex conflicts with in-flight high priority work
- Give constructive feedback on pull requests
- Merge pull requests which:
- Have been approved of by at least 1 maintainer
- Pass all tests
- Have no complex conflicts with in-flight high priority work

The maintainers of this project use a separate issue tracker for some internal
tasks. Unfortunately, the contents of this tracker is not publicly visible as
it may contain sensitive or confidential data. Our maintainers will endeavor to
ensure you are not 'left out' of the discussion about your contributions.


# What kind of expectations do the maintainers have from you?

We expect you to:

* Follow the [Contributor Covenant](CODE_OF_CONDUCT.md), just like them
* Make an earnest attempt to follow the contribution process described in this
- Follow the [Contributor Covenant](CODE_OF_CONDUCT.md), just like them
- Make an earnest attempt to follow the contribution process described in this
document
* Update bug reports with a solution, if you find one before we do
* Do your best to follow existing conventions
* Reflect maintainer feedback if you are able
* Declare if you need to abandon a PR so someone else can shepherd it

- Update bug reports with a solution, if you find one before we do
- Do your best to follow existing conventions
- Reflect maintainer feedback if you are able
- Declare if you need to abandon a PR so someone else can shepherd it

# How exactly does the contribution process work?

Here are how to do various kinds of contributions.


## Bug Reports

Create an issue on [the issue page](https://github.com/DeterminateSystems/nix-installer/issues).
Expand All @@ -80,7 +75,6 @@ It should contain:
5. What you expected to happen
6. If you tried to fix it, what did you try?


## Code/Documentation improvement

For **minor** fixes, documentation, or changes which **do not** have a
Expand All @@ -93,13 +87,12 @@ proposing the change is **required** for non-maintainers.

Please:

* Write civil commit messages, it's ok if they are simple like `fmt`
- Write civil commit messages, it's ok if they are simple like `fmt`
or `formatting`
* Follow existing conventions and style within the code the best you can
* Describe in your PR the problem and solution so reviewers don't need to
- Follow existing conventions and style within the code the best you can
- Describe in your PR the problem and solution so reviewers don't need to
rebuild much context
* Run `nix flake check` and `nix build`

- Run `nix flake check` and `nix build`

## Non-code contributions

Expand All @@ -111,7 +104,6 @@ the project.

Some snippets or workflows for development.


## Direnv support

While `nix develop` should work perfectly fine for development, contributors may prefer to enable [`direnv`](https://direnv.net/) or [`nix-direnv`](https://github.com/nix-community/nix-direnv) support.
Expand All @@ -124,9 +116,8 @@ direnv allow

If using an editor, it may be preferable to adopt an addon to enter the environment:

* [`vim`](https://github.com/direnv/direnv.vim)
* [VSCode](https://marketplace.visualstudio.com/items?itemName=mkhl.direnv)

- [`vim`](https://github.com/direnv/direnv.vim)
- [VSCode](https://marketplace.visualstudio.com/items?itemName=mkhl.direnv)

## Testing Installs

Expand All @@ -142,11 +133,10 @@ When running such interactive tests, consider creating a snapshot of the VM righ

In general, it's a good idea to test on the closest you can get to the desired target environment. For example, when testing the Steam Deck planner it's a good idea to run that test in a Steam Deck VM as described in detail in the planner.


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

Expand Down Expand Up @@ -210,7 +200,7 @@ nix build github:determinatesystems/nix-installer/${BRANCH}#hydraJobs.vm-test.ub
<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:

Expand Down Expand Up @@ -242,7 +232,6 @@ installer-test-rhel-v7-install-default> Formatting './disk.qcow2', fmt=qcow2 clu

## Container tests


For x86_64 Linux we have some additional container tests. In `nix/tests/container-test` there exists some Nix derivations which we expose in the flake via `hydraJobs`.

These should be visible in `nix flake show`:
Expand Down Expand Up @@ -278,7 +267,6 @@ git+file:///home/ana/git/determinatesystems/nix-installer

To run all of the currently supported tests:


```bash
nix build .#hydraJobs.container-test.all.x86_64-linux.all -L -j 4
```
Expand All @@ -300,7 +288,7 @@ nix build github:determinatesystems/nix-installer/${BRANCH}#hydraJobs.container-
<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:

Expand Down Expand Up @@ -356,31 +344,29 @@ wsl --unregister nix-installer-test-ubuntu-jammy

You can also remove your `$HOME/nix-installer-wsl-tests-temp` folder whenever you wish.


# Releases


This package uses [Semantic Versioning](https://semver.org/). When determining the version number for a new release refer to Semantic Versioning for guidance. You can use the `check-semver` command alias from within the development environment to validate your changes don't break semver.

To cut a release:

* Create a release branch from `main` (`git checkout -b release-v0.0.1`)
+ Release PRs should not contain any installer-related changes which require review
* Ensure the `flake.lock`, `Cargo.lock`, and Rust dependencies are up-to-date with the following:
+ `nix flake update --commit-lock-file`
+ `cargo update --aggressive`
+ `cargo outdated --ignore-external-rel --aggressive`
* Ensure the VM / container tests still pass with the following:
+ NOTE: At time of writing, these are run in CI on release branches
+ `nix flake check -L`
+ `nix build .#hydraJobs.container-test.all.x86_64-linux.all -L -j 6`
+ `nix build .#hydraJobs.vm-test.all.x86_64-linux.all -L -j 6`
* Push the branch, create a PR ("Release v0.0.1")
* Once the PR tests pass and it has been reviewed, merge it
* Checkout the `main` branch and `git pull`
* Prepare a draft release that creates the new tag on publish
+ Create a changelog following the format of the last release
* Undraft the release
* CI will produce artifacts and upload them to the release
* Once you are certain the release is good, `cargo publish` it
+ **Warning:** While you can re-release Github releases, it is not possible to do the same on `crates.io`
- Create a release branch from `main` (`git checkout -b release-v0.0.1`)
- Release PRs should not contain any installer-related changes which require review
- Ensure the `flake.lock`, `Cargo.lock`, and Rust dependencies are up-to-date with the following:
- `nix flake update --commit-lock-file`
- `cargo update --aggressive`
- `cargo outdated --ignore-external-rel --aggressive`
- Ensure the VM / container tests still pass with the following:
- NOTE: At time of writing, these are run in CI on release branches
- `nix flake check -L`
- `nix build .#hydraJobs.container-test.all.x86_64-linux.all -L -j 6`
- `nix build .#hydraJobs.vm-test.all.x86_64-linux.all -L -j 6`
- Push the branch, create a PR ("Release v0.0.1")
- Once the PR tests pass and it has been reviewed, merge it
- Checkout the `main` branch and `git pull`
- Prepare a draft release that creates the new tag on publish
- Create a changelog following the format of the last release
- Undraft the release
- CI will produce artifacts and upload them to the release
- Once you are certain the release is good, `cargo publish` it
- **Warning:** While you can re-release Github releases, it is not possible to do the same on `crates.io`
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
check.check-editorconfig
check.check-semver
check.check-clippy
editorconfig-checker
]
++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [
libiconv
Expand Down
2 changes: 1 addition & 1 deletion nix-installer.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# shellcheck shell=dash

# If you need an offline install, or you'd prefer to run the binary directly, head to
# If you need an offline install, or you'd prefer to run the binary directly, head to
# https://github.com/DeterminateSystems/nix-installer/releases then pick the version and platform
# most appropriate for your deployment target.
#
Expand Down
4 changes: 2 additions & 2 deletions nix/check.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ in
# EditorConfig
check-editorconfig = (writeShellApplication {
name = "check-editorconfig";
runtimeInputs = with pkgs; [ eclint ];
runtimeInputs = with pkgs; [ editorconfig-checker ];
text = ''
eclint .
editorconfig-checker
'';
});

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "stable"
components = [ "rustfmt" ]
components = [ "rustfmt" ]
2 changes: 1 addition & 1 deletion src/action/linux/selinux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion src/action/linux/selinux/nix.fc
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/action/macos/create_nix_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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(),
)
Expand Down
2 changes: 1 addition & 1 deletion src/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,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>),
Expand Down
4 changes: 2 additions & 2 deletions src/cli/subcommand/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl CommandExecute for Install {
Some(existing_receipt) => {
if let Err(e) = existing_receipt.check_compatible() {
eprintln!(
"{}",
"{}",
format!("\
{e}\n\
\n\
Expand Down Expand Up @@ -164,7 +164,7 @@ impl CommandExecute for Install {
Some(existing_receipt) => {
if let Err(e) = existing_receipt.check_compatible() {
eprintln!(
"{}",
"{}",
format!("\
{e}\n\
\n\
Expand Down
2 changes: 1 addition & 1 deletion src/cli/subcommand/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl CommandExecute for Uninstall {
if let Err(e) = plan.check_compatible() {
let version = plan.version;
eprintln!(
"{}",
"{}",
format!("\
{e}\n\
\n\
Expand Down
Loading
Loading