all repos — site @ bd3d166d51373d07c939c64fa8d9d9b599a15df9

source for my site, found at icyphox.sh

nix: build and deploy via flake apps
Anirudh Oppiliappan x@icyphox.sh
Wed, 24 Jul 2024 19:14:21 +0300
commit

bd3d166d51373d07c939c64fa8d9d9b599a15df9

parent

a962871b4c713243f5125de1994343b51ac067d3

2 files changed, 55 insertions(+), 48 deletions(-)

jump to
M flake.lockflake.lock

@@ -1,35 +1,20 @@

{ "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, + "nixpkgs": { "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1721833789, + "narHash": "sha256-VQw64O2UO0SnJlYiE9jvF9QVcFZgxvfiQxV2sKA20MU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e34403dab7f1171e0a2e4f5a47c32e7db95d0b2", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "nixos", + "repo": "nixpkgs", "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 0, - "narHash": "sha256-ZgnNHuKV6h2+fQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ=", - "path": "/nix/store/xr9wjzx0cdnwkmhzz74h8lphgn5jmyv3-source", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1716807034,

@@ -47,24 +32,8 @@ }

}, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "vite": "vite" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" } }, "vite": {
M flake.nixflake.nix

@@ -1,19 +1,33 @@

{ description = "site"; - inputs = { - vite.url = "github:icyphox/go-vite"; - flake-utils.url = "github:numtide/flake-utils"; - }; + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs.vite.url = "github:icyphox/go-vite"; - outputs = { self, nixpkgs, flake-utils, vite }: - flake-utils.lib.eachDefaultSystem - (system: + outputs = + { + self, + nixpkgs, + vite, + }: + let + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in + { + devShells = forAllSystems ( + system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = nixpkgsFor.${system}; in { - devShell = pkgs.mkShell { + default = pkgs.mkShell { buildInputs = [ vite.packages.${system}.vite pkgs.gotools

@@ -25,4 +39,28 @@ };

} ); + apps = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = { + type = "app"; + program = "${pkgs.writeShellScriptBin "vite-build" '' + #!/usr/bin/env bash + ${vite.packages.${system}.vite}/bin/vite build + ''}/bin/vite-build"; + cwd = ./.; + }; + deploy = { + type = "app"; + program = "${pkgs.writeShellScriptBin "s3-sync" '' + #!/usr/bin/env bash + ${pkgs.awscli2}/bin/aws s3 sync build s3://site/ --size-only + ''}/bin/s3-sync"; + }; + } + ); + }; }