Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell-wk
Last active October 27, 2017 19:39
Show Gist options
  • Save dustinlacewell-wk/a0976af57b8f59ee3c33f821609517fb to your computer and use it in GitHub Desktop.
Save dustinlacewell-wk/a0976af57b8f59ee3c33f821609517fb to your computer and use it in GitHub Desktop.
{ config, pkgs, lib, ... }:
with import <home-manager/modules/lib/dag.nix> { inherit lib; };
let
version = "0.9.57";
release = pkgs.fetchzip {
name = "Hammerspoon.app";
url = "https://github.com/Hammerspoon/hammerspoon/releases/download/${version}/Hammerspoon-${version}.zip";
sha256 = "12j9vylcxb7i3bn0v5x6zbxmnyyp7gh4am4vg48yv3hb54i73klx";
};
package = pkgs.runCommand "Hammerspoon-${version}" {} ''
mkdir -pv $out/Applications/Hammerspoon.app
cp -r ${release}/* $out/Applications/Hammerspoon.app
'';
in {
home.packages = [ package ];
home.activation.hammerspoon = dagEntryAfter["linkgeneration"] (let
linkName = "Hammerspoon.app";
home = config.home.homeDirectory;
applications = "${home}/.nix-profile/Applications";
source = "${applications}/${linkName}";
target = "${home}/Applications/";
in ''
rm -r ${target}/${linkName}
osascript << EOF
tell application "Finder"
set mySource to POSIX file "${source}" as alias
make new alias to mySource at POSIX file "${target}"
set name of result to "${linkName}"
end tell
EOF
'');
}
ls -la /nix/store/jsczd16r60galp5acm6ilfg2pyjssf7z-home-manager-path/
total 24
dr-xr-xr-x 8 root wheel 272 Dec 31 1969 .
drwxrwxr-t 2590 root nixbld 88060 Oct 27 14:31 ..
lrwxr-xr-x 1 root wheel 81 Dec 31 1969 Applications -> /nix/store/qgnj58776a3syzpjn99yiax67hfqa6lk-emacs-with-packages-25.3/Applications
dr-xr-xr-x 22 root wheel 748 Dec 31 1969 bin
lrwxr-xr-x 1 root wheel 57 Dec 31 1969 etc -> /nix/store/cjabqi6fm5qkq90ikznkqqxzg1fhahs6-zsh-5.4.2/etc
dr-xr-xr-x 5 root wheel 170 Dec 31 1969 lib
lrwxr-xr-x 1 root wheel 57 Dec 31 1969 sbin -> /nix/store/2inwapsm2c5yhxgd6cbqgwa7ipgbg77m-man-1.6g/sbin
dr-xr-xr-x 12 root wheel 408 Dec 31 1969 share
#> tree -L 2 /nix/store/qccgzdal0115i2p2snamzpmhginh9lpj-Hammerspoon-0.9.57/
/nix/store/qccgzdal0115i2p2snamzpmhginh9lpj-Hammerspoon-0.9.57/
└── Applications
└── Hammerspoon.app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment