-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c630b33
commit 7672da8
Showing
10 changed files
with
412 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
/target | ||
result* | ||
pki/ | ||
bgpfu-junos-agent-x86-64-0.1.0-alpha.1.tgz | ||
.build/ | ||
flamegraph.svg | ||
perf.data |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
description = "Packages and tooling for bgpfu"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
jetez-src = { | ||
url = "github:juniper/jetez/v1.0.7"; | ||
flake = false; | ||
}; | ||
}; | ||
|
||
outputs = { self, ... } @ inputs: | ||
inputs.flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import inputs.nixpkgs { | ||
inherit system; | ||
}; | ||
platforms = import ./nix/platforms { | ||
inherit pkgs; | ||
inherit (inputs) jetez-src; | ||
}; | ||
rust = import ./nix/rust.nix { | ||
inherit pkgs platforms; | ||
inherit (inputs) crane fenix; | ||
}; | ||
in | ||
{ | ||
packages = with platforms; rec { | ||
cli = rust.buildPackage { | ||
pname = "bgpfu-cli"; | ||
bin = "bgpfu"; | ||
}; | ||
junos-agent = rust.buildPackage { | ||
pname = "bgpfu-junos-agent"; | ||
defaultPlatform = x86_64-junos-freebsd; | ||
extraPlatforms = [ native ]; | ||
}; | ||
default = cli; | ||
}; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ pkgs, jetez-src }: | ||
{ | ||
native = { | ||
platformName = "native"; | ||
mkPackage = builder: args: builder args; | ||
}; | ||
x86_64-junos-freebsd = import ./junos { inherit pkgs jetez-src; }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ pkgs, jetez-src }: | ||
let | ||
platformName = "junos-freebsd"; | ||
jetez = import ./jetez.nix { inherit jetez-src pkgs; }; | ||
freebsdCrossArgs = import ./freebsd-cross.nix { inherit pkgs; }; | ||
in | ||
{ | ||
inherit platformName; | ||
rustTarget = freebsdCrossArgs.CARGO_BUILD_TARGET; | ||
mkPackage = builder: { pname, passthru, meta, ... } @ args: | ||
let | ||
finalArgs = args // freebsdCrossArgs // { | ||
pname = "${pname}-${platformName}"; | ||
doCheck = false; | ||
}; | ||
in | ||
jetez.mkJetPackage { | ||
pkg = builder finalArgs; | ||
inherit meta passthru; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ pkgs }: | ||
with pkgs; | ||
let | ||
freebsd-arch = "amd64"; | ||
freebsd-major = 12; | ||
freebsd-minor = 4; | ||
|
||
target-arch = "x86_64"; | ||
rust-target = "${target-arch}-unknown-freebsd"; | ||
gnu-target = "${rust-target}${toString freebsd-major}"; | ||
|
||
binutils = stdenv.mkDerivation | ||
rec { | ||
pname = "binutils-${gnu-target}"; | ||
version = "2.32"; | ||
src = fetchzip { | ||
url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.gz"; | ||
hash = "sha256-LUvvkE9/7fSrSFDBOqghKSQbLjWhKGXLUacpySHMwdY="; | ||
}; | ||
enableParallelBuilding = true; | ||
configureFlags = [ "--target=${gnu-target}" ]; | ||
}; | ||
|
||
gcc = | ||
let | ||
freebsd-base = | ||
let | ||
version = "${toString freebsd-major}.${toString freebsd-minor}"; | ||
in | ||
fetchzip { | ||
url = "https://ftp.freebsd.org/pub/FreeBSD/releases/${freebsd-arch}/${version}-RELEASE/base.txz"; | ||
hash = "sha256-5UIyd6oZjBzcnC2E4MFftocorQfnIpbwAgZt0dhIDXE="; | ||
stripRoot = false; | ||
}; | ||
fetch-gnu-src = { name, version, hash, compression ? "bz2" }: fetchzip { | ||
inherit hash; | ||
url = "https://gcc.gnu.org/pub/gcc/infrastructure/${name}-${version}.tar.${compression}"; | ||
}; | ||
mpfr-src = fetch-gnu-src { | ||
name = "mpfr"; | ||
version = "2.4.2"; | ||
hash = "sha256-LwiN1dYyIKLKLDWj4O1qzkTgh9iYLY8VTxpTPLtt5Bo="; | ||
}; | ||
gmp-src = fetch-gnu-src { | ||
name = "gmp"; | ||
version = "4.3.2"; | ||
hash = "sha256-JJAmw32NfAl0Lq7AbK6EPCwqEWVBYHqvcg9gwuurbaQ="; | ||
}; | ||
mpc-src = fetch-gnu-src { | ||
name = "mpc"; | ||
version = "0.8.1"; | ||
hash = "sha256-RElyn5c1mu18wiPiDC3s2QDss/sTCBM0On492Jk6K6k="; | ||
compression = "gz"; | ||
}; | ||
in | ||
stdenv.mkDerivation | ||
rec { | ||
pname = "gcc-${gnu-target}"; | ||
version = "6.4.0"; | ||
src = fetchzip { | ||
url = "https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.gz"; | ||
hash = "sha256-TkyEvTY36r84a6rQDgvNRdy3W2uIYJ0e+KWquPc9GEs="; | ||
}; | ||
nativeBuildInputs = [ binutils ]; | ||
enableParallelBuilding = true; | ||
hardeningDisable = [ "format" "pie" ]; | ||
sourceRoot = "."; | ||
postUnpack = /* bash */ '' | ||
ln -sf ${mpfr-src} source/mpfr | ||
ln -sf ${gmp-src} source/gmp | ||
ln -sf ${mpc-src} source/mpc | ||
mkdir build && cd build | ||
''; | ||
configureScript = "../source/configure"; | ||
configureFlags = [ | ||
"--disable-libada" | ||
"--disable-libcilkrt" | ||
"--disable-libcilkrts" | ||
"--disable-libgomp" | ||
"--disable-libquadmath" | ||
"--disable-libquadmath-support" | ||
"--disable-libsanitizer" | ||
"--disable-libssp" | ||
"--disable-libvtv" | ||
"--disable-lto" | ||
"--disable-nls" | ||
"--enable-languages=c,c++" | ||
"--target=${gnu-target}" | ||
"--with-sysroot=${freebsd-base}" | ||
]; | ||
passthru.linker = "${gnu-target}-gcc"; | ||
}; | ||
in | ||
{ | ||
depsBuildBuild = [ binutils gcc ]; | ||
CARGO_BUILD_TARGET = rust-target; | ||
CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER = gcc.linker; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ jetez-src, pkgs }: | ||
let | ||
jetez = pkgs.callPackage | ||
({ src, lib, python3, openssl, cdrtools, ... }: | ||
python3.pkgs.buildPythonApplication { | ||
pname = "jetez"; | ||
version = "v1.0.7"; | ||
inherit src; | ||
buildInputs = [ | ||
openssl | ||
]; | ||
propagatedBuildInputs = with python3.pkgs; [ | ||
pyyaml | ||
lxml | ||
]; | ||
makeWrapperArgs = [ | ||
"--prefix PATH : ${lib.makeBinPath [ openssl cdrtools ] }" | ||
]; | ||
}) | ||
{ src = jetez-src; }; | ||
writeManifest = pkg: | ||
pkgs.writeText "${pkg.name}-jet-manifest" /* yaml */ '' | ||
basename: ${pkg.pname} | ||
comment: ${pkg.meta.description} | ||
copyright: "Copyright 2023, Workonline Communications" | ||
arch: "x86" | ||
abi: "64" | ||
files: | ||
- source: ${pkg.out}/bin/${pkg.meta.mainProgram} | ||
destination: /var/db/scripts/jet/${pkg.meta.mainProgram} | ||
''; | ||
in | ||
{ | ||
mkJetPackage = { pkg, meta, passthru }: | ||
pkgs.runCommand | ||
"${pkg.name}-jet-package" | ||
{ inherit meta passthru; } | ||
/* bash */ '' | ||
mkdir -p "$out" | ||
cd "$out" | ||
${jetez}/bin/jetez \ | ||
--source '.' \ | ||
--version ${pkg.version} \ | ||
--jet ${writeManifest pkg} \ | ||
--cert "/certs/cert.pem" \ | ||
--key "/certs/key.pem" \ | ||
--build "../build" \ | ||
--debug | ||
''; | ||
} |
Oops, something went wrong.