Skip to content

nixos/systemd: allow running shellcheck on generated systemd scripts#311394

Merged
flokli merged 1 commit intoNixOS:masterfrom
r-vdp:shellcheck_systemd_units
Oct 8, 2024
Merged

nixos/systemd: allow running shellcheck on generated systemd scripts#311394
flokli merged 1 commit intoNixOS:masterfrom
r-vdp:shellcheck_systemd_units

Conversation

@r-vdp
Copy link
Copy Markdown
Contributor

@r-vdp r-vdp commented May 13, 2024

Description of changes

With this PR we can optionally run shellcheck on generated systemd scripts.
Our nixos closure already depends on GHC (and shellcheck), so this does not affect the runtime closure.

I fixed the scripts that I use on my machines, but there is definitely a lot more stuff to fix before this could become the default.
I will submit these as separate PRs.

For now, this sits behind an enable-option. It would be great if some people would enable this and submit fixes for existing scripts.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. labels May 13, 2024
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from a9a7eb6 to e2a08b4 Compare May 13, 2024 15:13
@r-vdp r-vdp changed the title Run shellcheck on systemd scripts Allow running shellcheck on systemd scripts May 13, 2024
@r-vdp r-vdp changed the title Allow running shellcheck on systemd scripts Allow running shellcheck on generated systemd scripts May 13, 2024
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from e2a08b4 to b3253bd Compare May 13, 2024 15:32
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 13, 2024
@r-vdp r-vdp changed the title Allow running shellcheck on generated systemd scripts systemd: allow running shellcheck on generated systemd scripts May 13, 2024
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch 2 times, most recently from faf5a04 to cedb0c7 Compare May 13, 2024 20:57
@r-vdp r-vdp marked this pull request as ready for review June 5, 2024 10:36
@r-vdp r-vdp requested review from a team, RaitoBezarius and dasJ as code owners June 5, 2024 10:36
Copy link
Copy Markdown
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good idea. I think the only thing that really needs some discussion, is what we are going to do about the shellcheck mkdir -p error. Maybe we ignore it by default for now?

Also please remind me in a week or so, that I want to test this on my deployments.

Copy link
Copy Markdown
Contributor

@ElvishJerricco ElvishJerricco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be something that can be enabled per-unit, with the global setting acting as the default.

@r-vdp
Copy link
Copy Markdown
Contributor Author

r-vdp commented Jun 5, 2024

Seems like this should be something that can be enabled per-unit, with the global setting acting as the default.

@ElvishJerricco that's already how it's done. There is a global switch (defaults to false for now) and a per-unit switch that defaults to the value of the global switch.

So it's possible to enable or disable this on a per-unit basis, independent of the global option.

@r-vdp r-vdp requested a review from ElvishJerricco June 5, 2024 20:54
@ElvishJerricco ElvishJerricco dismissed their stale review June 7, 2024 03:47

misunderstood things

@ElvishJerricco
Copy link
Copy Markdown
Contributor

Ah, I misunderstood what I was reading. Great!

@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from ee85fe4 to fbba7c8 Compare June 7, 2024 09:29
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from fbba7c8 to b9784ca Compare June 7, 2024 16:41
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from b9784ca to 350ec3e Compare July 23, 2024 17:32
@r-vdp r-vdp requested a review from arianvp as a code owner July 23, 2024 17:32
@r-vdp r-vdp requested a review from ElvishJerricco September 7, 2024 18:10
@r-vdp
Copy link
Copy Markdown
Contributor Author

r-vdp commented Sep 7, 2024

I removed the fixes for different services. I will make separate PRs for these.

You won't be able to build a NixOS system with shellcheck for services enabled until we also merge fixes for some of those.

Copy link
Copy Markdown
Contributor

@Mindavi Mindavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think splitting this up was the right call and on surface this looks good to me and I ACK the idea too.

@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from 34c6e05 to df3b9bb Compare October 5, 2024 08:26
@r-vdp r-vdp changed the title systemd: allow running shellcheck on generated systemd scripts nixos/systemd: allow running shellcheck on generated systemd scripts Oct 5, 2024
@r-vdp r-vdp dismissed ElvishJerricco’s stale review October 5, 2024 08:27

Changes to services have been split out into separate PRs, all but one of which are already merged.

@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from df3b9bb to 86db826 Compare October 8, 2024 09:49
@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes labels Oct 8, 2024
@r-vdp r-vdp force-pushed the shellcheck_systemd_units branch from 86db826 to 2b224f0 Compare October 8, 2024 10:01
Copy link
Copy Markdown
Member

@phaer phaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice feature! Code looks good to me and feature works as intended. PR quite easy to review IMO.

@flokli flokli merged commit 2ec88eb into NixOS:master Oct 8, 2024
@r-vdp r-vdp deleted the shellcheck_systemd_units branch October 8, 2024 22:15
@nixos-discourse

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants