flake.nix (1285B)
1 { 2 description = "stagit site generator"; 3 4 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 5 6 outputs = { self, nixpkgs }: 7 let 8 system = "x86_64-linux"; 9 pkgs = import nixpkgs { inherit system; }; 10 in { 11 packages.${system}.stagit-run = pkgs.writeShellApplication { 12 name = "stagit-run"; 13 runtimeInputs = [ pkgs.stagit pkgs.git ]; 14 15 text = '' 16 set -euo pipefail 17 18 BASE="$(pwd)" 19 OUT="$BASE/git" 20 REPOS_DIR="$BASE/../pub_repos" 21 22 rm -rf "$OUT" 23 mkdir -p "$OUT" 24 25 generate_repo () { 26 repo_path="$1" 27 repo_name="$(basename "$repo_path")" 28 29 work="$(mktemp -d)" 30 trap 'rm -rf "$work"' RETURN 31 32 mkdir -p "$work" 33 cd "$work" 34 35 stagit -c cache "$repo_path" 36 37 dest="$OUT/$repo_name" 38 mkdir -p "$dest" 39 40 cp -r ./* "$dest" 41 42 cp -f "${pkgs.stagit}/share/doc/stagit/style.css" "$dest/style.css" 43 cp -f "${pkgs.stagit}/share/doc/stagit/logo.png" "$dest/logo.png" 44 cp -f "${pkgs.stagit}/share/doc/stagit/favicon.png" "$dest/favicon.png" 45 } 46 47 # include website repo itself as just another repo 48 generate_repo "$BASE" 49 50 for repo in "$REPOS_DIR"/*; do 51 [ -d "$repo/.git" ] || continue 52 generate_repo "$repo" 53 done 54 55 '';}; 56 57 apps.${system}.default = { 58 type = "app"; 59 program = "${self.packages.${system}.stagit-run}/bin/stagit-run"; 60 }; 61 }; 62 }