fix apps symlinking, add spotify with spotx

This commit is contained in:
willemml 2023-01-04 09:55:46 -08:00
parent b8f04787c8
commit ac152b81e8
Signed by: willemml
GPG key ID: C3DE5DF6198DACBD
7 changed files with 102 additions and 5 deletions

21
apps.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
let
appEnv = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in {
home.activation.addApplications = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
# Install MacOS applications to the user environment.
HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state
[ -e "$HM_APPS" ] && $DRY_RUN_CMD rm -r "$HM_APPS"
$DRY_RUN_CMD mkdir -p "$HM_APPS"
# .app dirs need to be actual directories for Finder to detect them as Apps.
# In the env of Apps we build, the .apps are symlinks. We pass all of them as
# arguments to cp and make it dereference those using -H
$DRY_RUN_CMD cp --archive -H --dereference ${appEnv}/Applications/* "$HM_APPS"
$DRY_RUN_CMD chmod +w -R "$HM_APPS"
'';
}

17
flake.lock generated
View file

@ -53,6 +53,22 @@
"type": "github"
}
},
"nixpkgs-willem": {
"locked": {
"lastModified": 1672791794,
"narHash": "sha256-mqGPpGmwap0Wfsf3o2b6qHJW1w2kk/I6cGCGIU+3t6o=",
"ref": "master",
"rev": "9813adc7f7c0edd738c6bdd8431439688bb0cb3d",
"revCount": 439706,
"type": "git",
"url": "file:///Users/willem/dev/nixpkgs"
},
"original": {
"ref": "master",
"type": "git",
"url": "file:///Users/willem/dev/nixpkgs"
}
},
"nur": {
"locked": {
"lastModified": 1672325070,
@ -73,6 +89,7 @@
"home-manager": "home-manager",
"nixpkgs-22_11": "nixpkgs-22_11",
"nixpkgs-unstable": "nixpkgs-unstable",
"nixpkgs-willem": "nixpkgs-willem",
"nur": "nur"
}
},

View file

@ -2,6 +2,7 @@
description = "Willem's Home Manager configuration";
inputs = {
nixpkgs-willem.url = "git+file:///Users/willem/dev/nixpkgs?ref=master";
nixpkgs-22_11.url = "github:NixOS/nixpkgs/nixos-22.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {

View file

@ -4,7 +4,8 @@ let
homeDirectory = config.home.homeDirectory;
emacsCommand = [ "emacsclient" "-c" "-nw" ];
in {
imports = [ ./emacs.nix ./launchd.nix ./packages.nix ./programs.nix ];
imports =
[ ./emacs.nix ./launchd.nix ./packages.nix ./programs.nix ./apps.nix ];
nixpkgs.config = {
allowUnfree = true;
@ -37,4 +38,9 @@ in {
home.file.".gnupg/gpg-agent.conf".text = ''
pinentry-program "${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac"
'';
home.file.".config/nix/nix.conf".text = ''
allow-dirty = true
experimental-features = flakes nix-command
'';
}

View file

@ -2,8 +2,15 @@
{
home.packages = with pkgs;
[ coreutils gnused spoof-mac colima pinentry_mac iterm2 ] ++ [ discord ]
++ [ docker docker-compose ] ++ [
[
coreutils
gnused
spoof-mac
colima
pinentry_mac
iterm2
(pkgs.callPackage ./spotify-mac.nix { })
] ++ [ discord ] ++ [ docker docker-compose ] ++ [
zsh-powerlevel10k
comma
automake

View file

@ -31,8 +31,11 @@
key = "C3DE5DF6198DACBD";
signByDefault = true;
};
extraConfig.init.defaultBranch = "master";
extraConfig.core.autocrlf = false;
extraConfig = {
init.defaultBranch = "master";
core.autocrlf = false;
push.autoSetupRemote = true;
};
package = pkgs.gitAndTools.gitFull;
userName = "willemml";
userEmail = "willem@leit.so";

42
spotify-mac.nix Normal file
View file

@ -0,0 +1,42 @@
{ stdenv, lib, config, pkgs, ... }:
stdenv.mkDerivation {
name = "spotify-mac-app";
sourceRoot = ".";
nativeBuildInputs = [ pkgs.undmg pkgs.makeWrapper pkgs.perl pkgs.unzip pkgs.zip ];
src = pkgs.fetchurl {
url = "https://download.scdn.co/Spotify.dmg";
hash = "sha256-9Ts6064YaZdjbRN28qkZcrwTH+63drC/jUfTGLvpBNc=";
};
spotxsrc = pkgs.fetchFromGitHub {
name = "spotx-mac-src";
owner = "willemml";
repo = "SpotX-Mac";
rev = "03ea3aa59e135b9e2f68b6c8f4d4debe2b207830";
hash = "sha256-H3QxmM0ALtz58MKaQ6pFcK6wP8oMWufvQ2q2ZjpO5Gs=";
};
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r "Spotify.app" $out/Applications
# wrap executable to $out/bin
mkdir -p $out/bin
makeWrapper "$out/Applications/Spotify.app/Contents/MacOS/Spotify" "$out/bin/Spotify"
cp "$spotxsrc/install.sh" install.sh
chmod +x install.sh
./install.sh -a "$out/Applications/Spotify.app"
runHook postInstall
'';
}