Compare commits
3 Commits
5061fb5670
...
a8856fba99
Author | SHA1 | Date | |
---|---|---|---|
|
a8856fba99 | ||
|
1379291c1e | ||
|
05f9064d10 |
14
default.nix
14
default.nix
@ -1,10 +1,12 @@
|
||||
{
|
||||
|
||||
# TODO make this usable again! Add sane defaults for inputs, and allow for
|
||||
# injecting a bootstrap file.
|
||||
|
||||
pkgs,
|
||||
garage,
|
||||
selfRev,
|
||||
hostSystem,
|
||||
#buildSystem,
|
||||
|
||||
}: rec {
|
||||
|
||||
@ -15,9 +17,12 @@
|
||||
|
||||
inherit selfRev hostSystem;
|
||||
src = ./version.txt;
|
||||
|
||||
garageVersion = garage.version;
|
||||
|
||||
nativeBuildInputs = [ pkgs.go ];
|
||||
# TODO it'd be nice to be able to call `go version`, but that doesn't work
|
||||
# when crossSystem is being used for some unknown reason.
|
||||
goVersion = pkgs.go.version;
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
@ -29,7 +34,7 @@
|
||||
|
||||
echo "System: $hostSystem" >> "$versionFile"
|
||||
echo "Git Revision: $selfRev" >> "$versionFile"
|
||||
echo "Go Version: $(go version)" >> "$versionFile"
|
||||
echo "Go Version: $goVersion" >> "$versionFile"
|
||||
echo "Garage Version: $garageVersion" >> "$versionFile"
|
||||
|
||||
mkdir -p "$out"/share
|
||||
@ -67,8 +72,6 @@
|
||||
|
||||
nativeBuildInputs = [
|
||||
appimagetool
|
||||
pkgs.file
|
||||
pkgs.fuse
|
||||
];
|
||||
|
||||
ARCH = "x86_64";
|
||||
@ -82,6 +85,7 @@
|
||||
|
||||
# https://github.com/probonopd/go-appimage/issues/155
|
||||
unset SOURCE_DATE_EPOCH
|
||||
|
||||
appimagetool ./cryptic-net.AppDir
|
||||
|
||||
mkdir -p "$out"/bin
|
||||
|
@ -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
|
||||
|
@ -95,16 +95,16 @@
|
||||
},
|
||||
"pkgsSrc": {
|
||||
"locked": {
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"lastModified": 1674868155,
|
||||
"narHash": "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"rev": "ce20e9ebe1903ea2ba1ab006ec63093020c761cb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-22.05",
|
||||
"ref": "nixos-22.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
|
79
flake.nix
79
flake.nix
@ -1,14 +1,13 @@
|
||||
{
|
||||
|
||||
inputs.pkgsSrc.url = "nixpkgs/nixos-22.05";
|
||||
inputs.pkgsSrc.url = "nixpkgs/nixos-22.11";
|
||||
|
||||
inputs.utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# v0.8.1
|
||||
inputs.garage.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?ref=main&rev=76230f20282e73a5a5afa33af68152acaf732cf5";
|
||||
|
||||
description = "cryptic-net provides the foundation for an autonomous community
|
||||
cloud infrastructure";
|
||||
description = "cryptic-net provides the foundation for an autonomous community cloud infrastructure";
|
||||
|
||||
outputs = {
|
||||
|
||||
@ -18,36 +17,66 @@ cloud infrastructure";
|
||||
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
#"aarch64-linux"
|
||||
#"armv7l-linux" # rpi, I think?
|
||||
#"i686-linux"
|
||||
"aarch64-linux"
|
||||
"armv7l-linux" # rpi, I think?
|
||||
"i686-linux"
|
||||
];
|
||||
|
||||
in utils.lib.eachSystem supportedSystems (system: let
|
||||
mkPkg = (buildSystem: hostSystem: let
|
||||
|
||||
pkgs = import pkgsSrc {
|
||||
inherit system;
|
||||
pkgs = import pkgsSrc {
|
||||
system = buildSystem;
|
||||
|
||||
#crossSystem = {
|
||||
# config = system;
|
||||
#};
|
||||
crossSystem = {
|
||||
config = hostSystem;
|
||||
};
|
||||
|
||||
overlays = [
|
||||
(import ./nix/overlays/go_1_18.nix)
|
||||
];
|
||||
};
|
||||
overlays = [
|
||||
(import ./nix/overlays/go.nix)
|
||||
];
|
||||
};
|
||||
|
||||
defaultAttrs = (import ./default.nix) {
|
||||
inherit pkgs;
|
||||
hostSystem = system;
|
||||
#buildSystem = self.system;
|
||||
garage = garage.packages."${system}".default;
|
||||
selfRev = if self ? rev then self.rev else "UNKNOWN";
|
||||
};
|
||||
defaultAttrs = (import ./default.nix) {
|
||||
inherit pkgs;
|
||||
hostSystem = hostSystem;
|
||||
garage = garage.packages."${hostSystem}".default;
|
||||
selfRev = if self ? rev then self.rev else "UNKNOWN";
|
||||
};
|
||||
|
||||
in
|
||||
defaultAttrs.garage
|
||||
);
|
||||
|
||||
# TODO Once everything else is prepared for cross compilation this can be
|
||||
# re-enabled. Things left to do:
|
||||
#
|
||||
# - Revert to not using flake for garage, we'll need to compile it
|
||||
# ourselves because flakes don't actually support cross-compilation in a
|
||||
# nice way.
|
||||
#
|
||||
# - Set ARCH arg for appimagetool target in default.nix
|
||||
#
|
||||
# - Test builds in QEMU or something.
|
||||
#
|
||||
# - Probably other things which will come up
|
||||
#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 {
|
||||
|
||||
defaultPackage = defaultAttrs.appImage;
|
||||
packages = (builtins.foldl'
|
||||
(pkgs: buildSystem:
|
||||
pkgs // { "${buildSystem}" = pkgsForBuildSystem buildSystem; })
|
||||
{}
|
||||
supportedSystems
|
||||
);
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,18 +1,10 @@
|
||||
# Modified from https://github.com/matthewbauer/nix-bundle/blob/e9fa7e8a118942adafa8592a28b301ee23d37c13/appimagetool.nix
|
||||
{ stdenv, lib, fetchurl, fuse, zlib, file, glib, }:
|
||||
|
||||
# This is from some binaries.
|
||||
|
||||
# Ideally, this should be source based,
|
||||
# but I can't get it to build from GitHub
|
||||
{ stdenv, fetchurl }:
|
||||
|
||||
let
|
||||
|
||||
inherit (stdenv.cc.bintools) dynamicLinker;
|
||||
|
||||
version = "745";
|
||||
|
||||
cpuArch = stdenv.buildPlatform.parsed.cpu.arch;
|
||||
cpuArch = stdenv.buildPlatform.parsed.cpu.name;
|
||||
|
||||
src = {
|
||||
|
||||
@ -21,38 +13,38 @@ let
|
||||
sha256 = "sha256-HQ7d9LQDaPm6sGZ5boWZdmGTNqiGN9NWHUWPiDhl2Xc=";
|
||||
};
|
||||
|
||||
# TODO other archs
|
||||
"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 {
|
||||
inherit version src;
|
||||
|
||||
pname = "go-appimage";
|
||||
inherit version src;
|
||||
|
||||
sourceRoot = "squashfs-root";
|
||||
|
||||
unpackPhase = ''
|
||||
cp $src appimagetool
|
||||
chmod u+wx appimagetool
|
||||
#patchelf --set-interpreter ${dynamicLinker} \
|
||||
# --set-rpath ${fuse}/lib:${zlib}/lib \
|
||||
# appimagetool
|
||||
./appimagetool --appimage-extract
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
cp -r usr/* $out
|
||||
for x in $out/bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter ${dynamicLinker} \
|
||||
--set-rpath ${lib.makeLibraryPath [ zlib stdenv.glibc.out fuse glib ]} \
|
||||
$x || true
|
||||
done
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
}
|
||||
|
18
nix/overlays/go.nix
Normal file
18
nix/overlays/go.nix
Normal file
@ -0,0 +1,18 @@
|
||||
# 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);
|
||||
|
||||
}
|
||||
)
|
@ -1,21 +0,0 @@
|
||||
# Make buildGoModules use static compilation by default, and use go 1.18
|
||||
# everywhere.
|
||||
(final: prev:
|
||||
|
||||
let
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue
Block a user