|
| 1 | +{ |
| 2 | +description = "Reproducible checks for kelio-rewrite"; |
| 3 | + |
| 4 | +inputs = { |
| 5 | +nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | +semgrep-rules = { |
| 7 | +url = "github:semgrep/semgrep-rules"; |
| 8 | +flake = false; |
| 9 | +}; |
| 10 | +}; |
| 11 | + |
| 12 | +outputs = |
| 13 | +{ nixpkgs, semgrep-rules, ... }: |
| 14 | +let |
| 15 | +systems = [ |
| 16 | +"x86_64-linux" |
| 17 | +"aarch64-linux" |
| 18 | +]; |
| 19 | +forAllSystems = nixpkgs.lib.genAttrs systems; |
| 20 | +in |
| 21 | +{ |
| 22 | +checks = forAllSystems ( |
| 23 | +system: |
| 24 | +let |
| 25 | +pkgs = nixpkgs.legacyPackages.${system}; |
| 26 | +nodeModules = pkgs.importNpmLock.buildNodeModules { |
| 27 | +npmRoot = ./.; |
| 28 | +nodejs = pkgs.nodejs; |
| 29 | +}; |
| 30 | +npmCheck = |
| 31 | +name: command: |
| 32 | +pkgs.stdenvNoCC.mkDerivation { |
| 33 | +inherit name; |
| 34 | +npmDeps = nodeModules; |
| 35 | +src = ./.; |
| 36 | +nativeBuildInputs = [ |
| 37 | +pkgs.nodejs |
| 38 | +pkgs.importNpmLock.hooks.linkNodeModulesHook |
| 39 | +]; |
| 40 | +buildPhase = command; |
| 41 | +installPhase = "touch $out"; |
| 42 | +}; |
| 43 | +in |
| 44 | +{ |
| 45 | +actionlint = |
| 46 | +pkgs.runCommand "actionlint" |
| 47 | +{ |
| 48 | +nativeBuildInputs = [ pkgs.actionlint ]; |
| 49 | +} |
| 50 | +'' |
| 51 | + actionlint -config-file ${./.github/actionlint.yaml} ${./.github/workflows/ci.yml} |
| 52 | + touch $out |
| 53 | + ''; |
| 54 | +oxfmt = npmCheck "oxfmt" "npm run format:check"; |
| 55 | +oxlint = npmCheck "oxlint" "npm run lint"; |
| 56 | +semgrep = |
| 57 | +pkgs.runCommand "semgrep" |
| 58 | +{ |
| 59 | +nativeBuildInputs = [ pkgs.semgrep ]; |
| 60 | +SEMGREP_SEND_METRICS = "off"; |
| 61 | +SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
| 62 | +} |
| 63 | +'' |
| 64 | + export HOME="$TMPDIR" |
| 65 | + semgrep scan --metrics off --config ${semgrep-rules}/javascript --error ${./.} |
| 66 | + touch $out |
| 67 | + ''; |
| 68 | +} |
| 69 | +); |
| 70 | + |
| 71 | +formatter = forAllSystems ( |
| 72 | +system: |
| 73 | +let |
| 74 | +pkgs = nixpkgs.legacyPackages.${system}; |
| 75 | +in |
| 76 | +pkgs.writeShellScriptBin "nix-fmt" '' |
| 77 | + if [ "$#" -eq 0 ]; then |
| 78 | + set -- flake.nix |
| 79 | + fi |
| 80 | + exec ${pkgs.nixfmt}/bin/nixfmt "$@" |
| 81 | + '' |
| 82 | +); |
| 83 | +}; |
| 84 | +} |