Merge pull request 'packaging: package clan gui for many distros' (#1483) from DavHau-dave into main
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
./installer/flake-module.nix
|
./installer/flake-module.nix
|
||||||
./schemas/flake-module.nix
|
./schemas/flake-module.nix
|
||||||
./webview-ui/flake-module.nix
|
./webview-ui/flake-module.nix
|
||||||
|
./gui-installer/flake-module.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem =
|
perSystem =
|
||||||
|
|||||||
24
pkgs/gui-installer/flake-module.nix
Normal file
24
pkgs/gui-installer/flake-module.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
perSystem =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
nfpmConfig = pkgs.writeText "clan-nfpm-config.yaml" (
|
||||||
|
builtins.toJSON { name = "clan-gui-installer"; }
|
||||||
|
);
|
||||||
|
installerFor =
|
||||||
|
packager:
|
||||||
|
pkgs.runCommand "gui-installer" { } ''
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
${pkgs.nfpm}/bin/nfpm package --config ${nfpmConfig} --packager ${packager}
|
||||||
|
mkdir $out
|
||||||
|
mv * $out/
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.gui-installer-apk = installerFor "apk";
|
||||||
|
packages.gui-installer-archlinux = installerFor "archlinux";
|
||||||
|
packages.gui-installer-deb = installerFor "deb";
|
||||||
|
packages.gui-installer-rpm = installerFor "rpm";
|
||||||
|
};
|
||||||
|
}
|
||||||
54
pkgs/gui-installer/gui-installer.sh
Executable file
54
pkgs/gui-installer/gui-installer.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# create temp dir and ensure it is always cleaned
|
||||||
|
trap 'clean_temp_dir' EXIT
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
|
|
||||||
|
clean_temp_dir() {
|
||||||
|
rm -rf "$temp_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_nix_installed() {
|
||||||
|
if [ -n "$(command -v nix)" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_nix() {
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf -L \
|
||||||
|
https://install.determinate.systems/nix \
|
||||||
|
> "$temp_dir"/install_nix.sh
|
||||||
|
NIX_INSTALLER_DIAGNOSTIC_ENDPOINT="" sh "$temp_dir"/install_nix.sh install
|
||||||
|
}
|
||||||
|
|
||||||
|
ask_then_install_nix() {
|
||||||
|
echo "Clan requires Nix to be installed. Would you like to install it now? (y/n)"
|
||||||
|
read -r response
|
||||||
|
if [ "$response" = "y" ]; then
|
||||||
|
install_nix
|
||||||
|
else
|
||||||
|
echo "Clan cannot run without Nix. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_nix_installed() {
|
||||||
|
if ! is_nix_installed; then
|
||||||
|
ask_then_install_nix
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_clan_gui() {
|
||||||
|
exec nix run \
|
||||||
|
https://git.clan.lol/clan/clan-core/archive/main.tar.gz#clan-vm-manager \
|
||||||
|
--extra-experimental-features flakes nix-command -- "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
ensure_nix_installed
|
||||||
|
start_clan_gui "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user