diff options
| author | seth <[email protected]> | 2023-12-20 20:27:18 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2023-12-21 02:34:37 +0000 |
| commit | 5aa2e6c0c6e4c73d93307e9f70803237006afb28 (patch) | |
| tree | f26a67452e2d4a4ed30506e533ac17cc95184fac /flake.nix | |
| parent | 2a6f22fc1f1939b102fb8925bf04914a4b553e17 (diff) | |
go back to lume
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 154 |
1 files changed, 122 insertions, 32 deletions
@@ -1,19 +1,18 @@ { - description = "getchoo's personal website"; + description = "getchoo's website"; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; - pre-commit-hooks = { - url = "github:cachix/pre-commit-hooks.nix"; - inputs.nixpkgs-stable.follows = "nixpkgs"; + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + nix-deno = { + url = "github:nekowinston/nix-deno"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { - self, nixpkgs, - pre-commit-hooks, + nix-deno, + self, ... }: let systems = [ @@ -23,38 +22,129 @@ "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); - in { - checks = forAllSystems (system: { - pre-commit-check = pre-commit-hooks.lib.${system}.run { - src = ./.; - hooks = { - alejandra.enable = true; - eslint.enable = true; - prettier.enable = true; - editorconfig-checker.enable = true; + forSystem = system: fn: + fn rec { + pkgs = import nixpkgs { + inherit system; + overlays = [nix-deno.overlays.default]; }; + + inherit (pkgs) lib; + self' = lib.mapAttrs (_: v: v.${system} or {}) self; }; + + forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: forSystem system fn); + in { + checks = forAllSystems ({ + lib, + pkgs, + self', + ... + }: { + check-nil = + pkgs.runCommand "check-nil" { + nativeBuildInputs = with pkgs; [fd nil]; + } '' + cd ${./.} + fd . -e "nix" | while read -r file; do + nil diagnostics "$file" || exit 1 + done + + touch $out + ''; + + "check-${self'.formatter.pname}" = pkgs.runCommand "check-${self'.formatter.pname}" {} '' + ${lib.getExe self'.formatter} --check ${./.} + + touch $out + ''; + + check-statix = + pkgs.runCommand "check-statix" { + nativeBuildInputs = [pkgs.statix]; + } '' + statix check ${./.} + + touch $out + ''; + + check-actionlint = + pkgs.runCommand "check-actionlint" { + nativeBuildInputs = [pkgs.actionlint]; + } '' + actionlint ${./.github/workflows}/** + + touch $out + ''; + + check-denofmt = + pkgs.runCommand "check-denofmt" { + nativeBuildInputs = [pkgs.deno]; + } '' + cd ${./.} + export DENO_DIR="$(mktemp -d)" + deno fmt --check + + touch $out + ''; + + check-denolint = + pkgs.runCommand "check-denolint" { + nativeBuildInputs = [pkgs.deno]; + } '' + cd ${./.} + export DENO_DIR="$(mktemp -d)" + deno lint + + touch $out + ''; }); - devShells = forAllSystems (system: let - pkgs = nixpkgsFor.${system}; - inherit (pkgs) mkShell; - in { - default = mkShell { - inherit (self.checks.${system}.pre-commit-check) shellHook; - packages = with pkgs; - with nodePackages; [ - eslint - just - nodejs - prettier - pnpm + devShells = forAllSystems ({ + pkgs, + self', + ... + }: { + default = pkgs.mkShell { + packages = with pkgs; [ + deno + actionlint + + self'.formatter + nil + statix ]; }; }); - formatter = forAllSystems (s: nixpkgsFor.${s}.alejandra); + formatter = forAllSystems ({pkgs, ...}: pkgs.alejandra); + + packages = forAllSystems ({ + lib, + pkgs, + self', + ... + }: { + website = pkgs.denoPlatform.mkDenoDerivation { + name = "website"; + stdenv = pkgs.stdenvNoCC; + + src = lib.cleanSource ./.; + + buildPhase = '' + runHook preBuild + + deno task build + + runHook postBuild + ''; + + installPhase = '' + cp -r _site $out + ''; + }; + + default = self'.packages.website; + }); }; } |
