From 3743aead94daac0b914f60fffdf502e087030e25 Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Wed, 4 Oct 2023 15:25:52 +0100 Subject: [PATCH] Mailcap and flake check (#26) --- .github/workflows/lint.yaml | 24 ------------------------ bootstrap.sh | 6 +++--- flake.nix | 31 ++++++++++++++++++++++++++++--- home-manager/rider/link.sh | 10 ++++++---- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index af44f10..cb8cc0b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -7,28 +7,6 @@ on: branches: [ main ] jobs: - shellcheck: - runs-on: ubuntu-latest - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - - name: "Install Nix" - uses: "cachix/install-nix-action@v23" - with: { "extra_nix_config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" } - - name: "Run Shellcheck" - run: "nix develop --command bash -c \"find . -type f -name '*.sh' | xargs shellcheck\"" - - format: - runs-on: "ubuntu-latest" - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - - name: "Install Nix" - uses: "cachix/install-nix-action@v23" - with: { "extra_nix_config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" } - - name: "Run Alejandra" - run: "nix develop --command alejandra --check ." - flake-check: runs-on: "ubuntu-latest" steps: @@ -45,6 +23,4 @@ jobs: steps: - run: "echo \"All required checks complete.\"" needs: - - "shellcheck" - - "format" - "flake-check" diff --git a/bootstrap.sh b/bootstrap.sh index e02feee..3e27b74 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,13 +1,13 @@ #!/bin/sh -install_nix () { +install_nix() { echo "Installing Nix..." - diskutil list > /dev/null || export PATH="/usr/sbin:$PATH" + diskutil list >/dev/null || export PATH="/usr/sbin:$PATH" curl -L https://nixos.org/nix/install | sh -s -- --darwin-use-unencrypted-nix-store-volume --daemon || exit 1 echo "Nix installed." } -install_darwin_build () { +install_darwin_build() { echo "Installing nix-darwin..." nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer || exit 1 ./result/bin/darwin-installer || exit 1 diff --git a/flake.nix b/flake.nix index a915bf0..a091edd 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ # contentAddressedByDefault = true; allowUnfree = true; }; + systems = ["aarch64-darwin" "aarch64-linux" "x86_64-linux"]; in let overlays = [emacs.overlay] ++ import ./overlays.nix; recursiveMerge = attrList: let @@ -108,6 +109,29 @@ ]; }; }; + checks = let + fmt-check = system: let + pkgs = import nixpkgs {inherit config system;}; + in + pkgs.stdenvNoCC.mkDerivation { + name = "fmt-check"; + src = ./.; + nativeBuildInputs = [pkgs.alejandra pkgs.shellcheck pkgs.shfmt]; + checkPhase = '' + find . -type f -name '*.sh' | xargs shfmt -d -s -i 2 -ci + alejandra -c . + find . -type f -name '*.sh' -exec shellcheck -x {} \; + ''; + installPhase = "mkdir $out"; + dontBuild = true; + doCheck = true; + }; + in + builtins.listToAttrs (builtins.map (system: { + name = system; + value = {fmt-check = fmt-check system;}; + }) + systems); devShells = let devShell = system: ( let @@ -120,8 +144,9 @@ ); in builtins.listToAttrs (builtins.map (system: { - name = system; - value = devShell system; - }) ["aarch64-darwin" "aarch64-linux" "x86_64-linux"]); + name = system; + value = devShell system; + }) + systems); }; } diff --git a/home-manager/rider/link.sh b/home-manager/rider/link.sh index 24b1705..e52e7ef 100644 --- a/home-manager/rider/link.sh +++ b/home-manager/rider/link.sh @@ -3,17 +3,19 @@ outfile="$1/resharper-host/GlobalSettingsStorage.DotSettings" if [ -e "$outfile" ]; then existing=$(readlink "$outfile") - if [ $? -eq 1 ] ; then + if [ $? -eq 1 ]; then echo "Backing up existing settings file $outfile" mv "$outfile" "$outfile.bak" ln -s "NIX-RIDER-CONFIG/GlobalSettingsStorage.DotSettings" "$outfile" else case "$existing" in "/nix/store/"*) - ln -fs "NIX-RIDER-CONFIG/GlobalSettingsStorage.DotSettings" "$outfile" ;; + ln -fs "NIX-RIDER-CONFIG/GlobalSettingsStorage.DotSettings" "$outfile" + ;; *) - echo "Refusing to overwrite existing symlink to $existing" && \ - exit 1 ;; + echo "Refusing to overwrite existing symlink to $existing" && + exit 1 + ;; esac fi else