Compare commits
2 Commits
1dc22701cd
...
5061fb5670
Author | SHA1 | Date | |
---|---|---|---|
|
5061fb5670 | ||
|
17fb9bbd77 |
86
default.nix
86
default.nix
@ -1,51 +1,36 @@
|
||||
{
|
||||
|
||||
pkgsAttrs ? (import ./nix/pkgs.nix),
|
||||
bootstrap ? null,
|
||||
releaseName ? "debug",
|
||||
pkgs,
|
||||
garage,
|
||||
selfRev,
|
||||
hostSystem,
|
||||
#buildSystem,
|
||||
|
||||
}: let
|
||||
}: rec {
|
||||
|
||||
pkgs = pkgsAttrs.pkgs;
|
||||
|
||||
in rec {
|
||||
|
||||
rootedBootstrap = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-rooted-bootstrap";
|
||||
|
||||
src = bootstrap;
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
mkdir -p "$out"/share
|
||||
cp "$src" "$out"/share/bootstrap.yml
|
||||
'';
|
||||
};
|
||||
inherit garage;
|
||||
|
||||
version = pkgs.stdenv.mkDerivation {
|
||||
name = "cryptic-net-version";
|
||||
|
||||
buildInputs = [ pkgs.git pkgs.go ];
|
||||
inherit selfRev hostSystem;
|
||||
src = ./version.txt;
|
||||
garageVersion = garage.version;
|
||||
|
||||
src = ./.;
|
||||
inherit releaseName;
|
||||
nixPkgsVersion = pkgsAttrs.version;
|
||||
nixPkgsRev = pkgsAttrs.rev;
|
||||
builtByUser = builtins.getEnv "USER";
|
||||
nativeBuildInputs = [ pkgs.go ];
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
|
||||
versionFile=version
|
||||
|
||||
cp -r "$src" srcCp
|
||||
cat "$src" >> "$versionFile"
|
||||
echo "" >> "$versionFile"
|
||||
|
||||
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"
|
||||
echo "System: $hostSystem" >> "$versionFile"
|
||||
echo "Git Revision: $selfRev" >> "$versionFile"
|
||||
echo "Go Version: $(go version)" >> "$versionFile"
|
||||
echo "Garage Version: $garageVersion" >> "$versionFile"
|
||||
|
||||
mkdir -p "$out"/share
|
||||
cp "$versionFile" "$out"/share
|
||||
@ -55,15 +40,11 @@ in rec {
|
||||
entrypoint = pkgs.callPackage ./entrypoint {};
|
||||
|
||||
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
||||
glibcStatic = pkgs.glibc.static;
|
||||
stdenv = pkgs.pkgsStatic.stdenv;
|
||||
});
|
||||
|
||||
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 = [
|
||||
@ -75,7 +56,7 @@ in rec {
|
||||
garage
|
||||
entrypoint
|
||||
|
||||
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
|
||||
];
|
||||
};
|
||||
|
||||
appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};
|
||||
@ -84,29 +65,42 @@ in rec {
|
||||
name = "cryptic-net-AppImage";
|
||||
src = appDir;
|
||||
|
||||
buildInputs = [ appimagetool ];
|
||||
nativeBuildInputs = [
|
||||
appimagetool
|
||||
pkgs.file
|
||||
pkgs.fuse
|
||||
];
|
||||
|
||||
ARCH = "x86_64";
|
||||
|
||||
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)
|
||||
'';
|
||||
};
|
||||
|
163
flake.lock
Normal file
163
flake.lock
Normal file
@ -0,0 +1,163 @@
|
||||
{
|
||||
"nodes": {
|
||||
"cargo2nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"garage",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1666087781,
|
||||
"narHash": "sha256-trKVdjMZ8mNkGfLcY5LsJJGtdV3xJDZnMVrkFjErlcs=",
|
||||
"owner": "Alexis211",
|
||||
"repo": "cargo2nix",
|
||||
"rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Alexis211",
|
||||
"repo": "cargo2nix",
|
||||
"rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"garage": {
|
||||
"inputs": {
|
||||
"cargo2nix": "cargo2nix",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1672666365,
|
||||
"narHash": "sha256-lpNp/jw4YaczG3NM3pVWR0cZ8u/KBQCWvvfAswO4+Do=",
|
||||
"ref": "main",
|
||||
"rev": "76230f20282e73a5a5afa33af68152acaf732cf5",
|
||||
"revCount": 1007,
|
||||
"type": "git",
|
||||
"url": "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"
|
||||
},
|
||||
"original": {
|
||||
"ref": "main",
|
||||
"rev": "76230f20282e73a5a5afa33af68152acaf732cf5",
|
||||
"type": "git",
|
||||
"url": "https://git.deuxfleurs.fr/Deuxfleurs/garage.git"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1665657542,
|
||||
"narHash": "sha256-mojxNyzbvmp8NtVtxqiHGhRfjCALLfk9i/Uup68Y5q8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a3073c49bc0163fea6a121c276f526837672b555",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a3073c49bc0163fea6a121c276f526837672b555",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pkgsSrc": {
|
||||
"locked": {
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-22.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"garage": "garage",
|
||||
"pkgsSrc": "pkgsSrc",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"garage",
|
||||
"cargo2nix",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"garage",
|
||||
"cargo2nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1664247556,
|
||||
"narHash": "sha256-J4vazHU3609ekn7dr+3wfqPo5WGlZVAgV7jfux352L0=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "524db9c9ea7bc7743bb74cdd45b6d46ea3fcc2ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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
|
||||
}
|
53
flake.nix
Normal file
53
flake.nix
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
|
||||
inputs.pkgsSrc.url = "nixpkgs/nixos-22.05";
|
||||
|
||||
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";
|
||||
|
||||
outputs = {
|
||||
|
||||
self, pkgsSrc, utils, garage,
|
||||
|
||||
}: let
|
||||
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
#"aarch64-linux"
|
||||
#"armv7l-linux" # rpi, I think?
|
||||
#"i686-linux"
|
||||
];
|
||||
|
||||
in utils.lib.eachSystem supportedSystems (system: let
|
||||
|
||||
pkgs = import pkgsSrc {
|
||||
inherit system;
|
||||
|
||||
#crossSystem = {
|
||||
# config = system;
|
||||
#};
|
||||
|
||||
overlays = [
|
||||
(import ./nix/overlays/go_1_18.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";
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
defaultPackage = defaultAttrs.appImage;
|
||||
|
||||
});
|
||||
}
|
@ -1,17 +1,58 @@
|
||||
{
|
||||
# Modified from https://github.com/matthewbauer/nix-bundle/blob/e9fa7e8a118942adafa8592a28b301ee23d37c13/appimagetool.nix
|
||||
{ stdenv, lib, fetchurl, fuse, zlib, file, glib, }:
|
||||
|
||||
fetchFromGitHub,
|
||||
callPackage,
|
||||
# This is from some binaries.
|
||||
|
||||
}: let
|
||||
# Ideally, this should be source based,
|
||||
# but I can't get it to build from GitHub
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "matthewbauer";
|
||||
repo = "nix-bundle";
|
||||
rev = "223f4ffc4179aa318c34dc873a08cb00090db829";
|
||||
sha256 = "0pqpx9vnjk9h24h9qlv4la76lh5ykljch6g487b26r1r2s9zg7kh";
|
||||
};
|
||||
let
|
||||
|
||||
in
|
||||
inherit (stdenv.cc.bintools) dynamicLinker;
|
||||
|
||||
callPackage "${src}/appimagetool.nix" {}
|
||||
version = "745";
|
||||
|
||||
cpuArch = stdenv.buildPlatform.parsed.cpu.arch;
|
||||
|
||||
src = {
|
||||
|
||||
"x86-64" = fetchurl {
|
||||
url = "https://github.com/probonopd/go-appimage/releases/download/continuous/appimagetool-${version}-x86_64.AppImage";
|
||||
sha256 = "sha256-HQ7d9LQDaPm6sGZ5boWZdmGTNqiGN9NWHUWPiDhl2Xc=";
|
||||
};
|
||||
|
||||
# TODO other archs
|
||||
|
||||
}."${cpuArch}";
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
inherit version src;
|
||||
|
||||
pname = "go-appimage";
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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 +0,0 @@
|
||||
{
|
||||
|
||||
fetchgit,
|
||||
buildEnv,
|
||||
minio-client,
|
||||
|
||||
}: let
|
||||
|
||||
version = "0.8.0-unstable";
|
||||
|
||||
src = fetchgit {
|
||||
name = "garage-v${version}";
|
||||
url = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git";
|
||||
rev = "293139a94a8911aaac1b650e4707379a972196aa";
|
||||
sha256 = "sha256-b6HHLnxMdmpngiywll6Egr8O9/4cqBN01Mj3OwVMeBc=";
|
||||
};
|
||||
|
||||
in rec {
|
||||
|
||||
garage = (import "${src}/default.nix") { git_version = version; };
|
||||
|
||||
minioClient = minio-client;
|
||||
|
||||
env = buildEnv {
|
||||
name = "cryptic-net-garage";
|
||||
paths = [
|
||||
garage.pkgs.amd64.release
|
||||
minioClient
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
21
nix/overlays/go_1_18.nix
Normal file
21
nix/overlays/go_1_18.nix
Normal file
@ -0,0 +1,21 @@
|
||||
# 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);
|
||||
|
||||
}
|
||||
)
|
38
nix/pkgs.nix
38
nix/pkgs.nix
@ -1,38 +0,0 @@
|
||||
rec {
|
||||
|
||||
overlays = [
|
||||
|
||||
# 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);
|
||||
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
version = "22-05";
|
||||
rev = "2aec372cdcd4d73b94863611fea70e0884270fdc";
|
||||
|
||||
src = fetchTarball {
|
||||
name = "nixpkgs-${version}";
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
||||
sha256 = "1pbfhlh4v8l70p44gspsci3i6w0wk70vaisiawg3jhka2nxb8367";
|
||||
};
|
||||
|
||||
pkgs = import src { inherit overlays; };
|
||||
}
|
1
version.txt
Normal file
1
version.txt
Normal file
@ -0,0 +1 @@
|
||||
Release: 0.0.1
|
Loading…
Reference in New Issue
Block a user