From b589ba5d8a644ffb4039bd838418c3f564009514 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 29 Jul 2023 15:20:14 -0400 Subject: [PATCH] enable auto PRs and checks --- .github/workflows/check.yml | 21 +++++++++++++++++++++ .github/workflows/update.yml | 32 ++++++++++++++++++++++++++++++++ flake.nix | 18 ++++++++++++++++++ hosts/aws/default.nix | 6 +----- modules/common/mail/system.nix | 4 +++- 5 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/update.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..629f2bf --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,21 @@ +name: Check Build + +on: + workflow_dispatch: # allows manual triggering + pull_request: + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + - name: Check Nixpkgs Inputs + uses: DeterminateSystems/flake-checker-action@v5 + - name: Add Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Check the Flake + run: nix flake check diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..4813b6e --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,32 @@ +name: Update Flake + +on: + workflow_dispatch: # allows manual triggering + schedule: + - cron: '33 3 * * 0' # runs weekly on Sunday at 03:33 + +permissions: + contents: read + pull-request: write + +jobs: + lockfile: + name: Lockfile + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v4 + - name: Check Nixpkgs Inputs + uses: DeterminateSystems/flake-checker-action@v5 + - name: Update flake.lock + uses: DeterminateSystems/update-flake-lock@v3 + id: update + with: + pr-title: "Update flake.lock" # Title of PR to be created + pr-labels: | # Labels to be set on the PR + dependencies + automated + - name: Enable Pull Request Automerge + run: gh pr merge --merge --auto ${{ steps.update.outputs.pull-request-number }} diff --git a/flake.nix b/flake.nix index e5f3951..8c8321c 100644 --- a/flake.nix +++ b/flake.nix @@ -228,6 +228,24 @@ }); + checks = forAllSystems (system: + let pkgs = import nixpkgs { inherit system overlays; }; + in { + neovim = pkgs.runCommand "neovim-check-health" { + buildInputs = [ inputs.self.packages.${system}.neovim ]; + } '' + mkdir -p $out + export HOME=$TMPDIR + nvim -c "checkhealth" -c "write $out/health.log" -c "quitall" + + # Check for errors inside the health log + if $(grep "ERROR" $out/health.log); then + cat $out/health.log + exit 1 + fi + ''; + }); + # Templates for starting other projects quickly templates = rec { default = basic; diff --git a/hosts/aws/default.nix b/hosts/aws/default.nix index 45b9285..217220e 100644 --- a/hosts/aws/default.nix +++ b/hosts/aws/default.nix @@ -4,14 +4,10 @@ inputs.nixos-generators.nixosGenerate { inherit system; format = "amazon"; modules = [ + globals inputs.home-manager.nixosModules.home-manager { nixpkgs.overlays = overlays; - user = globals.user; - fullName = globals.fullName; - dotfilesRepo = globals.dotfilesRepo; - gitName = globals.gitName; - gitEmail = globals.gitEmail; networking.hostName = "sheep"; gui.enable = false; theme.colors = (import ../../colorscheme/gruvbox).dark; diff --git a/modules/common/mail/system.nix b/modules/common/mail/system.nix index c43daa9..81476f0 100644 --- a/modules/common/mail/system.nix +++ b/modules/common/mail/system.nix @@ -5,12 +5,14 @@ home-manager.users.${config.user} = { programs.msmtp.enable = true; + + # The system user for sending automatic notifications accounts.email.accounts.system = let address = "system@${config.mail.server}"; in { userName = address; realName = "NixOS System"; - primary = false; + primary = !config.mail.enable; # Only primary if mail not enabled inherit address; passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${