Merge pull request #327512 from Gerg-L/hyprspace

hyprspace: reinit at 0.10.2
This commit is contained in:
Masum Reza 2024-07-17 21:21:34 +05:30 committed by GitHub
commit d18b68fe6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 173 additions and 1 deletions

View File

@ -0,0 +1,113 @@
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package schema
import "encoding/json"
import "fmt"
type Config struct {
// List of addresses to listen on for libp2p traffic.
ListenAddresses []string `json:"listenAddresses,omitempty"`
// Trusted peers in the network.
Peers []ConfigPeersElem `json:"peers,omitempty"`
// This node's private key.
PrivateKey string `json:"privateKey"`
// The services this node provides via the Service Network.
Services ConfigServices `json:"services,omitempty"`
}
type ConfigPeersElem struct {
// PeerID of this peer.
Id string `json:"id"`
// Friendly name for this peer. (optional)
Name string `json:"name,omitempty"`
// Networks to route to this peer. (optional)
Routes []ConfigPeersElemRoutesElem `json:"routes,omitempty"`
}
type ConfigPeersElemRoutesElem struct {
// Network specification.
Net string `json:"net"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ConfigPeersElemRoutesElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["net"]; raw != nil && !ok {
return fmt.Errorf("field net in ConfigPeersElemRoutesElem: required")
}
type Plain ConfigPeersElemRoutesElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = ConfigPeersElemRoutesElem(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ConfigPeersElem) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["id"]; raw != nil && !ok {
return fmt.Errorf("field id in ConfigPeersElem: required")
}
type Plain ConfigPeersElem
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if v, ok := raw["name"]; !ok || v == nil {
plain.Name = ""
}
if v, ok := raw["routes"]; !ok || v == nil {
plain.Routes = []ConfigPeersElemRoutesElem{}
}
*j = ConfigPeersElem(plain)
return nil
}
// The services this node provides via the Service Network.
type ConfigServices map[string]string
// UnmarshalJSON implements json.Unmarshaler.
func (j *Config) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["privateKey"]; raw != nil && !ok {
return fmt.Errorf("field privateKey in Config: required")
}
type Plain Config
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if v, ok := raw["listenAddresses"]; !ok || v == nil {
plain.ListenAddresses = []string{
"/ip4/0.0.0.0/tcp/8001",
"/ip4/0.0.0.0/udp/8001/quic-v1",
"/ip6/::/tcp/8001",
"/ip6/::/udp/8001/quic-v1",
}
}
if v, ok := raw["peers"]; !ok || v == nil {
plain.Peers = []ConfigPeersElem{}
}
if v, ok := raw["services"]; !ok || v == nil {
plain.Services = map[string]string{}
}
*j = Config(plain)
return nil
}

View File

@ -0,0 +1,60 @@
{
lib,
buildGoModule,
fetchFromGitHub,
writeShellScript,
nix-update,
nix,
}:
buildGoModule rec {
pname = "hyprspace";
version = "0.10.2";
src = fetchFromGitHub {
owner = "hyprspace";
repo = "hyprspace";
rev = "refs/tags/v${version}";
hash = "sha256-zWajCfHFqPa3Z72DHcxBUq4bmcCu1lpEKUbZZewpYOE=";
};
CGO_ENABLED = "0";
vendorHash = "sha256-LJpgGeD47Bs+Cq9Z7WWFa49F8/n3exOyxRcd6EkkL2g=";
ldflags = [
"-s"
"-w"
"-X github.com/hyprspace/hyprspace/cli.appVersion=${version}"
];
preBuild = ''
ln -s ${./config_generated.go} ./schema/config_generated.go
'';
passthru.updateScript = writeShellScript "update" ''
${lib.getExe nix-update} hyprspace
nix () {
${lib.getExe nix} --extra-experimental-features 'flakes nix-command' "$@"
}
cat "$(
nix build --print-out-paths --no-link \
"github:hyprspace/hyprspace?ref=refs/tags/v$(
nix eval .#hyprspace.version --raw
)#vendor"
)/schema/config_generated.go" \
> pkgs/by-name/hy/hyprspace/config_generated.go
'';
meta = {
description = "Lightweight VPN Built on top of Libp2p for Truly Distributed Networks";
homepage = "https://github.com/hyprspace/hyprspace";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
gerg-l
max
];
platforms = lib.platforms.linux;
mainProgram = "hyprspace";
};
}

View File

@ -608,7 +608,6 @@ mapAliases ({
hll2390dw-cups = throw "The hll2390dw-cups package was dropped since it was unmaintained."; # Added 2024-06-21
ht-rust = xh; # Added 2021-02-13
hydra-unstable = hydra_unstable; # added 2022-05-10
hyprspace = throw "hyprspace has been removed from nixpkgs because it is broken"; # Added 2024-07-15
hyper-haskell = throw "'hyper-haskell' has been removed. reason: has been broken for a long time and depends on an insecure electron version"; # Added 2024-03-14
hyper-haskell-server-with-packages = throw "'hyper-haskell-server-with-packages' has been removed. reason: has been broken for a long time"; # Added 2024-03-14