added aarch64 (raspberry pi) support

This commit is contained in:
Benton Edmondson 2022-09-03 19:24:18 -05:00
parent 26fe53dfd8
commit f60e2a4537
2 changed files with 190 additions and 168 deletions

View file

@ -16,6 +16,21 @@
"url": "https://gist.github.com/f0fd86b6c73063283afe550bc5d77594.git" "url": "https://gist.github.com/f0fd86b6c73063283afe550bc5d77594.git"
} }
}, },
"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"
}
},
"gourou-src": { "gourou-src": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -68,6 +83,7 @@
"root": { "root": {
"inputs": { "inputs": {
"base64-src": "base64-src", "base64-src": "base64-src",
"flake-utils": "flake-utils",
"gourou-src": "gourou-src", "gourou-src": "gourou-src",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"pugixml-src": "pugixml-src", "pugixml-src": "pugixml-src",

View file

@ -1,6 +1,7 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gourou-src = { gourou-src = {
url = "git://soutade.fr/libgourou.git"; url = "git://soutade.fr/libgourou.git";
flake = false; flake = false;
@ -20,22 +21,24 @@
}; };
outputs = flakes: outputs = flakes:
flakes.flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ]
(system:
let let
version = "1.3.0"; version = "1.3.1";
self = flakes.self.packages.x86_64-linux; self = flakes.self.packages.${system};
nixpkgs = flakes.nixpkgs.legacyPackages.x86_64-linux.pkgsStatic; nixpkgs = flakes.nixpkgs.legacyPackages.${system}.pkgsStatic;
nixpkgs-dyn = flakes.nixpkgs.legacyPackages.x86_64-linux; nixpkgs-dyn = flakes.nixpkgs.legacyPackages.${system};
nixpkgs-fmt = flakes.nixpkgs-fmt.defaultPackage.x86_64-linux; nixpkgs-fmt = flakes.nixpkgs-fmt.defaultPackage.${system};
gourou-src = flakes.gourou-src; gourou-src = flakes.gourou-src;
updfparser-src = flakes.updfparser-src; updfparser-src = flakes.updfparser-src;
base64-src = flakes.base64-src; base64-src = flakes.base64-src;
pugixml-src = flakes.pugixml-src; pugixml-src = flakes.pugixml-src;
cxx = "${nixpkgs.stdenv.cc}/bin/x86_64-unknown-linux-musl-g++"; cxx = "${nixpkgs.stdenv.cc}/bin/${nixpkgs.stdenv.cc.targetPrefix}c++";
ar = "${nixpkgs.stdenv.cc.bintools.bintools_bin}/bin/x86_64-unknown-linux-musl-ar"; ar = "${nixpkgs.stdenv.cc.bintools.bintools_bin}/bin/${nixpkgs.stdenv.cc.targetPrefix}ar";
obj-flags = "-O2 -static"; obj-flags = "-O2 -static";
in in
rec { rec {
packages.x86_64-linux.libzip-static = nixpkgs.libzip.overrideAttrs (prev: { packages.libzip-static = nixpkgs.libzip.overrideAttrs (prev: {
cmakeFlags = (prev.cmakeFlags or [ ]) ++ [ cmakeFlags = (prev.cmakeFlags or [ ]) ++ [
"-DBUILD_SHARED_LIBS=OFF" "-DBUILD_SHARED_LIBS=OFF"
"-DBUILD_EXAMPLES=OFF" "-DBUILD_EXAMPLES=OFF"
@ -45,9 +48,9 @@
]; ];
outputs = [ "out" ]; outputs = [ "out" ];
}); });
packages.x86_64-linux.base64 = derivation { packages.base64 = derivation {
name = "updfparser"; name = "updfparser";
system = "x86_64-linux"; inherit system;
builder = "${nixpkgs.bash}/bin/bash"; builder = "${nixpkgs.bash}/bin/bash";
PATH = "${nixpkgs.coreutils}/bin"; PATH = "${nixpkgs.coreutils}/bin";
args = [ args = [
@ -58,9 +61,9 @@
'' ''
]; ];
}; };
packages.x86_64-linux.updfparser = derivation { packages.updfparser = derivation {
name = "updfparser"; name = "updfparser";
system = "x86_64-linux"; inherit system;
builder = "${nixpkgs.bash}/bin/bash"; builder = "${nixpkgs.bash}/bin/bash";
PATH = "${nixpkgs.coreutils}/bin"; PATH = "${nixpkgs.coreutils}/bin";
args = [ args = [
@ -75,17 +78,18 @@
'' ''
]; ];
}; };
packages.x86_64-linux.gourou = derivation { packages.gourou = derivation {
name = "gourou"; name = "gourou";
system = "x86_64-linux"; inherit system;
builder = "${nixpkgs.bash}/bin/bash"; builder = "${nixpkgs.bash}/bin/bash";
PATH = "${nixpkgs.coreutils}/bin"; PATH = "${nixpkgs.coreutils}/bin";
args = [ args = [
"-c" "-c"
'' ''
shopt -s extglob
${cxx} \ ${cxx} \
-c \ -c \
${gourou-src}/src/*.cpp \ ${gourou-src}/src/!(pugixml).cpp \
${pugixml-src}/src/pugixml.cpp \ ${pugixml-src}/src/pugixml.cpp \
-I ${self.base64}/include \ -I ${self.base64}/include \
-I ${gourou-src}/include \ -I ${gourou-src}/include \
@ -98,9 +102,9 @@
'' ''
]; ];
}; };
packages.x86_64-linux.utils-common = derivation { packages.utils-common = derivation {
name = "utils-common"; name = "utils-common";
system = "x86_64-linux"; inherit system;
builder = "${nixpkgs.bash}/bin/bash"; builder = "${nixpkgs.bash}/bin/bash";
PATH = "${nixpkgs.coreutils}/bin"; PATH = "${nixpkgs.coreutils}/bin";
args = [ args = [
@ -122,9 +126,9 @@
'' ''
]; ];
}; };
packages.x86_64-linux.knock = derivation { packages.knock = derivation {
name = "knock"; name = "knock";
system = "x86_64-linux"; inherit system;
builder = "${nixpkgs.bash}/bin/bash"; builder = "${nixpkgs.bash}/bin/bash";
PATH = "${nixpkgs.coreutils}/bin"; PATH = "${nixpkgs.coreutils}/bin";
args = [ args = [
@ -135,6 +139,7 @@
-o $out/bin/knock \ -o $out/bin/knock \
${./src/knock.cpp} \ ${./src/knock.cpp} \
-D KNOCK_VERSION='"${version}"' \ -D KNOCK_VERSION='"${version}"' \
--std=c++17 \
-Wl,--as-needed -static \ -Wl,--as-needed -static \
${self.utils-common}/lib/libutils-common.a \ ${self.utils-common}/lib/libutils-common.a \
${self.gourou}/lib/libgourou.a \ ${self.gourou}/lib/libgourou.a \
@ -162,8 +167,8 @@
'' ''
]; ];
}; };
packages.x86_64-linux.default = self.knock; packages.default = self.knock;
packages.x86_64-linux.tests = nixpkgs-dyn.stdenv.mkDerivation { packages.tests = nixpkgs-dyn.stdenv.mkDerivation {
name = "tests"; name = "tests";
src = ./tests; src = ./tests;
buildInputs = [ buildInputs = [
@ -181,11 +186,12 @@
chmod +x $out/bin/tests chmod +x $out/bin/tests
''; '';
}; };
packages.x86_64-linux.formatter = nixpkgs.writeShellScriptBin "formatter" '' packages.formatter = nixpkgs.writeShellScriptBin "formatter" ''
set -x set -x
${nixpkgs-dyn.clang-tools}/bin/clang-format -i --verbose ./src/*.cpp ${nixpkgs-dyn.clang-tools}/bin/clang-format -i --verbose ./src/*.cpp
${nixpkgs-dyn.nixpkgs-fmt}/bin/nixpkgs-fmt . ${nixpkgs-dyn.nixpkgs-fmt}/bin/nixpkgs-fmt .
${nixpkgs-dyn.black}/bin/black ./tests ${nixpkgs-dyn.black}/bin/black ./tests
''; '';
}; }
);
} }