Skip to content

Commit

Permalink
swap out nix lint/fix for devbox style
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-aye-see-kay committed Dec 21, 2023
1 parent e70cca4 commit 4336944
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 39 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ jobs:
run: docker build -t bootstrap-script-test-fish -f ./bootstrap-test.Dockerfile . --build-arg SHELL_VAR=fish
- name: Run bats-fish test via devbox
run: docker run bootstrap-script-test-fish bats test/bootstrap-agnostic.bats test/bootstrap-fish.bats
nix-flake-check:
check-linting-and-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- run: nix flake check --keep-going --print-build-logs
- uses: jetpack-io/[email protected]
- run: devbox run lint
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ Devbox is something we're trialing internally, we need some plugins. So putting
This repo is public as it's only used to configure open source software, there will likely be a bit of company specific stuff in here but nothing sensitive.

Once we're happy with there plugins we'll attempt to upstream them as appropriate.

# Formatting and linting

```sh
# check formatting and linting
devbox run lint

# autofix (where possible) formatting and linting
devbox run lint:fix
```
12 changes: 12 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
],
"shell": {
"scripts": {
"lint": [
"nixpkgs-fmt --check . &",
"statix check --ignore .devbox &",
"shellcheck **/*.{sh,bats} &",
"shfmt --diff **/*.{sh,bats} &",
"wait"
],
"lint:fix": [
"nixpkgs-fmt .",
"statix fix --ignore .devbox",
"shfmt --write **/*.{sh,bats}"
],
"test": [
"devbox run test-bash",
"devbox run test-zsh",
Expand Down
35 changes: 0 additions & 35 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,11 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = "${system}"; config.allowUnfree = true; };

# common parts of making derivations for flake checks
# from: https://msfjarvis.dev/posts/writing-your-own-nix-flake-checks/
mkCheck = { name, nativeBuildInputs, checkPhase }: pkgs.stdenvNoCC.mkDerivation {
inherit name nativeBuildInputs checkPhase;
src = ./.;
dontBuild = true;
doCheck = true;
installPhase = ''
mkdir "$out"
'';
};
in
{
# set formatter binary for `nix fmt` command
formatter = pkgs.nixpkgs-fmt;

checks = {
nix-formatting = mkCheck {
name = "nix-formatting";
nativeBuildInputs = [ pkgs.nixpkgs-fmt ];
checkPhase = "nixpkgs-fmt --check .";
};
nix-linting = mkCheck {
name = "nix-linting";
nativeBuildInputs = [ pkgs.statix ];
checkPhase = "statix check";
};
shell-linting = mkCheck {
name = "shell-linting";
nativeBuildInputs = [ pkgs.shellcheck ];
checkPhase = "shellcheck **/*.{sh,bash,bats}";
};
shell-formatting = mkCheck {
name = "shell-formatting";
nativeBuildInputs = [ pkgs.shfmt ];
checkPhase = "shfmt --write **/*.{sh,bash,bats}";
};
};

packages = {
mongodb-4_4 = pkgs.callPackage ./packages/mongodb-4_4.nix { };
dynamodb_local = pkgs.callPackage ./packages/dynamodb_local.nix { };
Expand Down

0 comments on commit 4336944

Please sign in to comment.