Files
nix-darwin/modules/pkg-installs.nix

32 lines
864 B
Nix

{ pkgs, lib, config, ... }:
let
cfg = config.pkgInstalls;
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
{
options.pkgInstalls = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.str);
default = [ ];
description = "PKG files to install on activation";
};
config.system.activationScripts.postActivation.text =
lib.concatMapStringsSep "\n" installScript cfg;
}