Compare commits
No commits in common. "2919906843a001827610ef6cdcd88eaab321ce29" and "bd09a1ad7bc66ada76cf605bacf13b1fb1c54968" have entirely different histories.
2919906843
...
bd09a1ad7b
92
default.nix
92
default.nix
@ -6,15 +6,15 @@
|
||||
features ? null,
|
||||
}:
|
||||
|
||||
with import ./nix/common.nix;
|
||||
|
||||
let
|
||||
pkgsSrc = import ./nix/pkgs.nix;
|
||||
newBuildTarget = {
|
||||
nixPkgsSystem,
|
||||
rustTarget ? nixPkgsSystem,
|
||||
nativeBuildInputs ? pkgsCross: [],
|
||||
rustFlags ? pkgsCross: [],
|
||||
depsBuildBuild ? pkgsCross: [],
|
||||
}: {
|
||||
inherit nixPkgsSystem rustTarget nativeBuildInputs rustFlags;
|
||||
inherit nixPkgsSystem rustTarget depsBuildBuild;
|
||||
};
|
||||
|
||||
# centralize per-target configuration in a single place.
|
||||
@ -31,19 +31,18 @@ let
|
||||
nixPkgsSystem = "aarch64-unknown-linux-musl";
|
||||
};
|
||||
|
||||
# Old Raspberry Pi's (not currently supported due to linking errors with
|
||||
# libsqlite3 and libsodium
|
||||
#"armv6l-linux" = newBuildTarget {
|
||||
# nixPkgsSystem = "armv6l-unknown-linux-musleabihf";
|
||||
# rustTarget = "arm-unknown-linux-musleabihf";
|
||||
#};
|
||||
# Old Raspberry Pi's
|
||||
"armv6l-linux" = newBuildTarget {
|
||||
nixPkgsSystem = "armv6l-unknown-linux-musleabihf";
|
||||
rustTarget = "arm-unknown-linux-musleabihf";
|
||||
};
|
||||
|
||||
"x86_64-windows" = newBuildTarget {
|
||||
nixPkgsSystem = "x86_64-w64-mingw32";
|
||||
rustTarget = "x86_64-pc-windows-gnu";
|
||||
nativeBuildInputs = pkgsCross: [ pkgsCross.windows.pthreads ];
|
||||
rustFlags = pkgsCross: [
|
||||
"-C" "link-arg=-L${pkgsCross.windows.pthreads}/lib"
|
||||
depsBuildBuild = pkgsCross: [
|
||||
pkgsCross.stdenv.cc
|
||||
pkgsCross.windows.pthreads
|
||||
];
|
||||
};
|
||||
};
|
||||
@ -77,7 +76,6 @@ let
|
||||
(mkToolchain fenix).rustc
|
||||
(mkToolchain fenix).rustfmt
|
||||
(mkToolchain fenix).cargo
|
||||
(mkToolchain fenix).clippy
|
||||
(mkToolchain fenix.targets.${rustTarget}).rust-std
|
||||
];
|
||||
|
||||
@ -94,6 +92,28 @@ let
|
||||
rustc = toolchain;
|
||||
};
|
||||
|
||||
|
||||
# TODO build all of these
|
||||
#build_debug_and_release = (target: {
|
||||
# debug = (compile {
|
||||
# inherit system target gitVersion pkgsSrc cargo2nixOverlay;
|
||||
# release = false;
|
||||
# }).workspace.garage { compileMode = "build"; };
|
||||
|
||||
# release = (compile {
|
||||
# inherit system target gitVersion pkgsSrc cargo2nixOverlay;
|
||||
# release = true;
|
||||
# }).workspace.garage { compileMode = "build"; };
|
||||
#});
|
||||
|
||||
#test = (rustPkgs:
|
||||
# pkgs.symlinkJoin {
|
||||
# name = "garage-tests";
|
||||
# paths =
|
||||
# builtins.map (key: rustPkgs.workspace.${key} { compileMode = "test"; })
|
||||
# (builtins.attrNames rustPkgs.workspace);
|
||||
# });
|
||||
|
||||
builtFeatures = if features != null then
|
||||
features
|
||||
else (
|
||||
@ -103,6 +123,7 @@ let
|
||||
"garage/kubernetes-discovery"
|
||||
"garage/metrics"
|
||||
"garage/telemetry-otlp"
|
||||
"garage/lmdb"
|
||||
"garage/sqlite"
|
||||
] else [ ]
|
||||
)
|
||||
@ -122,20 +143,21 @@ let
|
||||
fi
|
||||
'';
|
||||
|
||||
in rec {
|
||||
inherit pkgs pkgsCross;
|
||||
|
||||
# Exported separately so it can be used from shell.nix
|
||||
buildEnv = rec {
|
||||
nativeBuildInputs = (buildTarget.nativeBuildInputs pkgsCross) ++ [
|
||||
nativeBuildInputs = (buildTarget.depsBuildBuild pkgsCross) ++ [
|
||||
toolchain
|
||||
pkgs.protobuf
|
||||
|
||||
# Required for shell because of rust dependency build scripts which must
|
||||
# run on the build system.
|
||||
pkgs.stdenv.cc
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
pkgsCross.stdenv.cc
|
||||
pkgsCross.windows.pthreads
|
||||
];
|
||||
|
||||
OPENSSL_STATIC = "1";
|
||||
OPENSSL_LIB_DIR = "${pkgsCross.pkgsStatic.openssl.out}/lib";
|
||||
OPENSSL_INCLUDE_DIR = "${pkgsCross.pkgsStatic.openssl.dev}/include";
|
||||
|
||||
SODIUM_LIB_DIR = "${libsodium}/lib";
|
||||
|
||||
# Required because ring crate is special. This also seems to have
|
||||
@ -145,14 +167,21 @@ in rec {
|
||||
CARGO_BUILD_TARGET = rustTarget;
|
||||
CARGO_BUILD_RUSTFLAGS = [
|
||||
"-C" "target-feature=+crt-static"
|
||||
"-C" "link-arg=-static"
|
||||
|
||||
# -latomic is required to build openssl-sys for armv6l-linux, but
|
||||
# it doesn't seem to hurt any other builds.
|
||||
"-C" "link-args=-static -latomic"
|
||||
|
||||
# https://github.com/rust-lang/cargo/issues/4133
|
||||
"-C" "linker=${TARGET_CC}"
|
||||
] ++ (buildTarget.rustFlags pkgsCross);
|
||||
];
|
||||
};
|
||||
|
||||
build = naersk.buildPackage (rec {
|
||||
in {
|
||||
|
||||
inherit pkgs pkgsCross;
|
||||
|
||||
release = naersk.buildPackage (rec {
|
||||
inherit release;
|
||||
|
||||
src = ./.;
|
||||
@ -163,4 +192,15 @@ in rec {
|
||||
"--features=${builtins.concatStringsSep "," builtFeatures}"
|
||||
];
|
||||
} // buildEnv);
|
||||
|
||||
shell = pkgsCross.mkShell buildEnv;
|
||||
|
||||
# TODO
|
||||
#clippy = {
|
||||
# amd64 = (compile {
|
||||
# inherit system gitVersion pkgsSrc cargo2nixOverlay;
|
||||
# target = "x86_64-unknown-linux-musl";
|
||||
# compiler = "clippy";
|
||||
# }).workspace.garage { compileMode = "build"; };
|
||||
#};
|
||||
}
|
||||
|
111
flake.lock
111
flake.lock
@ -1,5 +1,31 @@
|
||||
{
|
||||
"nodes": {
|
||||
"cargo2nix": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"flake-compat"
|
||||
],
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1688025799,
|
||||
@ -20,19 +46,54 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-utils",
|
||||
"type": "indirect"
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1682109806,
|
||||
"narHash": "sha256-d9g7RKNShMLboTWwukM+RObDWWpHKaqTYXB48clBWXI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2362848adf8def2866fabbffc50462e929d7fffb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1682423271,
|
||||
"narHash": "sha256-WHhl1GiOij1ob4cTLL+yhqr+vFOUH8E5wAX8Ir8fvjE=",
|
||||
@ -50,9 +111,32 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"cargo2nix": "cargo2nix",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-utils": [
|
||||
"cargo2nix",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682389182,
|
||||
"narHash": "sha256-8t2nmFnH+8V48+IJsf8AK51ebXNlVbOSVYOpiqJKvJE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "74f1a64dd28faeeb85ef081f32cad2989850322c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
@ -69,6 +153,21 @@
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"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",
|
||||
|
45
flake.nix
45
flake.nix
@ -8,23 +8,50 @@
|
||||
|
||||
inputs.flake-compat.url = "github:nix-community/flake-compat";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
inputs.cargo2nix = {
|
||||
# As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
|
||||
url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36";
|
||||
|
||||
# As of 2023-04-25:
|
||||
# - my two patches were merged into unstable (one for clippy and one to "fix" feature detection)
|
||||
# - rustc v1.66
|
||||
# url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2";
|
||||
|
||||
# Rust overlay as of 2023-04-25
|
||||
inputs.rust-overlay.url =
|
||||
"github:oxalica/rust-overlay/74f1a64dd28faeeb85ef081f32cad2989850322c";
|
||||
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-compat.follows = "flake-compat";
|
||||
};
|
||||
|
||||
inputs.flake-utils.follows = "cargo2nix/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, cargo2nix, flake-utils, ... }:
|
||||
let
|
||||
gitVersion = self.lastModifiedDate;
|
||||
git_version = self.lastModifiedDate;
|
||||
compile = import ./nix/compile.nix;
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
packages = {
|
||||
default = (import ./default.nix {
|
||||
inherit gitVersion;
|
||||
buildSystem = system;
|
||||
default = (compile {
|
||||
inherit system git_version;
|
||||
pkgsSrc = nixpkgs;
|
||||
cargo2nixOverlay = cargo2nix.overlays.default;
|
||||
release = true;
|
||||
}).build;
|
||||
}).workspace.garage { compileMode = "build"; };
|
||||
};
|
||||
devShell = (import ./shell.nix {
|
||||
buildSystem = system;
|
||||
}).rust;
|
||||
devShell = (compile {
|
||||
inherit system git_version;
|
||||
pkgsSrc = nixpkgs;
|
||||
cargo2nixOverlay = cargo2nix.overlays.default;
|
||||
release = false;
|
||||
}).workspaceShell { packages = with pkgs; [
|
||||
rustfmt
|
||||
clang
|
||||
mold
|
||||
]; };
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ path ? "/../aws-list.txt", }:
|
||||
|
||||
with import ./pkgs.nix;
|
||||
with import ./common.nix;
|
||||
let
|
||||
pkgs = import pkgsSrc { };
|
||||
lib = pkgs.lib;
|
||||
|
17
nix/common.nix
Normal file
17
nix/common.nix
Normal file
@ -0,0 +1,17 @@
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
|
||||
|
||||
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
|
||||
|
||||
flake-compat = fetchTarball {
|
||||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
|
||||
sha256 = narHash;
|
||||
};
|
||||
|
||||
flake = (import flake-compat { system = builtins.currentSystem; src = ../.; });
|
||||
in
|
||||
rec {
|
||||
pkgsSrc = flake.defaultNix.inputs.nixpkgs;
|
||||
cargo2nix = flake.defaultNix.inputs.cargo2nix;
|
||||
cargo2nixOverlay = cargo2nix.overlays.default;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
|
||||
inherit (lock.nodes.nixpkgs.locked) owner repo rev narHash;
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
|
||||
sha256 = narHash;
|
||||
}
|
33
shell.nix
33
shell.nix
@ -1,12 +1,12 @@
|
||||
{
|
||||
buildSystem ? builtins.currentSystem,
|
||||
targetSystem ? buildSystem,
|
||||
}:
|
||||
{ system ? builtins.currentSystem, }:
|
||||
|
||||
with import ./nix/pkgs.nix;
|
||||
with import ./nix/common.nix;
|
||||
|
||||
let
|
||||
inherit (import ./default.nix { inherit buildSystem targetSystem; }) pkgs pkgsCross buildEnv;
|
||||
pkgs = import pkgsSrc {
|
||||
inherit system;
|
||||
overlays = [ cargo2nixOverlay ];
|
||||
};
|
||||
kaniko = (import ./nix/kaniko.nix) pkgs;
|
||||
manifest-tool = (import ./nix/manifest-tool.nix) pkgs;
|
||||
winscp = (import ./nix/winscp.nix) pkgs;
|
||||
@ -14,13 +14,22 @@ let
|
||||
in {
|
||||
# --- Rust Shell ---
|
||||
# Use it to compile Garage
|
||||
rust = pkgsCross.mkShell (buildEnv // {
|
||||
inputsFrom = [
|
||||
kaniko
|
||||
manifest-tool
|
||||
winscp
|
||||
rust = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
#rustPlatform.rust.rustc
|
||||
rustPlatform.rust.cargo
|
||||
clang
|
||||
mold
|
||||
#clippy
|
||||
rustfmt
|
||||
#perl
|
||||
#protobuf
|
||||
#pkg-config
|
||||
#openssl
|
||||
file
|
||||
#cargo2nix.packages.x86_64-linux.cargo2nix
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
# --- Integration shell ---
|
||||
# Use it to test Garage with common S3 clients
|
||||
|
@ -978,7 +978,6 @@ impl NodeStatus {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn get_default_ip() -> Option<IpAddr> {
|
||||
pnet_datalink::interfaces()
|
||||
.iter()
|
||||
@ -987,11 +986,6 @@ fn get_default_ip() -> Option<IpAddr> {
|
||||
.map(|a| a.ip())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn get_default_ip() -> Option<IpAddr> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn resolve_peers(peers: &[String]) -> Vec<(NodeID, SocketAddr)> {
|
||||
let mut ret = vec![];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user