added option for global and per profile pkg and zip installs
This commit is contained in:
41
modules/archive-installs.nix
Normal file
41
modules/archive-installs.nix
Normal file
@@ -0,0 +1,41 @@
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.archiveApps;
|
||||
stampDir = "/usr/local/share/nix-pkg-stamps";
|
||||
|
||||
appScript = a:
|
||||
let
|
||||
src = pkgs.fetchurl { inherit (a) url sha256; };
|
||||
in ''
|
||||
stamp="${stampDir}/${a.name}"
|
||||
want="${src}"
|
||||
if [ "$(cat "$stamp" 2>/dev/null)" != "$want" ]; then
|
||||
echo "installing ${a.name}..."
|
||||
tmp=$(mktemp -d)
|
||||
if /usr/bin/unzip -q "$want" -d "$tmp"; then
|
||||
if [ -d "$tmp/${a.app}" ]; then
|
||||
rm -rf "/Applications/${a.app}"
|
||||
/usr/bin/ditto "$tmp/${a.app}" "/Applications/${a.app}"
|
||||
mkdir -p "${stampDir}"
|
||||
echo "$want" > "$stamp"
|
||||
else
|
||||
echo "${a.name}: ${a.app} not found in zip, skipping"
|
||||
fi
|
||||
else
|
||||
echo "${a.name}: could not unzip, skipping"
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
optiosn.archiveApps = lib.mkOption {
|
||||
type = lib.types.typesOf (lib.types.attrsOf lib.types.str);
|
||||
default = [ ];
|
||||
description = "Apps distributed as .zip archives to install into /Applications";
|
||||
}
|
||||
|
||||
system.activationScripts.postActivation.text =
|
||||
lib.concatMapStringsSep "\n" appScript cfg;
|
||||
}
|
||||
Reference in New Issue
Block a user