Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to run apps from the launchpad #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,66 @@ in
}
#+end_src

*** Others Flakes without nix-darwin nor home-manager

This will install apps local for a project available in the launchpad

Example:

#+begin_src nix
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

inputs.nixcasks.url = "github:jacekszymanski/nixcasks";
inputs.nixcasks.inputs.nixpkgs.follows = "nixpkgs";

inputs.mac-app-util.url = "github:hraban/mac-app-util";

outputs =
{ self
, nixpkgs
, flake-utils
, mac-app-util
, nixcasks
, ...
}:
flake-utils.lib.eachDefaultSystem (system: {
devShells.default =
let
osVersion = "sonoma";

nixcasksOverlay = final: prev: {
nixcasks = (nixcasks.output {
inherit osVersion;
}).packages."${prev.system}";
};

pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
nixcasksOverlay
];
};

brewPackages = [
pkgs.nixcasks.android-studio
pkgs.nixcasks.firefox
];
in
pkgs.mkShellNoCC {
shellHook = ''
# make apps available in the launcher and up to date in the dock
${pkgs.lib.getExe mac-app-util.packages."${system}".shellHook} \
${mac-app-util.lib.assembleBrewAppsInOneFolder { inherit pkgs brewPackages; }} \
"Nix_Flake_Example"
'';
};
});
}
#+end_src

** Commands

At the core of this project is a (Nix-agnostic) program that can:
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock
52 changes: 52 additions & 0 deletions example/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

inputs.nixcasks.url = "github:jacekszymanski/nixcasks";
inputs.nixcasks.inputs.nixpkgs.follows = "nixpkgs";

# inputs.mac-app-util.url = "github:hraban/mac-app-util";
inputs.mac-app-util.url = "../.";

outputs =
{ self
, nixpkgs
, flake-utils
, mac-app-util
, nixcasks
, ...
}:
flake-utils.lib.eachDefaultSystem (system: {
devShells.default =
let
osVersion = "sonoma";

nixcasksOverlay = final: prev: {
nixcasks = (nixcasks.output {
inherit osVersion;
}).packages."${prev.system}";
};

pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
nixcasksOverlay
];
};

brewPackages = [
pkgs.nixcasks.android-studio
pkgs.nixcasks.firefox
];
in
pkgs.mkShellNoCC {
shellHook = ''
# make apps available in the launcher and up to date in the dock
${pkgs.lib.getExe mac-app-util.packages."${system}".shellHook} \
${mac-app-util.lib.assembleBrewAppsInOneFolder { inherit pkgs brewPackages; }} \
"Nix_Flake_Example"
'';
};
});
}
22 changes: 22 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
${mac-app-util}/bin/mac-app-util sync-trampolines "/Applications/Nix Apps" "/Applications/Nix Trampolines"
'';
};
lib.assembleBrewAppsInOneFolder = { pkgs, brewPackages }:
pkgs.runCommand "assembleBrewAppsInOneFolder" { } ''
mkdir --parents $out
for PACKAGE in ${builtins.concatStringsSep " " brewPackages}; do
for APP in "$PACKAGE"/*/*.app; do
ln --symbolic "$APP" "$out"
done
done
'';
}
//
(with flake-utils.lib; eachDefaultSystem (system:
Expand Down Expand Up @@ -100,6 +109,19 @@
doInstallCheck = true;
meta.license = pkgs.lib.licenses.agpl3Only;
}) {};

shellHook =
let
is-on-mac = builtins.hasAttr system self.packages;
mac-app-util = self.packages.${system}.default;
in
pkgs.writeShellScriptBin "mac-app-util-shell-hook" (
if is-on-mac then ''
fromDir="$1"
toDir="~/Applications/$2"
${mac-app-util}/bin/mac-app-util sync-trampolines "$fromDir" "$toDir"
'' else ""
);
};
}));
}