Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add a flake to build the web frontend
Michael Raitza committed 2 years ago
commit ab982e934e979f7f4de9e94a33e4cee58bc74399
parent f9b1e5bf79006364407b2e49cf54876c49a51e24
3 files changed +271 -1
added flake.lock
@@ -0,0 +1,151 @@
+
{
+
  "nodes": {
+
    "advisory-db": {
+
      "flake": false,
+
      "locked": {
+
        "lastModified": 1701193254,
+
        "narHash": "sha256-Hr7efA3GjwqBkGYKmd3XmGckdPQikbcCmOrq7fmTp3A=",
+
        "owner": "rustsec",
+
        "repo": "advisory-db",
+
        "rev": "43af5fef0591531a72ebb86c5f1c623ee95c62fe",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "rustsec",
+
        "repo": "advisory-db",
+
        "type": "github"
+
      }
+
    },
+
    "crane": {
+
      "inputs": {
+
        "nixpkgs": [
+
          "heartwood",
+
          "nixpkgs"
+
        ]
+
      },
+
      "locked": {
+
        "lastModified": 1701622587,
+
        "narHash": "sha256-o3XhxCCyrUHZ0tlta2W7/MuXzy+n0+BUt3rKFK3DIK4=",
+
        "owner": "ipetkov",
+
        "repo": "crane",
+
        "rev": "c09d2cbe84cc2adfe1943cb2a0b55a71c835ca9a",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "ipetkov",
+
        "repo": "crane",
+
        "type": "github"
+
      }
+
    },
+
    "fenix": {
+
      "inputs": {
+
        "nixpkgs": [
+
          "heartwood",
+
          "nixpkgs"
+
        ],
+
        "rust-analyzer-src": [
+
          "heartwood"
+
        ]
+
      },
+
      "locked": {
+
        "lastModified": 1701930186,
+
        "narHash": "sha256-t9uIiU1fE7VXi3t460iOuAUW8Ece9mowRKva1aw48zI=",
+
        "owner": "nix-community",
+
        "repo": "fenix",
+
        "rev": "aeb764a8e4c16da3f36b200a302552d8e457b9f4",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "nix-community",
+
        "repo": "fenix",
+
        "type": "github"
+
      }
+
    },
+
    "flake-utils": {
+
      "inputs": {
+
        "systems": "systems"
+
      },
+
      "locked": {
+
        "lastModified": 1705309234,
+
        "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
+
        "owner": "numtide",
+
        "repo": "flake-utils",
+
        "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "numtide",
+
        "repo": "flake-utils",
+
        "type": "github"
+
      }
+
    },
+
    "heartwood": {
+
      "inputs": {
+
        "advisory-db": "advisory-db",
+
        "crane": "crane",
+
        "fenix": "fenix",
+
        "flake-utils": [
+
          "flake-utils"
+
        ],
+
        "nixpkgs": [
+
          "nixpkgs"
+
        ]
+
      },
+
      "locked": {
+
        "lastModified": 1706090127,
+
        "narHash": "sha256-g228VgKkUbWyGGzLi0XhP3EmobpTSiKYm4y1QIl8zxc=",
+
        "ref": "master",
+
        "rev": "49584f4e732fb0039d2089f3c39fd56fc34a2ee3",
+
        "revCount": 1641,
+
        "type": "git",
+
        "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"
+
      },
+
      "original": {
+
        "ref": "master",
+
        "rev": "49584f4e732fb0039d2089f3c39fd56fc34a2ee3",
+
        "type": "git",
+
        "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"
+
      }
+
    },
+
    "nixpkgs": {
+
      "locked": {
+
        "lastModified": 1705683926,
+
        "narHash": "sha256-Xc9+2dXNZ7JZHZ0FB1nW6CNn1xI951xR308C0Z+KrrM=",
+
        "owner": "NixOS",
+
        "repo": "nixpkgs",
+
        "rev": "ef3a4d52ff55537a4b649a1c28c8c5abb0691461",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "NixOS",
+
        "ref": "release-23.11",
+
        "repo": "nixpkgs",
+
        "type": "github"
+
      }
+
    },
+
    "root": {
+
      "inputs": {
+
        "flake-utils": "flake-utils",
+
        "heartwood": "heartwood",
+
        "nixpkgs": "nixpkgs"
+
      }
+
    },
+
    "systems": {
+
      "locked": {
+
        "lastModified": 1681028828,
+
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+
        "owner": "nix-systems",
+
        "repo": "default",
+
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+
        "type": "github"
+
      },
+
      "original": {
+
        "owner": "nix-systems",
+
        "repo": "default",
+
        "type": "github"
+
      }
+
    }
+
  },
+
  "root": "root",
+
  "version": 7
+
}
added flake.nix
@@ -0,0 +1,119 @@
+
{
+
  description = "Radicle web frontend";
+
  inputs = {
+
    nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
+
    flake-utils.url = "github:numtide/flake-utils";
+
    heartwood = {
+
      inputs.flake-utils.follows = "flake-utils";
+
      inputs.nixpkgs.follows = "nixpkgs";
+
      url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git?ref=master&rev=49584f4e732fb0039d2089f3c39fd56fc34a2ee3";
+
    };
+
  };
+

+
  outputs = {
+
    self,
+
    heartwood,
+
    nixpkgs,
+
    flake-utils,
+
    ...
+
  }@inputs:
+
    {
+
      nixosModules.radicle-interface = { config, lib, pkgs, ... }: {
+
        options.services.radicle-interface.enable = lib.mkEnableOption "Local radicle web interface";
+
        config = lib.mkIf config.services.radicle-interface.enable {
+
          services.nginx = {
+
            enable = true;
+
            virtualHosts.localhost = {
+
              listen = [ { addr = "127.0.0.1"; port = 4433; ssl = false; } ];
+
              rejectSSL = true;
+
              locations = {
+
                "/" = {
+
                  index = "index.html";
+
                  root = self.packages.${pkgs.system}.radicle-interface;
+
                  extraConfig = ''
+
                    try_files $uri $uri/ /index.html;
+
                  '';
+
                };
+
              };
+
            };
+
          };
+
        };
+
      };
+
    } //
+

+
    (flake-utils.lib.eachDefaultSystem (system: let
+
      pkgs = nixpkgs.legacyPackages.${system};
+
      inherit (pkgs) lib;
+
    in {
+

+
      checks = {
+
        radicle-interface =  self.packages.${system}.radicle-interface.override { doCheck = true; };
+
      };
+

+
      packages = {
+
        default = self.packages.${system}.radicle-interface;
+
        twemoji-assets = pkgs.fetchFromGitHub {
+
          owner = "twitter";
+
          repo = "twemoji";
+
          rev = "v14.0.2";
+
          hash = "sha256-YoOnZ5uVukzi/6bLi22Y8U5TpplPzB7ji42l+/ys5xI=";
+
        };
+

+
        radicle-interface = pkgs.callPackage ({
+
          lib, buildNpmPackage, doCheck ? false
+
        }: let
+
          # We need rad debug binaries
+
          devProfile = _: { CARGO_PROFILE = ""; };
+
          checkBins = pkgs.buildEnv {
+
            name = "heartwood-debug-bins";
+
            paths = with heartwood.packages.${system}; [
+
              (default.overrideAttrs devProfile)
+
              (radicle-httpd.overrideAttrs devProfile)
+
            ];
+
          };
+
        in buildNpmPackage rec {
+
          pname = "radicle-interface";
+
          version = "1.0.0";
+
          src = ./.;
+
          npmDepsHash = "sha256-WBX+S67Y7SnXLfc202eNxM355Q0nTH4G7fMY5eEDIio=";
+
          postPatch = ''
+
            patchShebangs --build ./scripts
+
            mkdir -p "public/twemoji"
+
            cp -t public/twemoji -r -- ${self.packages.${system}.twemoji-assets}/assets/svg/*
+
            : >scripts/install-twemoji-assets
+
          '';
+
          dontConfigure = true;
+

+
          inherit doCheck;
+
          nativeCheckInputs = with pkgs; [
+
            which
+
            gitMinimal
+
          ];
+
          checkPhase = ''
+
            runHook preCheck
+
            heartwoodRev="${heartwood.rev or "unknown"}"
+
            expRev=$(cat tests/support/heartwood-version)
+
            if [ "''${heartwoodRev#$expRev}" = "$heartwoodRev" ]; then
+
              printf "Error: Expecting heartwood binaries revision '%s', got '%s'" "$expRev" "$heartwoodRev" >&2
+
              exit 1
+
            fi
+
            echo unknown > tests/support/heartwood-version
+
            scripts/install-binaries -l ${checkBins}/bin
+
            scripts/check
+
            {
+
              npm run test:unit
+
              npm run test:httpd-api:unit
+
            } | tee /dev/null
+
            runHook postCheck
+
          '';
+

+
          installPhase = ''
+
            runHook preInstall
+
            mkdir -p "$out"
+
            cp -r -t "$out" build/*
+
            runHook postInstall
+
          '';
+
        }) {};
+
      };
+
    }));
+
}
modified scripts/install-binaries
@@ -2,7 +2,7 @@
set -e

BINARIES=(rad rad-web radicle-node radicle-httpd git-remote-rad)
-
REPO_ROOT=$(git rev-parse --show-toplevel)
+
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")
REV=$(cat "$REPO_ROOT/tests/support/heartwood-version")
BINARY_PATH=$REPO_ROOT/tests/tmp/bin/${REV:0:7}
USE_LOCAL_BINARIES=false