feat: add nix for formatting
Also adds CI tests!
This commit is contained in:
parent
58249e9ad0
commit
73142cfab8
9 changed files with 314 additions and 121 deletions
8
.editorconfig
Normal file
8
.editorconfig
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
|
||||||
|
[*.{nix,json,sh}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
41
.forgejo/workflows/check.yml
Normal file
41
.forgejo/workflows/check.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: nixos
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
check:
|
||||||
|
- treefmt
|
||||||
|
steps:
|
||||||
|
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
|
||||||
|
- name: Run checks
|
||||||
|
run: |
|
||||||
|
nix --version
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
nix build --print-build-logs '.#checks.x86_64-linux.${{ matrix.check }}'
|
||||||
|
check-renovaterc:
|
||||||
|
runs-on: nixos
|
||||||
|
steps:
|
||||||
|
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
|
||||||
|
- name: Validate renovaterc.json
|
||||||
|
run: |
|
||||||
|
nix --version
|
||||||
|
nix shell nixpkgs#renovate --command renovate-config-validator
|
||||||
|
report-size:
|
||||||
|
runs-on: nixos
|
||||||
|
needs: check
|
||||||
|
steps:
|
||||||
|
- uses: "https://git.salame.cl/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4
|
||||||
|
- run: nix --version
|
||||||
|
- name: Create Size Report
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
# Create a comment on the associated PR
|
||||||
|
comment-on-pr: ${{ github.ref_name != 'main' }}
|
||||||
|
# Generate artifacts on main (to speed up comparisons)
|
||||||
|
generate-artifact: ${{ github.ref_name == 'main' }}
|
||||||
|
# Generate comparisons to main
|
||||||
|
do-comparison: 'true'
|
||||||
|
# This job's name (so we can find the artifacts)
|
||||||
|
job-name: report-size
|
|
@ -51,6 +51,7 @@ For more details see the [action.yaml](./action.yml) file.
|
||||||
- Reduce the `NAR Size` by reducing the size of the build outputs, e.g. don't copy unnecessary data to the $out dir, optimize binaries for size, etc.
|
- Reduce the `NAR Size` by reducing the size of the build outputs, e.g. don't copy unnecessary data to the $out dir, optimize binaries for size, etc.
|
||||||
- Reduce the `Size` by reducing the dependencies (e.g. `buildInputs`).
|
- Reduce the `Size` by reducing the dependencies (e.g. `buildInputs`).
|
||||||
- Don't worry too much about size, some dependencies are deduplicated, e.g. `glibc` adds ~40MiB to the `Size`, but is generally shared by ~every binary on the system, so, chances are, you are already including it from somewhere else and statically linking with e.g. `musl` is not gonna improve things.
|
- Don't worry too much about size, some dependencies are deduplicated, e.g. `glibc` adds ~40MiB to the `Size`, but is generally shared by ~every binary on the system, so, chances are, you are already including it from somewhere else and statically linking with e.g. `musl` is not gonna improve things.
|
||||||
|
|
||||||
# NixOS Configurations
|
# NixOS Configurations
|
||||||
|
|
||||||
| Name | Size | Size Change | NAR Size | NAR Size Change |
|
| Name | Size | Size Change | NAR Size | NAR Size Change |
|
||||||
|
|
98
flake.lock
generated
Normal file
98
flake.lock
generated
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741352980,
|
||||||
|
"narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741513245,
|
||||||
|
"narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1740877520,
|
||||||
|
"narHash": "sha256-oiwv/ZK/2FhGxrCkQkB83i7GnWXPPLzoqFHpDD3uYpk=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "147dee35aab2193b174e4c0868bd80ead5ce755c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"systems": "systems",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1739829690,
|
||||||
|
"narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "3d0579f5cc93436052d94b73925b48973a104204",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
43
flake.nix
Normal file
43
flake.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
description = "Description for the project";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
systems.url = "github:nix-systems/default";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
inputs@{ flake-parts, ... }:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||||
|
systems = import inputs.systems;
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
# Export pkgs.hello so we can test this action
|
||||||
|
packages = { inherit (pkgs) hello; };
|
||||||
|
|
||||||
|
# Setup formatters
|
||||||
|
treefmt = {
|
||||||
|
# Ignore images
|
||||||
|
settings.global.excludes = [ "*.png" ];
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
programs = {
|
||||||
|
mdformat.enable = true;
|
||||||
|
nixfmt.enable = true;
|
||||||
|
shfmt.enable = true;
|
||||||
|
shellcheck.enable = true;
|
||||||
|
statix.enable = true;
|
||||||
|
typos.enable = true;
|
||||||
|
yamlfmt.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
2
utils.sh
2
utils.sh
|
@ -1,3 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue