automate publishing with nix
This commit is contained in:
parent
3dfe914fda
commit
ede836fc80
2 changed files with 122 additions and 19 deletions
87
flake.lock
vendored
87
flake.lock
vendored
|
@ -1,10 +1,30 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"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,6 +79,24 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"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": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1667395993,
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
|
@ -73,9 +111,9 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_3": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689068808,
|
"lastModified": 1689068808,
|
||||||
|
@ -92,6 +130,21 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"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": 1672580127,
|
"lastModified": 1672580127,
|
||||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||||
|
@ -107,7 +160,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1688231357,
|
"lastModified": 1688231357,
|
||||||
"narHash": "sha256-ZOn16X5jZ6X5ror58gOJAxPfFLAQhZJ6nOUeS4tfFwo=",
|
"narHash": "sha256-ZOn16X5jZ6X5ror58gOJAxPfFLAQhZJ6nOUeS4tfFwo=",
|
||||||
|
@ -123,7 +176,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1690294827,
|
"lastModified": 1690294827,
|
||||||
"narHash": "sha256-JV53dEaMM566e+6R4Wj58jBAkFg7HaZr3SsXZ9hdh40=",
|
"narHash": "sha256-JV53dEaMM566e+6R4Wj58jBAkFg7HaZr3SsXZ9hdh40=",
|
||||||
|
@ -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",
|
||||||
|
|
52
flake.nix
52
flake.nix
|
@ -17,10 +17,10 @@
|
||||||
fenix.url = "github:nix-community/fenix/monthly";
|
fenix.url = "github:nix-community/fenix/monthly";
|
||||||
|
|
||||||
# import alba releasing tool
|
# 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 [
|
let platformArtifacts = flake-utils.lib.eachSystem [
|
||||||
"x86_64-unknown-linux-musl"
|
"x86_64-unknown-linux-musl"
|
||||||
"aarch64-unknown-linux-musl"
|
"aarch64-unknown-linux-musl"
|
||||||
|
@ -127,15 +127,29 @@
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
crate = (rustRelease.workspace.aerogramme {});
|
||||||
|
|
||||||
# binary extract
|
# binary extract
|
||||||
bin = pkgs.stdenv.mkDerivation {
|
bin = pkgs.stdenv.mkDerivation {
|
||||||
pname = "aerogramme-bin";
|
pname = "${crate.name}-bin";
|
||||||
version = "0.1.0";
|
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;
|
dontUnpack = true;
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
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 {
|
container = pkgs.dockerTools.buildImage {
|
||||||
name = "dxflrs/aerogramme";
|
name = "dxflrs/aerogramme";
|
||||||
architecture = (builtins.getAttr targetHost archMap).GOARCH;
|
architecture = (builtins.getAttr targetHost archMap).GOARCH;
|
||||||
copyToRoot = bin;
|
copyToRoot = fhs;
|
||||||
config = {
|
config = {
|
||||||
Env = [ "PATH=/bin" ];
|
Env = [ "PATH=/bin" ];
|
||||||
Cmd = [ "aerogramme" "--dev" "provider" "daemon" ];
|
Cmd = [ "aerogramme" "--dev" "provider" "daemon" ];
|
||||||
|
@ -162,6 +176,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
meta = {
|
||||||
|
version = crate.version;
|
||||||
|
};
|
||||||
packages = {
|
packages = {
|
||||||
debug = (rustDebug.workspace.aerogramme {}).bin;
|
debug = (rustDebug.workspace.aerogramme {}).bin;
|
||||||
aerogramme = bin;
|
aerogramme = bin;
|
||||||
|
@ -170,12 +187,20 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# RELEASE STUFF
|
||||||
|
#
|
||||||
|
###
|
||||||
gpkgs = import nixpkgs {
|
gpkgs = import nixpkgs {
|
||||||
system = "x86_64-linux"; # hardcoded as we will cross compile
|
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
|
set -euxo pipefail
|
||||||
|
|
||||||
# static
|
# 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.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
|
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
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
x86_64-linux = {
|
x86_64-linux = {
|
||||||
inherit build;
|
inherit build push;
|
||||||
};
|
};
|
||||||
} // platformArtifacts.packages;
|
} // platformArtifacts.packages;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue