isle/dist/linux/deb/default.nix

73 lines
1.5 KiB
Nix
Raw Normal View History

2024-12-20 11:49:01 +00:00
{
pkgs,
hostSystem,
releaseName,
appDir,
}: let
debArch = builtins.getAttr hostSystem {
"x86_64-linux" = "amd64";
"aarch64-linux" = "arm64";
"armv6l-linux" = "armhf";
"i686-linux" = "i386";
};
control = pkgs.writeTextDir "DEBIAN/control" ''
Package: isle
Version: ${releaseName}
Section: net
Priority: optional
Architecture: ${debArch}
Maintainer: Brian Picciano <me@mediocregopher.com>
Description: The foundation for an autonomous community cloud infrastructure
Homepage: https://code.betamike.com/micropelago/isle
'';
postinst = pkgs.writeTextDir "DEBIAN/postinst" ''
#!/bin/sh
systemctl daemon-reload
systemd-sysusers /usr/lib/sysusers.d/isle.conf
'';
postrm = pkgs.writeTextDir "DEBIAN/postrm" ''
#!/bin/sh
systemctl daemon-reload
'';
linuxRoot = (import ../default.nix).buildRoot {
inherit pkgs appDir;
};
root = pkgs.buildEnv {
name = "isle-deb-pkg-root";
paths = [
linuxRoot
control
postinst
postrm
];
};
in pkgs.stdenv.mkDerivation {
name = "isle-deb-pkg-${releaseName}-${debArch}";
nativeBuildInputs = [
pkgs.zstd
pkgs.dpkg
];
src = root;
buildPhase = ''
cp -rL "$src" root
chmod +w -R root
chmod +x root/DEBIAN/post*
dpkg-deb \
--root-owner-group \
-Z zstd \
-b root isle_${releaseName}_${debArch}.deb
'';
installPhase = ''
mkdir -p "$out"
cp *.deb "$out"
'';
}