34 lines
940 B
Nix
34 lines
940 B
Nix
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
# Add one entry per program you want to install from a .pkg file
|
|
pkgInstalls = [
|
|
{
|
|
name = "cupsadmin";
|
|
url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg";
|
|
hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y=";
|
|
}
|
|
];
|
|
|
|
installScript = p:
|
|
let
|
|
src = pkgs.fetchurl { inherit (p) url hash; };
|
|
in ''
|
|
stamp="/usr/local/share/nix-pkg-stamps/${p.name}"
|
|
want="${src}"
|
|
if [ "$(cat "$stamp" 2>/dev/null)" != "$want" ]; then
|
|
echo "installing ${p.name}..."
|
|
if /usr/sbin/installer -pkg "$want" -target /; then
|
|
mkdir -p /usr/local/share/nix-pkg-stamps
|
|
echo "$want" > "$stamp"
|
|
else
|
|
echo "${p.name} install failed, skipping"
|
|
fi
|
|
fi
|
|
'';
|
|
in
|
|
{
|
|
system.activationScripts.postActivation.text =
|
|
lib.concatMapStringsSep "\n" installScript pkgInstalls;
|
|
}
|