this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 328b88f434564a2546a1c8282cd4d0ce576f5740 120 lines 3.8 kB view raw
1{ 2 description = "A basic flake with a shell"; 3 inputs = { 4 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 5 flake-utils.url = "github:numtide/flake-utils"; 6 }; 7 8 outputs = { nixpkgs, flake-utils, ... }: 9 flake-utils.lib.eachDefaultSystem (system: 10 let 11 pkgs = import nixpkgs { inherit system; }; 12 username = "admin"; 13 passwordHash = 14 "$apr1$bhZ6EAAr$E8cv5p/2RUBrxLZD.9Jpi."; # Replace with your hash 15 16 nginxConfig = pkgs.writeText "nginx.conf" '' 17 worker_processes auto; 18 daemon off; 19 20 events { 21 worker_connections 1024; 22 } 23 24 http { 25 include ${pkgs.nginx}/conf/mime.types; 26 27 server { 28 listen 8080; 29 30 location / { 31 auth_basic "Restricted Content"; 32 auth_basic_user_file /etc/nginx/htpasswd; 33 34 root /app; 35 index index.html; 36 try_files $uri $uri/ /index.html; 37 } 38 } 39 } 40 ''; 41 42 htpasswd = pkgs.writeText "htpasswd" '' 43 ${username}:${passwordHash} 44 ''; 45 in { 46 packages = rec { 47 react = pkgs.buildNpmPackage { 48 pname = "mast-react"; 49 version = "0.0.1"; 50 src = ./mast-react-vite; 51 52 npmDepsHash = "sha256-oqq55MEzXGEiF9UW7rZFyQrkyTPrUEkh2enZmbbZ7Ks="; 53 buildInputs = with pkgs; [ nodejs typescript ]; 54 nativeBuildInputs = with pkgs; [ nodejs ]; 55 56 # npmWorkspace = ./mast-react-vite; 57 npmBuildScript = "build"; 58 installPhase = '' 59 mkdir -p $out 60 cp -r dist $out/ 61 ''; 62 }; 63 react-server = pkgs.dockerTools.buildImage { 64 name = "react-server"; 65 tag = "latest"; 66 67 copyToRoot = pkgs.buildEnv { 68 name = "image-root"; 69 paths = [ 70 pkgs.nginx 71 react 72 (pkgs.writeScriptBin "start-server.sh" '' 73 #!/usr/bin/env bash 74 75 # Create necessary directories 76 mkdir -p /etc/nginx 77 cp ${htpasswd} /etc/nginx/htpasswd 78 79 # Create app directory and copy built files 80 mkdir -p /app 81 cp -r ${react}/* /app/ 82 83 # Start nginx 84 ${pkgs.nginx}/bin/nginx -c ${nginxConfig} 85 '') 86 ]; 87 pathsToLink = [ "/bin" ]; 88 }; 89 90 config = { 91 Cmd = [ "/start-server.sh" ]; 92 ExposedPorts = { "8080/tcp" = { }; }; 93 Entrypoint = ["/start-server.sh"]; 94 }; 95 }; 96 }; 97 devShells.default = pkgs.mkShell { 98 buildInputs = with pkgs; [ go pigeon nodejs sqlite git-bug openssl flyctl skopeo ]; 99 100 # TODO: 101 # Shell Aliases don't work for direnv because they're not shell portable 102 # Find an alternative to this 103 shellHook = '' 104 alias start-dev='npm run dev' 105 alias build-dev='npm run build' 106 alias clean-dev='rm -rf dist node_modules' 107 alias ws-server='go run ./server/main.go' 108 alias gen-pass='openssl passwd -apr1 ' 109 110 echo "System: ${system}" 111 echo "Available commands:" 112 echo " start-dev - Start Vite dev server" 113 echo " build-dev - Build the application" 114 echo " clean-dev - Clean build artifacts" 115 echo " ws-server - Run the websocket server" 116 echo " gen-pass - Generate a basic_auth password" 117 ''; 118 }; 119 }); 120}