diff options
-rw-r--r-- | flake.lock | 87 | ||||
-rw-r--r-- | flake.nix | 54 |
2 files changed, 122 insertions, 19 deletions
@@ -1,10 +1,30 @@ { "nodes": { + "albatros": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1684830446, + "narHash": "sha256-jyYwYYNKSe40Y9OirIkeFTvTvqNj0NErh4TNBJmujw4=", + "ref": "main", + "rev": "fb80c5d6734044ca7718989a3b36503b9463f1b2", + "revCount": 81, + "type": "git", + "url": "https://git.deuxfleurs.fr/Deuxfleurs/albatros.git" + }, + "original": { + "ref": "main", + "type": "git", + "url": "https://git.deuxfleurs.fr/Deuxfleurs/albatros.git" + } + }, "cargo2nix": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", "rust-overlay": "rust-overlay" }, "locked": { @@ -24,7 +44,7 @@ }, "fenix": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "rust-analyzer-src": "rust-analyzer-src" }, "locked": { @@ -59,6 +79,24 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, + "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" + } + }, + "flake-utils_2": { "locked": { "lastModified": 1667395993, "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", @@ -73,9 +111,9 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_3": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1689068808, @@ -93,6 +131,21 @@ }, "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": { "lastModified": 1672580127, "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", "owner": "nixos", @@ -107,7 +160,7 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { "lastModified": 1688231357, "narHash": "sha256-ZOn16X5jZ6X5ror58gOJAxPfFLAQhZJ6nOUeS4tfFwo=", @@ -123,7 +176,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1690294827, "narHash": "sha256-JV53dEaMM566e+6R4Wj58jBAkFg7HaZr3SsXZ9hdh40=", @@ -141,10 +194,11 @@ }, "root": { "inputs": { + "albatros": "albatros", "cargo2nix": "cargo2nix", "fenix": "fenix", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" } }, "rust-analyzer-src": { @@ -203,6 +257,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", @@ -17,10 +17,10 @@ fenix.url = "github:nix-community/fenix/monthly"; # import alba releasing tool - #albatros.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/albatros.git?ref=main"; + albatros.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/albatros.git?ref=main"; }; - outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix /*, alabtros */ }: + outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix, albatros }: let platformArtifacts = flake-utils.lib.eachSystem [ "x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" @@ -127,15 +127,29 @@ ]; }); + + crate = (rustRelease.workspace.aerogramme {}); + # binary extract bin = pkgs.stdenv.mkDerivation { - pname = "aerogramme-bin"; - version = "0.1.0"; + pname = "${crate.name}-bin"; + version = crate.version; + dontUnpack = true; + dontBuild = true; + installPhase = '' + cp ${crate.bin}/bin/aerogramme $out + ''; + }; + + # fhs extract + fhs = pkgs.stdenv.mkDerivation { + pname = "${crate.name}-fhs"; + version = crate.version; dontUnpack = true; dontBuild = true; installPhase = '' mkdir -p $out/bin - cp ${(rustRelease.workspace.aerogramme {}).bin}/bin/aerogramme $out/bin/ + cp ${crate.bin}/bin/aerogramme $out/bin/ ''; }; @@ -154,7 +168,7 @@ container = pkgs.dockerTools.buildImage { name = "dxflrs/aerogramme"; architecture = (builtins.getAttr targetHost archMap).GOARCH; - copyToRoot = bin; + copyToRoot = fhs; config = { Env = [ "PATH=/bin" ]; Cmd = [ "aerogramme" "--dev" "provider" "daemon" ]; @@ -162,6 +176,9 @@ }; in { + meta = { + version = crate.version; + }; packages = { debug = (rustDebug.workspace.aerogramme {}).bin; aerogramme = bin; @@ -169,13 +186,21 @@ default = self.packages.${targetHost}.aerogramme; }; }); - + + ### + # + # RELEASE STUFF + # + ### gpkgs = import nixpkgs { system = "x86_64-linux"; # hardcoded as we will cross compile }; - #alba = albatros.packages.x86_64-linux.alba; + alba = albatros.packages.x86_64-linux.alba; - build = gpkgs.writeScriptBin "aerogramme-build-static" '' + # Used only to fetch the "version" + version = platformArtifacts.meta.x86_64-unknown-linux-musl.version; + + build = gpkgs.writeScriptBin "aerogramme-build" '' set -euxo pipefail # static @@ -188,11 +213,20 @@ nix build --print-build-logs .#packages.aarch64-unknown-linux-musl.container -o docker/linux.arm64.tar.gz nix build --print-build-logs .#packages.armv6l-unknown-linux-musleabihf.container -o docker/linux.arm.tar.gz ''; + + push = gpkgs.writeScriptBin "aerogramme-publish" '' + set -euxo pipefail + + ${alba} static push -t aerogramme:${version} static/ 's3://download.deuxfleurs.org?endpoint=garage.deuxfleurs.fr&s3ForcePathStyle=true®ion=garage' 1>&2 + ${alba} container push -t aerogramme:${version} docker/ 's3://registry.deuxfleurs.org?endpoint=garage.deuxfleurs.fr&s3ForcePathStyle=true®ion=garage' 1>&2 + ${alba} container push -t aerogramme:${version} docker/ "docker://docker.io/dxflrs/aerogramme:$RTAG" 1>&2 + ''; + in { packages = { x86_64-linux = { - inherit build; + inherit build push; }; } // platformArtifacts.packages; }; |