diff --git a/.gitignore b/.gitignore index e49973e..a55f26d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .direnv .DS_Store node_modules +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..89b1f3d --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775403759, + "narHash": "sha256-cGyKiTspHEUx3QwAnV3RfyT+VOXhHLs+NEr17HU34Wo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5e11f7acce6c3469bef9df154d78534fa7ae8b6c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9287134 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: + import nixpkgs { + inherit system; + }); + in { + packages = forAllSystems (system: let + pkgs = nixpkgsFor."${system}"; + in { + default = pkgs.stdenv.mkDerivation { + pname = "tinysub"; + version = "0.1.0"; + src = ./.; + + nativeBuildInputs = with pkgs; [ + monolith + ]; + + buildPhase = '' + runHook preBuild + + monolith src/index.html -o index.html + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp index.html $out/ + + runHook postInstall + ''; + }; + }); + + formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); + + overlays.default = final: prev: { + tinysub = self.packages.${final.system}.default; + }; + }; +}