Compare commits
10 Commits
1dc22701cd
...
e9190e4dbb
Author | SHA1 | Date | |
---|---|---|---|
|
e9190e4dbb | ||
|
94c6ad8774 | ||
|
8e800951a6 | ||
|
b7d49bff5b | ||
|
1354c96ba9 | ||
|
a8856fba99 | ||
|
1379291c1e | ||
|
05f9064d10 | ||
|
5061fb5670 | ||
|
17fb9bbd77 |
145
default.nix
145
default.nix
@ -1,15 +1,81 @@
|
||||
{
|
||||
|
||||
pkgsAttrs ? (import ./nix/pkgs.nix),
|
||||
bootstrap ? null,
|
||||
buildSystem ? builtins.currentSystem,
|
||||
hostSystem ? builtins.currentSystem,
|
||||
|
||||
revision ? "",
|
||||
releaseName ? "debug",
|
||||
|
||||
bootstrap ? null,
|
||||
|
||||
}: let
|
||||
|
||||
pkgs = pkgsAttrs.pkgs;
|
||||
pkgsNix = (import ./nix/pkgs.nix);
|
||||
|
||||
pkgs = pkgsNix.default {
|
||||
inherit buildSystem hostSystem;
|
||||
};
|
||||
|
||||
garageNix = (import ./nix/garage.nix);
|
||||
|
||||
in rec {
|
||||
|
||||
version = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-version";
|
||||
|
||||
inherit buildSystem revision releaseName;
|
||||
repoSrc = ./.;
|
||||
|
||||
nativeBuildInputs = [ pkgs.git ];
|
||||
|
||||
goVersion = pkgs.go.version;
|
||||
garageVersion = garageNix.version;
|
||||
nixpkgsVersion = pkgsNix.version;
|
||||
|
||||
release = "${releaseName}-${hostSystem}";
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
|
||||
versionFile=version
|
||||
|
||||
if [ "$revision" = "" ]; then
|
||||
cp -r "$repoSrc" repoSrcCp
|
||||
revision="$(cd repoSrcCp && git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
echo "Release $release" >> "$versionFile"
|
||||
echo "Git Revision: $revision" >> "$versionFile"
|
||||
echo "Go Version: $goVersion" >> "$versionFile"
|
||||
echo "Garage Version: $garageVersion" >> "$versionFile"
|
||||
echo "NixPkgs Version: $nixpkgsVersion" >> "$versionFile"
|
||||
echo "Build Platform: $buildSystem" >> "$versionFile"
|
||||
|
||||
mkdir -p "$out"/share
|
||||
cp "$versionFile" "$out"/share
|
||||
'';
|
||||
};
|
||||
|
||||
entrypoint = pkgs.callPackage ./entrypoint {};
|
||||
|
||||
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
||||
stdenv = pkgs.pkgsStatic.stdenv;
|
||||
});
|
||||
|
||||
nebula = pkgs.callPackage ./nix/nebula.nix {};
|
||||
|
||||
garage = let
|
||||
|
||||
hostPlatform = pkgs.stdenv.hostPlatform.parsed;
|
||||
|
||||
in pkgs.callPackage garageNix.package {
|
||||
|
||||
inherit buildSystem;
|
||||
hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl";
|
||||
pkgsSrc = pkgsNix.src;
|
||||
|
||||
};
|
||||
|
||||
rootedBootstrap = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-rooted-bootstrap";
|
||||
|
||||
@ -22,48 +88,6 @@ in rec {
|
||||
'';
|
||||
};
|
||||
|
||||
version = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-version";
|
||||
|
||||
buildInputs = [ pkgs.git pkgs.go ];
|
||||
|
||||
src = ./.;
|
||||
inherit releaseName;
|
||||
nixPkgsVersion = pkgsAttrs.version;
|
||||
nixPkgsRev = pkgsAttrs.rev;
|
||||
builtByUser = builtins.getEnv "USER";
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
|
||||
versionFile=version
|
||||
|
||||
cp -r "$src" srcCp
|
||||
|
||||
echo "Release: $releaseName" >> "$versionFile"
|
||||
echo "Git Revision: $(cd srcCp && git rev-parse HEAD)" >> "$versionFile"
|
||||
echo "Build date: $(date) ($(date +%s))" >> "$versionFile"
|
||||
echo "Built by: $builtByUser" >> "$versionFile"
|
||||
echo "Go version: $(go version)" >> "$versionFile"
|
||||
echo "Nixpkgs version: $nixPkgsVersion ($nixPkgsRev)" >> "$versionFile"
|
||||
|
||||
mkdir -p "$out"/share
|
||||
cp "$versionFile" "$out"/share
|
||||
'';
|
||||
};
|
||||
|
||||
entrypoint = pkgs.callPackage ./entrypoint {};
|
||||
|
||||
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
||||
glibcStatic = pkgs.glibc.static;
|
||||
});
|
||||
|
||||
nebula = pkgs.callPackage ./nix/nebula.nix {};
|
||||
|
||||
garage = (pkgs.callPackage ./nix/garage.nix {}).env;
|
||||
|
||||
waitFor = pkgs.callPackage ./nix/wait-for.nix {};
|
||||
|
||||
appDir = pkgs.buildEnv {
|
||||
name = "cryptic-net-AppDir";
|
||||
paths = [
|
||||
@ -73,6 +97,7 @@ in rec {
|
||||
dnsmasq
|
||||
nebula
|
||||
garage
|
||||
pkgs.minio-client
|
||||
entrypoint
|
||||
|
||||
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
|
||||
@ -84,29 +109,41 @@ in rec {
|
||||
name = "cryptic-net-AppImage";
|
||||
src = appDir;
|
||||
|
||||
buildInputs = [ appimagetool ];
|
||||
nativeBuildInputs = [
|
||||
appimagetool
|
||||
];
|
||||
|
||||
ARCH = "x86_64";
|
||||
ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
||||
|
||||
builder = builtins.toFile "build.sh" ''
|
||||
source $stdenv/setup
|
||||
cp -rL "$src" cryptic-net
|
||||
chmod +w cryptic-net -R
|
||||
appimagetool cryptic-net "$out"
|
||||
cp -rL "$src" cryptic-net.AppDir
|
||||
chmod +w cryptic-net.AppDir -R
|
||||
|
||||
export VERSION=debug
|
||||
|
||||
# https://github.com/probonopd/go-appimage/issues/155
|
||||
unset SOURCE_DATE_EPOCH
|
||||
|
||||
appimagetool ./cryptic-net.AppDir
|
||||
|
||||
mkdir -p "$out"/bin
|
||||
chmod +w "$out" -R
|
||||
mv Cryptic_Net-* "$out"/bin/cryptic-net
|
||||
'';
|
||||
};
|
||||
|
||||
release = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-AppImage";
|
||||
inherit appImage releaseName;
|
||||
name = "cryptic-net-release";
|
||||
inherit appImage;
|
||||
|
||||
buildInputs = [ pkgs.coreutils ];
|
||||
nativeBuildInputs = [ pkgs.coreutils ];
|
||||
|
||||
builder = builtins.toFile "build.sh" ''
|
||||
source $stdenv/setup
|
||||
|
||||
mkdir -p "$out"
|
||||
cp "$appImage" "$out"/cryptic-net-$releaseName-linux-amd64
|
||||
cp "$appImage" "$out"/cryptic-net
|
||||
(cd "$out" && sha256sum * > sha256.txt)
|
||||
'';
|
||||
};
|
||||
|
@ -3,7 +3,16 @@
|
||||
This document will guide you through the process of obtaining a cryptic-net
|
||||
binary and joining the network.
|
||||
|
||||
NOTE currently only linux machines with amd64/x86_64 processors are supported.
|
||||
NOTE currently only linux machines with the following architectures are
|
||||
supported:
|
||||
|
||||
- `x86_64` / `amd64`
|
||||
- `aarch64` / `arm64`
|
||||
- `armv7l` (Raspberry Pi)
|
||||
- `i686`
|
||||
|
||||
(Only `x86_64` has been tested.)
|
||||
|
||||
More OSs and architectures coming soon!
|
||||
|
||||
## Obtaining a cryptic-net Binary
|
||||
|
26
flake.lock
Normal file
26
flake.lock
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"nodes": {
|
||||
"root": {
|
||||
"inputs": {
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
49
flake.nix
Normal file
49
flake.nix
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
inputs.utils.url = "github:numtide/flake-utils";
|
||||
|
||||
description = "cryptic-net provides the foundation for an autonomous community cloud infrastructure";
|
||||
|
||||
outputs = {
|
||||
self, utils,
|
||||
}: let
|
||||
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"armv7l-linux" # rpi, I think?
|
||||
"i686-linux"
|
||||
];
|
||||
|
||||
mkPkg = (buildSystem: hostSystem: let
|
||||
|
||||
defaultAttrs = (import ./default.nix) {
|
||||
inherit hostSystem buildSystem;
|
||||
revision = if self ? rev then self.rev else "dirty";
|
||||
releaseName = "flake";
|
||||
};
|
||||
|
||||
in
|
||||
defaultAttrs.appImage
|
||||
);
|
||||
|
||||
#pkgsForBuildSystem = (buildSystem: builtins.foldl'
|
||||
# (sysPkgs: hostSystem:
|
||||
# sysPkgs // { "compiled-for-${hostSystem}" = mkPkg buildSystem hostSystem; })
|
||||
# { default = mkPkg buildSystem buildSystem; }
|
||||
# supportedSystems
|
||||
#);
|
||||
|
||||
pkgsForBuildSystem = (buildSystem:
|
||||
{ default = mkPkg buildSystem buildSystem; });
|
||||
|
||||
in {
|
||||
|
||||
packages = (builtins.foldl'
|
||||
(pkgs: buildSystem:
|
||||
pkgs // { "${buildSystem}" = pkgsForBuildSystem buildSystem; })
|
||||
{}
|
||||
supportedSystems
|
||||
);
|
||||
|
||||
};
|
||||
}
|
@ -1,17 +1,50 @@
|
||||
{
|
||||
{ stdenv, fetchurl }:
|
||||
|
||||
fetchFromGitHub,
|
||||
callPackage,
|
||||
let
|
||||
|
||||
}: let
|
||||
version = "745";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "matthewbauer";
|
||||
repo = "nix-bundle";
|
||||
rev = "223f4ffc4179aa318c34dc873a08cb00090db829";
|
||||
sha256 = "0pqpx9vnjk9h24h9qlv4la76lh5ykljch6g487b26r1r2s9zg7kh";
|
||||
};
|
||||
cpuArch = stdenv.buildPlatform.parsed.cpu.name;
|
||||
|
||||
in
|
||||
src = {
|
||||
|
||||
callPackage "${src}/appimagetool.nix" {}
|
||||
"x86_64" = fetchurl {
|
||||
url = "https://github.com/probonopd/go-appimage/releases/download/continuous/appimagetool-${version}-x86_64.AppImage";
|
||||
sha256 = "sha256-HQ7d9LQDaPm6sGZ5boWZdmGTNqiGN9NWHUWPiDhl2Xc=";
|
||||
};
|
||||
|
||||
"aarch64" = fetchurl {
|
||||
url = "https://github.com/probonopd/go-appimage/releases/download/continuous/appimagetool-${version}-aarch64.AppImage";
|
||||
sha256 = "sha256-VvH2qXULliCiyFrisaIJbM0ApXp++ZAtxHiS6FM3XT0=";
|
||||
};
|
||||
|
||||
"armv7l" = fetchurl {
|
||||
url = "https://github.com/probonopd/go-appimage/releases/download/continuous/appimagetool-${version}-armhf.AppImage";
|
||||
sha256 = "sha256-ytJjN2dLYOSwqCCFZvqnt+wt2wX/lZ1R+nVz5C+Akvo=";
|
||||
};
|
||||
|
||||
"i686" = fetchurl {
|
||||
url = "https://github.com/probonopd/go-appimage/releases/download/continuous/appimagetool-${version}-i686.AppImage";
|
||||
sha256 = "sha256-GLEhn3dcrwdU3mG0lB6H7PQ5JwEIGqWlGrO1IifeQv4=";
|
||||
};
|
||||
|
||||
}."${cpuArch}";
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
|
||||
pname = "go-appimage";
|
||||
inherit version src;
|
||||
|
||||
sourceRoot = "squashfs-root";
|
||||
|
||||
unpackPhase = ''
|
||||
cp $src appimagetool
|
||||
chmod u+wx appimagetool
|
||||
./appimagetool --appimage-extract
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r usr/* $out
|
||||
'';
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
|
||||
stdenv,
|
||||
glibcStatic,
|
||||
|
||||
}: stdenv.mkDerivation rec {
|
||||
|
||||
@ -13,11 +12,7 @@
|
||||
sha256 = "sha256-rZjTgD32h+W5OAgPPSXGKP5ByHh1LQP7xhmXh/7jEvo=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ glibcStatic ];
|
||||
|
||||
makeFlags = [
|
||||
"LDFLAGS=-static"
|
||||
"DESTDIR="
|
||||
"BINDIR=$(out)/bin"
|
||||
"MANDIR=$(out)/man"
|
||||
"LOCALEDIR=$(out)/share/locale"
|
||||
|
@ -1,33 +1,33 @@
|
||||
{
|
||||
rec {
|
||||
|
||||
fetchgit,
|
||||
buildEnv,
|
||||
minio-client,
|
||||
version = "0.8.1";
|
||||
|
||||
}: let
|
||||
|
||||
version = "0.8.0-unstable";
|
||||
|
||||
src = fetchgit {
|
||||
src = builtins.fetchGit {
|
||||
name = "garage-v${version}";
|
||||
url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git";
|
||||
rev = "293139a94a8911aaac1b650e4707379a972196aa";
|
||||
sha256 = "sha256-b6HHLnxMdmpngiywll6Egr8O9/4cqBN01Mj3OwVMeBc=";
|
||||
rev = "76230f20282e73a5a5afa33af68152acaf732cf5";
|
||||
};
|
||||
|
||||
in rec {
|
||||
package = {
|
||||
pkgsSrc,
|
||||
buildSystem,
|
||||
hostSystem,
|
||||
}: let
|
||||
|
||||
garage = (import "${src}/default.nix") { git_version = version; };
|
||||
compile = (import "${src}/nix/compile.nix") {
|
||||
|
||||
minioClient = minio-client;
|
||||
system = buildSystem;
|
||||
target = hostSystem;
|
||||
pkgsSrc = pkgsSrc;
|
||||
|
||||
env = buildEnv {
|
||||
name = "cryptic-net-garage";
|
||||
paths = [
|
||||
garage.pkgs.amd64.release
|
||||
minioClient
|
||||
];
|
||||
};
|
||||
cargo2nixOverlay = (import "${src}/nix/common.nix").cargo2nixOverlay;
|
||||
|
||||
release = true;
|
||||
git_version = version;
|
||||
};
|
||||
|
||||
in
|
||||
compile.workspace.garage {
|
||||
compileMode = "build";
|
||||
};
|
||||
}
|
||||
|
||||
|
54
nix/pkgs.nix
54
nix/pkgs.nix
@ -2,37 +2,45 @@ rec {
|
||||
|
||||
overlays = [
|
||||
|
||||
# Make buildGoModules use static compilation by default, and use go 1.18
|
||||
# everywhere.
|
||||
(final: prev:
|
||||
# Make buildGoModules use static compilation by default
|
||||
(final: prev: let
|
||||
buildArgs = {
|
||||
doCheck = false;
|
||||
CGO_ENABLED=0;
|
||||
tags = [ "netgo" "timetzdata" ];
|
||||
ldflags = [ "-w" "-extldflags=-static" ];
|
||||
};
|
||||
in {
|
||||
buildGoModule = args: prev.buildGoModule (buildArgs // args);
|
||||
})
|
||||
|
||||
let
|
||||
# for whatever reason git checks fail when flake is being used (or maybe
|
||||
# it's crossSystem's fault)
|
||||
(final: prev: {
|
||||
git = prev.git.overrideAttrs (oldAttrs: {
|
||||
installCheckPhase = ''
|
||||
# noop
|
||||
'';
|
||||
});
|
||||
})
|
||||
|
||||
buildArgs = {
|
||||
doCheck = false;
|
||||
CGO_ENABLED=0;
|
||||
tags = [ "netgo" "timetzdata" ];
|
||||
ldflags = [ "-w" "-extldflags=-static" ];
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
go = prev.go_1_18;
|
||||
buildGoModule = args: prev.buildGo118Module (buildArgs // args);
|
||||
buildGo118Module = args: prev.buildGo118Module (buildArgs // args);
|
||||
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
version = "22-05";
|
||||
rev = "2aec372cdcd4d73b94863611fea70e0884270fdc";
|
||||
version = "22.11";
|
||||
rev = "ce20e9ebe1903ea2ba1ab006ec63093020c761cb";
|
||||
|
||||
src = fetchTarball {
|
||||
name = "nixpkgs-${version}";
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
||||
sha256 = "1pbfhlh4v8l70p44gspsci3i6w0wk70vaisiawg3jhka2nxb8367";
|
||||
sha256 = "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc=";
|
||||
};
|
||||
|
||||
pkgs = import src { inherit overlays; };
|
||||
default = {
|
||||
buildSystem,
|
||||
hostSystem,
|
||||
}: import src {
|
||||
system = buildSystem;
|
||||
crossSystem.config = hostSystem;
|
||||
inherit overlays;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user