Compare commits
No commits in common. "6ad1d58fbc709f8833d874fffb382eee2dfd6e41" and "b987cba515092320408e5c60d5fbcdefe4bf8470" have entirely different histories.
6ad1d58fbc
...
b987cba515
4 changed files with 49 additions and 4 deletions
|
@ -30,11 +30,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1714475611,
|
"lastModified": 1714137143,
|
||||||
"narHash": "sha256-7EmI74Xth23FM9ZDVJe2s/AeW9FqrJw9/b27dIYSvaM=",
|
"narHash": "sha256-LMZjGiacgn0R9zuuolU+XJZsx1hkX5p9gs+d7B0YQCc=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "e242401553971d5903ae4671bcb395185a81bcd2",
|
"rev": "77d432ad8b0e16213b29bbb58e3d73aef0512ee9",
|
||||||
"revCount": 5,
|
"revCount": 3,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.kun.is/home/blog-pim"
|
"url": "https://git.kun.is/home/blog-pim"
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
./blog-pim.nix
|
./blog-pim.nix
|
||||||
./forgejo-nix-action.nix
|
./forgejo-nix-action.nix
|
||||||
./atticd.nix
|
./atticd.nix
|
||||||
|
./release.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
19
release.nix
Normal file
19
release.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ nixpkgs, flutils, ... }: flutils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
createScript = name: runtimeInputs: scriptPath:
|
||||||
|
let
|
||||||
|
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
|
||||||
|
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||||
|
});
|
||||||
|
in
|
||||||
|
pkgs.symlinkJoin {
|
||||||
|
inherit name;
|
||||||
|
paths = [ script ] ++ runtimeInputs;
|
||||||
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
|
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.release = createScript "release" (with pkgs; [ nix docker-client git ]) ./release.sh;
|
||||||
|
})
|
25
release.sh
Executable file
25
release.sh
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
flakeref="${1-}"
|
||||||
|
name="${2-}"
|
||||||
|
gitdir="${3:-.}"
|
||||||
|
|
||||||
|
if [ -z "$flakeref" ] || [ -z "$name" ];
|
||||||
|
then
|
||||||
|
echo "Usage: $0 FLAKEREF NAME [GITDIR]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
imagename=$(nix eval --no-allow-dirty --raw $flakeref.imageName)
|
||||||
|
imagetag=$(nix eval --no-allow-dirty --raw $flakeref.imageTag)
|
||||||
|
image=$(nix build --no-allow-dirty $flakeref --print-out-paths --no-link)
|
||||||
|
gitrev=$(git --git-dir $gitdir/.git --work-tree $gitdir rev-parse HEAD)
|
||||||
|
|
||||||
|
docker load < $image
|
||||||
|
docker tag $imagename:$imagetag git.kun.is/home/$name:$gitrev
|
||||||
|
docker tag $imagename:$imagetag git.kun.is/home/$name:latest
|
||||||
|
docker push git.kun.is/home/$name:$gitrev
|
||||||
|
docker push git.kun.is/home/$name:latest
|
Reference in a new issue