32 lines
858 B
Nix
32 lines
858 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";
|
|
};
|
|
|
|
system.activationScripts.postActivation.text =
|
|
lib.concatMapStringsSep "\n" installScript cfg;
|
|
}
|