flake.nix (view raw)
1{
2 description = "site";
3
4 inputs.nixpkgs.url = "github:nixos/nixpkgs";
5 inputs.vite.url = "github:icyphox/go-vite";
6
7 outputs =
8 { self
9 , nixpkgs
10 , vite
11 ,
12 }:
13 let
14 supportedSystems = [
15 "x86_64-linux"
16 "x86_64-darwin"
17 "aarch64-linux"
18 "aarch64-darwin"
19 ];
20 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
21 nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
22 in
23 {
24 devShells = forAllSystems (
25 system:
26 let
27 pkgs = nixpkgsFor.${system};
28 in
29 {
30 default = pkgs.mkShell {
31 buildInputs = [
32 vite.packages.${system}.vite
33 pkgs.gotools
34 pkgs.gnumake
35 pkgs.entr
36 pkgs.awscli2
37 ];
38 };
39 }
40 );
41
42 apps = forAllSystems (
43 system:
44 let
45 pkgs = nixpkgsFor.${system};
46 in
47 {
48 default = {
49 type = "app";
50 program = "${pkgs.writeShellScriptBin "vite-build" ''
51 #!/usr/bin/env bash
52 ${vite.packages.${system}.vite}/bin/vite build
53 ''}/bin/vite-build";
54 cwd = ./.;
55 };
56 deploy = {
57 type = "app";
58 program = "${pkgs.writeShellScriptBin "s3-sync" ''
59 #!/usr/bin/env bash
60 ${vite.packages.${system}.vite}/bin/vite build
61 ${pkgs.awscli2}/bin/aws s3 sync build s3://site/ --size-only
62 ''}/bin/s3-sync";
63 };
64 }
65 );
66 };
67}