added option for global and per profile pkg and zip installs

This commit is contained in:
2026-11-09 13:41:03 -05:00
parent 00147ba242
commit 0a9ede2ba8
6 changed files with 70 additions and 51 deletions

42
modules/apps.nix Normal file
View File

@@ -0,0 +1,42 @@
{ ... }:
{
# This file installs these apps on all configurations
pkgInstalls = [
{
name = "cupsadmin";
url = "https://github.com/kfattic/cupsadmin/releases/download/v1.4.1/cupsadmin-1.4.1.pkg";
hash = "sha256-DyIyDYSjAlcU7ivyfldMapIZw5nczEBXfnLicnK6k7Y=";
}
];
archiveApps = [];
environment.systemPackages = with pkgs; [
exif
exiftool
git
helix
];
homebrew.brews = [
"bun"
"defaultbrowser"
"harper"
"rust"
"ykman"
];
homebrew.casks = [
"bitwarden"
"harper-desktop"
"nextcloud"
"obsidian"
"signal"
"task-manager-tmog"
"twingate"
"vlc"
"vscodium"
"firefox"
];
}

View 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;
}

View File

@@ -8,39 +8,11 @@
system.stateVersion = 6;
system.primaryUser = "briannelson";
environment.systemPackages = with pkgs; [
exif
exiftool
git
helix
];
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
cleanup = "none";
};
brews = [
"bun"
"defaultbrowser"
"harper"
"rust"
"ykman"
];
casks = [
"bitwarden"
"harper-desktop"
"nextcloud"
"obsidian"
"signal"
"task-manager-tmog"
"twingate"
"vlc"
"vscodium"
"firefox"
];
};
}

View File

@@ -3,8 +3,10 @@
{
imports = [
./base.nix
./apps.nix
./cli-tools.nix
./mac-settings.nix
./pkg-installs.nix
./archive-installs.nix
];
}

View File

@@ -1,15 +1,7 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
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=";
}
];
cfg = config.pkgInstalls;
installScript = p:
let
src = pkgs.fetchurl { inherit (p) url hash; };
@@ -28,6 +20,12 @@ let
'';
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 pkgInstalls;
lib.concatMapStringsSep "\n" installScript cfg;
}