Deploying via ipfs?
This commit is contained in:
parent
c50529e44e
commit
a19640ec02
20
flake.nix
20
flake.nix
@ -13,7 +13,18 @@
|
||||
outputs = { self, nixpkgs, flake-utils, easy-hls }:
|
||||
{
|
||||
overlay = final: prev: {
|
||||
build-rauhala-info = final.haskellPackages.build-rauhala-info;
|
||||
deploy-rauhala-info = with final; runCommand "deploy-rauhala-info.sh" { inherit bash ipfs; }
|
||||
''
|
||||
mkdir -p $out/bin/
|
||||
substituteAll ${./support/deploy-rauhala-info.sh} $out/bin/deploy-rauhala-info.sh
|
||||
chmod u+x $out/bin/deploy-rauhala-info.sh
|
||||
'';
|
||||
build-rauhala-info = final.runCommand "site" { buildInputs = [final.makeWrapper]; }
|
||||
''
|
||||
mkdir -p $out/bin/
|
||||
cp ${final.haskellPackages.build-rauhala-info}/bin/site $out/bin/
|
||||
wrapProgram $out/bin/site --prefix PATH : ${ final.lib.makeBinPath [ final.ipfs ] }
|
||||
'';
|
||||
rauhala-info = final.callPackage ./rauhala.info { site = final.build-rauhala-info; };
|
||||
haskellPackages = prev.haskellPackages.override ( old: {
|
||||
overrides = final.lib.composeExtensions ( old.overrides or (_: _: {})) (f: p: {
|
||||
@ -30,11 +41,15 @@
|
||||
hls = easy-hls.defaultPackage.${system};
|
||||
in
|
||||
rec {
|
||||
packages = { inherit (pkgs) build-rauhala-info rauhala-info; };
|
||||
packages = { inherit (pkgs) build-rauhala-info rauhala-info deploy-rauhala-info; };
|
||||
applications.build-rauhala-info = flake-utils.lib.mkApp {
|
||||
drv = packages.build-rauhala-info;
|
||||
exePath = "/bin/site";
|
||||
};
|
||||
applications.deploy-rauhala-info = flake-utils.lib.mkApp {
|
||||
drv = packages.deploy-rauhala-info;
|
||||
exePath = "/bin/deploy-rauhala-info.sh";
|
||||
};
|
||||
defaultPackage = packages.rauhala-info;
|
||||
defaultApp = applications.build-rauhala-info;
|
||||
devShell = hp.shellFor {
|
||||
@ -45,6 +60,7 @@
|
||||
stylish-haskell
|
||||
entr
|
||||
hls
|
||||
ipfs
|
||||
];
|
||||
};
|
||||
});
|
||||
|
36
support/deploy-rauhala-info.sh
Executable file
36
support/deploy-rauhala-info.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!@bash@/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ ! -d _site ]; then
|
||||
echo "No _site detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API=/ip4/127.0.0.1/tcp/5001
|
||||
|
||||
function upload() {
|
||||
echo "Uploading.."
|
||||
hash=$(ipfs --api $API add -r _site --pin=false -Q)
|
||||
}
|
||||
|
||||
function pin() {
|
||||
echo "Pinning"
|
||||
ipfs --api $API pin remote rm --service=pinata --cid="$hash"
|
||||
ipfs --api $API pin remote add --service=pinata --name=rauhala.info "$hash"
|
||||
}
|
||||
|
||||
function publish() {
|
||||
echo "Updating name"
|
||||
ipfs --api $API name publish --key=rauhala.info "$hash"
|
||||
}
|
||||
|
||||
upload
|
||||
|
||||
pin &
|
||||
|
||||
publish &
|
||||
|
||||
wait
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user