diff --git a/default.nix b/default.nix index fc9fbf5..5064b2a 100644 --- a/default.nix +++ b/default.nix @@ -168,5 +168,11 @@ in rec { pkgs = pkgsNative; appDir = appDir { systemRoot = "/"; }; }); + + debPkg = ((import ./dist/linux/deb) { + inherit hostSystem releaseName; + pkgs = pkgsNative; + appDir = appDir { systemRoot = "/"; }; + }); }; } diff --git a/dist/linux/arch/default.nix b/dist/linux/arch/default.nix index ef2867e..e3ad985 100644 --- a/dist/linux/arch/default.nix +++ b/dist/linux/arch/default.nix @@ -11,7 +11,7 @@ pkgname=isle pkgver=${builtins.replaceStrings ["-"] ["_"] releaseName} pkgrel=0 - pkgdesc="The foundation for an autonomous community cloud infrastructure." + pkgdesc="The foundation for an autonomous community cloud infrastructure" arch=('${cpuArch}') url="https://code.betamike.com/micropelago/isle" license=('AGPL-3.0-or-later') @@ -25,6 +25,10 @@ } ''; + linuxRoot = (import ../default.nix).buildRoot { + inherit pkgs appDir; + }; + in pkgs.stdenv.mkDerivation { name = "isle-arch-pkg-${releaseName}-${cpuArch}"; @@ -37,30 +41,13 @@ in ]; inherit pkgbuild; - src = appDir; - defaultDaemonYml = ../../../go/daemon/daecommon/daemon.yml; - systemdService = ../isle.service; + src = linuxRoot; dontUnpack = true; buildPhase = '' - cp -rL "$src" root - chmod -R +w root - - mkdir -p root/etc/isle/ - cp "$defaultDaemonYml" root/etc/isle/daemon.yml - - mkdir -p root/usr/lib/sysusers.d/ - cat >root/usr/lib/sysusers.d/isle.conf < + 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" + ''; +} diff --git a/dist/linux/default.nix b/dist/linux/default.nix new file mode 100644 index 0000000..9435d70 --- /dev/null +++ b/dist/linux/default.nix @@ -0,0 +1,18 @@ +{ + buildRoot = { pkgs, appDir}: pkgs.runCommand "isle-linux-root" {} '' + mkdir -p "$out" + cp -r ${appDir}/usr "$out"/ + chmod +w -R "$out"/usr + + mkdir -p "$out"/etc/isle + cp "${../../go/daemon/daecommon/daemon.yml}" "$out"/etc/isle/daemon.yml + + mkdir -p "$out"/usr/lib/sysusers.d/ + cat >"$out"/usr/lib/sysusers.d/isle.conf <