add build scripts with alba

This commit is contained in:
Quentin 2023-05-18 11:56:10 +02:00
parent 24fed41288
commit 115dd077ca
Signed by: quentin
GPG key ID: E9602264D639FF68
3 changed files with 165 additions and 35 deletions

View file

@ -2,3 +2,22 @@
set -euxo pipefail set -euxo pipefail
nix build --print-build-logs .#packages.x86_64-unknown-linux-musl.debug nix build --print-build-logs .#packages.x86_64-unknown-linux-musl.debug
if [[ ! -z $TAG && ! -z $DOCKER_AUTH ]]; then
# Configure Docker Auth
mkdir .docker
cat > .docker/config.json <<EOF
{"auths":{"https://index.docker.io/v1/":{"auth":"${DOCKER_AUTH}"}}}
EOF
export DOCKER_CONFIG=`pwd`/.docker/
# Hack to circumvent "initializing source docker-archive:docker/linux.386.tar.gz: creating temporary file: open /var/tmp/docker-tar1213702538: no such file or directory"
mkdir -p /var/tmp/
# Release
nix run .#publish-static
nix run .#publish-garage
nix run .#publish-docker-hub
fi

View file

@ -1,10 +1,30 @@
{ {
"nodes": { "nodes": {
"albatros": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1684318881,
"narHash": "sha256-Yk9GjcXd5hXkRWlAlxzHFpEKfEDSb15+Ptp/ldY468w=",
"ref": "main",
"rev": "373c1f8d76b11a5638b2a4aa753417c67f0c2e13",
"revCount": 78,
"type": "git",
"url": "https://git.deuxfleurs.fr/Deuxfleurs/albatros.git"
},
"original": {
"ref": "main",
"type": "git",
"url": "https://git.deuxfleurs.fr/Deuxfleurs/albatros.git"
}
},
"cargo2nix": { "cargo2nix": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
@ -24,7 +44,7 @@
}, },
"fenix": { "fenix": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_3",
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
@ -59,21 +79,6 @@
} }
}, },
"flake-utils": { "flake-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"
}
},
"flake-utils_2": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
}, },
@ -91,7 +96,55 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"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"
}
},
"flake-utils_3": {
"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": { "nixpkgs": {
"locked": {
"lastModified": 1678964307,
"narHash": "sha256-POV15raLJzwns6U84W4aWNSeSJRXTz7xWQW6IcrWQns=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fd4f7832961053e6095af8de8d6a57b5ad402f19",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1682600000, "lastModified": 1682600000,
"narHash": "sha256-ha4BehR1dh8EnXSoE1m/wyyYVvHI9txjW4w5/oxsW5Y=", "narHash": "sha256-ha4BehR1dh8EnXSoE1m/wyyYVvHI9txjW4w5/oxsW5Y=",
@ -107,7 +160,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1683408522, "lastModified": 1683408522,
"narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=",
@ -123,7 +176,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1683631309, "lastModified": 1683631309,
"narHash": "sha256-1cNXXM98+9NyH8TV3TYSESFjZ+MZGbFbNO4AtM6um3I=", "narHash": "sha256-1cNXXM98+9NyH8TV3TYSESFjZ+MZGbFbNO4AtM6um3I=",
@ -141,10 +194,11 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"albatros": "albatros",
"cargo2nix": "cargo2nix", "cargo2nix": "cargo2nix",
"fenix": "fenix", "fenix": "fenix",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_4"
} }
}, },
"rust-analyzer-src": { "rust-analyzer-src": {
@ -203,6 +257,21 @@
"repo": "default", "repo": "default",
"type": "github" "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", "root": "root",

View file

@ -15,10 +15,13 @@
# use rust project builds # use rust project builds
fenix.url = "github:nix-community/fenix/monthly"; fenix.url = "github:nix-community/fenix/monthly";
# import alba releasing tool
albatros.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/albatros.git?ref=main";
}; };
outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix }: outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix, albatros }:
flake-utils.lib.eachSystem [ let platformSpecific = flake-utils.lib.eachSystem [
"x86_64-unknown-linux-musl" "x86_64-unknown-linux-musl"
"aarch64-unknown-linux-musl" "aarch64-unknown-linux-musl"
"armv6l-unknown-linux-musleabihf" "armv6l-unknown-linux-musleabihf"
@ -51,12 +54,6 @@
]; ];
}; };
shell = pkgs.mkShell {
buildInputs = [
cargo2nix.packages.x86_64-linux.default
];
};
rustTarget = if targetHost == "armv6l-unknown-linux-musleabihf" then "arm-unknown-linux-musleabihf" else targetHost; rustTarget = if targetHost == "armv6l-unknown-linux-musleabihf" then "arm-unknown-linux-musleabihf" else targetHost;
# release builds # release builds
@ -135,10 +132,55 @@
}; };
in { in {
devShells.default = shell; packages = {
packages.debug = (rustDebug.workspace.aerogramme {}).bin; debug = (rustDebug.workspace.aerogramme {}).bin;
packages.aerogramme = bin; aerogramme = bin;
packages.container = container; container = container;
packages.default = self.packages.${targetHost}.aerogramme; default = self.packages.${targetHost}.aerogramme;
};
}); });
gpkgs = import nixpkgs {
system = "x86_64-linux"; # hardcoded as we will cross compile
};
alba = albatros.alba;
build-static = gpkgs.writeScriptBin "aerogramme-build-static" ''
nix build --print-build-logs .#packages.x86_64-unknown-linux-musl.aerogramme -o static/linux/amd64/aerogramme
nix build --print-build-logs .#packages.aarch64-unknown-linux-musl.aerogramme -o static/linux/arm64/aerogramme
nix build --print-build-logs .#packages.armv6l-unknown-linux-musleabihf.aerogramme -o static/linux/arm/aerogramme
'';
publish-static = gpkgs.writeScriptBin "aerogramme-push-static" ''
RTAG=''${TAG:-$COMMIT}
echo "selected release tag is $RTAG"
${alba} static push -t aerogramme:$RTAG static/ 's3://download.deuxfleurs.org?endpoint=garage.deuxfleurs.fr&s3ForcePathStyle=true&region=garage' 1>&2
'';
build-container = gpkgs.writeScriptBin "aerogramme-build-container" ''
nix build --print-build-logs .#packages.x86_64-unknown-linux-musl.container -o docker/linux.amd64.tar.gz
nix build --print-build-logs .#packages.armv6l-unknown-linux-musl.container -o docker/linux.arm.tar.gz
nix build --print-build-logs .#packages.aarch64-unknown-linux-musleabihf.container -o docker/linux.arm64.tar.gz
'';
publish-garage = gpkgs.writeScriptBin "aerogramme-publish-garage" ''
RTAG=''${TAG:-$COMMIT}
echo "selected release tag is $RTAG"
${alba} container push -t aerogramme:$RTAG docker/ 's3://registry.deuxfleurs.org?endpoint=garage.deuxfleurs.fr&s3ForcePathStyle=true&region=garage' 1>&2
'';
publish-docker-hub = gpkgs.writeScriptBin "aerogramme-publish-dockerhub" ''
RTAG=''${TAG:-$COMMIT}
echo "selected release tag is $RTAG"
${alba} container push -t aerogramme:$RTAG docker/ "docker://docker.io/dxflrs/aerogramme:$RTAG" 1>&2
'';
in
{
packages = {
x86_64-linux = {
inherit build-static publish-static build-container publish-garage publish-docker-hub;
};
} // platformSpecific.packages;
};
} }