add firefox + chromium + browserpass

This commit is contained in:
willemml 2023-02-04 10:59:10 -08:00
parent f1bd47b20b
commit 24bc7e9284
Signed by: willemml
GPG key ID: C3DE5DF6198DACBD
13 changed files with 203 additions and 124 deletions

View file

@ -1,8 +1,48 @@
{ config, pkgs, lib, inputs, ... }:
{
let
inherit (lib) mkIf;
inherit (pkgs) stdenv;
appCommands = {
calibre = "Calibre";
discord = "Discord";
email = "Mail";
ical = "Calendar";
im = "Messages";
maps = "Maps";
music = "Music";
settings = "System Settings";
spotify = "Spotify";
web = "Safari";
zotero = "Zotero";
};
in {
imports = [ ./launchd.nix ./apps.nix ];
home.file.".gnupg/gpg-agent.conf".text = mkIf stdenv.isDarwin ''
pinentry-program "${pkgs.pinentry-touchid}/bin/pinentry-touchid"
default-cache-ttl 30
max-cache-ttl 600
'';
home.file.".config/zsh/am.sh" = mkIf stdenv.isDarwin {
executable = true;
source = builtins.fetchurl {
url = "https://raw.githubusercontent.com/mcthomas/Apple-Music-CLI-Player/27353ec55abac8b5d73b8a061fb87f305c663adb/src/am.sh";
sha256 = "sha256-78zRpNg7/OR7p8dpsJt6Xc4j0Y+8zSUtm/PT94nf03M=";
};
};
programs.zsh.shellAliases = mkIf stdenv.isDarwin ({
am = lib.mkIf pkgs.stdenv.isDarwin "zsh ~/.config/zsh/am.sh";
o = "open";
oa = "open -a";
pinentry = "pinentry-mac";
} // lib.attrsets.mapAttrs (name: value: "open -a " + value) appCommands);
programs.firefox.package = mkIf stdenv.isDarwin pkgs.firefox-mac;
programs.chromium.package = mkIf stdenv.isDarwin pkgs.chromium-mac;
targets.darwin = {
defaults = {
"com.googlecode.iterm2" = import ./iterm2.nix;

View file

@ -463,9 +463,7 @@ in {
enable = true;
after = [ "org" ];
init = ''
; -*-emacs-lisp-*-
(setq org-babel-octave-shell-command "${pkgs.octave}/bin/octave -q")
(setq org-babel-matlab-shell-command "~/Applications/MATLAB_R2022b.app/bin/matlab -nosplash")
'';
};
@ -523,7 +521,6 @@ in {
'';
init = ''
; -*-emacs-lisp-*-
(defvar my/org-dir "~/Documents/org/")
(require 'oc)
(require 'oc-basic)
(require 'oc-csl)
@ -537,7 +534,7 @@ in {
(setq org-export-with-tags nil)
(setq org-publish-project-alist
'(("root"
:base-directory (expand-file-name my/org-dir)
:base-directory "${config.home.sessionVariables.ORGDIR}"
:publishing-function org-html-publish-to-html
:publishing-directory (expand-file-name "~/public_html")
:section-numbers nil
@ -551,8 +548,8 @@ in {
(setq org-html-head-include-default-style nil)
(setq org-html-head "<link rel=\"stylesheet\" href=\"https://cdn.simplecss.org/simple.min.css\" />")
(setq org-html-section)
(setq bibtex-completion-notes-path (expand-file-name "notes.org" my/org-dir))
(setq org-cite-global-bibliography '("~/Documents/org/zotero.bib"))
(setq bibtex-completion-notes-path "${config.home.sessionVariables.ORGDIR}/notes.org")
(setq org-cite-global-bibliography '("${config.home.sessionVariables.ORGDIR}/zotero.bib"))
(setq org-cite-export-processors '((t basic)))
(setq org-cite-follow-processor 'ivy-bibtex-org-cite-follow)
(setq org-cite-csl-styles-dir "~/Zotero/styles")
@ -566,7 +563,7 @@ in {
(setq org-export-latex-format-toc-function 'org-export-latex-no-toc)
(setq org-latex-pdf-process
'("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f"))
(add-to-list 'exec-path "/Users/willem/.nix-profile/bin")
(add-to-list 'exec-path "${config.home.homeDirectory}/.nix-profile/bin")
(add-to-list 'org-latex-classes
'("apa6"
"\\documentclass{apa6}"
@ -583,7 +580,7 @@ in {
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(setq org-agenda-files '("~/Documents/org" "~/Documents/org/ubc"))
(setq org-agenda-files '("${config.home.sessionVariables.ORGDIR}" "${config.home.sessionVariables.UBCDIR}"))
'';
hook = [
"(org-babel-after-execute . org-redisplay-inline-images)"
@ -606,7 +603,7 @@ in {
enable = true;
init = ''
(require 'org-download)
(setq-default org-download-image-dir "~/Documents/org/images")
(setq-default org-download-image-dir "${config.home.sessionVariables.ORGDIR}/images")
'';
hook = [ "(dired-mode-hook . org-download-enable)" ];
};
@ -618,8 +615,8 @@ in {
(setq org-ref-insert-cite-function
(lambda ()
(org-cite-insert nil)))
(setq org-ref-default-bibliography "~/Documents/org/zotero.bib")
(setq bibtex-completion-bibliography '("~/Documents/org/zotero.bib"))
(setq org-ref-default-bibliography "${config.home.sessionVariables.ORGDIR}/zotero.bib")
(setq bibtex-completion-bibliography '("${config.home.sessionVariables.ORGDIR}/zotero.bib"))
(require 'org-ref)
(require 'org-ref-ivy)
'';
@ -690,7 +687,7 @@ in {
yasnippet = {
enable = true;
config = ''
(setq yas-snippet-dirs '("~/Documents/org/snippets"))
(setq yas-snippet-dirs '("${config.home.sessionVariables.ORGDIR}/snippets"))
(yas-global-mode 1)
'';
};

10
flake.lock generated
View file

@ -53,13 +53,13 @@
"type": "github"
}
},
"nur": {
"nurrepo": {
"locked": {
"lastModified": 1675104428,
"narHash": "sha256-u0ivGegUvyfd76yuDpL2qAT8hGZQAlJ3s1nLXuFFrw4=",
"lastModified": 1675529301,
"narHash": "sha256-upLPV9gqFnfkwwZQfKEJDLXMv5lyeIpTOXCXFjPN2zA=",
"owner": "nix-community",
"repo": "NUR",
"rev": "f784e280fb43d0a95edfdc4f35b20fdb3dd8b720",
"rev": "ac7a6f0e289c4690f808f0865a0e7f766670bdfe",
"type": "github"
},
"original": {
@ -73,7 +73,7 @@
"home-manager": "home-manager",
"nixpkgs-22_11": "nixpkgs-22_11",
"nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur"
"nurrepo": "nurrepo"
}
},
"utils": {

View file

@ -8,11 +8,11 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs-22_11";
};
nur.url = "github:nix-community/NUR";
nurrepo.url = "github:nix-community/NUR";
};
outputs =
{ self, nixpkgs-unstable, nixpkgs-22_11, home-manager, nur, ... }@inputs:
{ self, nixpkgs-unstable, nixpkgs-22_11, home-manager, nurrepo, ... }@inputs:
let
system = "aarch64-darwin";
@ -28,7 +28,12 @@
];
};
nurNoPkgs = import nur {
nur = import nurrepo {
nurpkgs = pkgs;
pkgs = pkgs;
};
nurNoPkgs = import nurrepo {
nurpkgs = pkgs;
pkgs = throw "nixpkgs eval";
};
@ -38,11 +43,11 @@
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ nur.hmModules.nur ./home.nix ];
modules = [ nurrepo.hmModules.nur ./home.nix ];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = { inherit nurNoPkgs; };
extraSpecialArgs = { inherit nur nurNoPkgs; };
};
};
}

View file

@ -1,11 +1,11 @@
{ config, pkgs, lib, inputs, ... }:
{ config, pkgs, lib, inputs, nur, ... }:
let
inherit (pkgs) stdenv;
inherit (lib) mkIf;
emacsCommand = "emacsclient -c -nw";
homeDirectory = config.home.homeDirectory;
in {
in rec {
home = {
username = "willem";
homeDirectory = "/Users/willem";
@ -18,22 +18,6 @@ in {
builders-use-substitutes = true
'';
home.file.".gnupg/gpg-agent.conf".text = mkIf stdenv.isDarwin ''
pinentry-program "${pkgs.pinentry-touchid}/bin/pinentry-touchid"
default-cache-ttl 30
max-cache-ttl 600
'';
home.file.".config/zsh/am.sh" = mkIf stdenv.isDarwin {
executable = true;
source = let rev = "27353ec55abac8b5d73b8a061fb87f305c663adb";
in builtins.fetchurl {
url =
"https://raw.githubusercontent.com/mcthomas/Apple-Music-CLI-Player/${rev}/src/am.sh";
sha256 = "sha256-78zRpNg7/OR7p8dpsJt6Xc4j0Y+8zSUtm/PT94nf03M=";
};
};
home.keyboard = {
layout = "us";
variant = "colemak";
@ -45,9 +29,11 @@ in {
ctype = "en_US.UTF-8";
};
home.sessionVariables = {
home.sessionVariables = rec {
EDITOR = emacsCommand;
VISUAL = emacsCommand;
ORGDIR = "${home.homeDirectory}/Documents/org";
UBCDIR = "${ORGDIR}/ubc";
};
imports =
@ -57,6 +43,9 @@ in {
allowUnfree = true;
allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [ "discord" "unrar" "zoom" ];
packageOverrides = pkgs: {
nur = nur;
};
};
nixpkgs.overlays = [ (import ./overlays) ];

27
overlays/chromium-mac.nix Normal file
View file

@ -0,0 +1,27 @@
{ stdenv, pkgs, fetchurl, ... }:
let
versions = {
aarch64-darwin = "1101351";
x86_64-darwin = "1101350";
};
version = versions.${stdenv.hostPlatform.system};
pname = "chromium";
appName = "Chromium";
srcs = {
aarch64-darwin = fetchurl {
url = "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac_Arm/${version}/chrome-mac.zip";
sha256 = "sha256-LlbYlJmFLzyHIiygofa0Btm7NAOvWXXhmbjMHldVoGo=";
name = "${pname}_aarch64_${version}.zip";
};
x86_64-darwin = fetchurl {
url = "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/${version}/chrome-mac.zip";
sha256 = "sha256-O+OnjakEpjCRbSjDysEA6RKKaKaSMw+LSO2ZLcxz2vM=";
name = "${pname}_x86_64_${version}.zip";
};
};
src = srcs.${stdenv.hostPlatform.system};
in import ./mk-mac-binpkg.nix { inherit pkgs src pname appName version; srcsubdir = "chrome-mac"; }

View file

@ -1,4 +1,6 @@
self: super: {
chromium-mac = super.callPackage ./chromium-mac.nix { pkgs = super; };
firefox-mac = super.callPackage ./firefox-mac.nix { pkgs = super; };
pinentry-touchid = super.callPackage ./pinentry-touchid.nix { pkgs = super; };
qbittorrent-mac = super.callPackage ./qbittorrent-mac.nix { pkgs = super; };
spotify-mac = super.callPackage ./spotify-mac.nix { pkgs = super; };

12
overlays/firefox-mac.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs, fetchurl, ... }:
let
version = "109.0.1";
pname = "firefox";
appName = "Firefox";
src = fetchurl {
url = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/mac/en-CA/Firefox%20${version}.dmg";
sha256 = "sha256-V/8W3qqYhJmte2tq/ZSPtYChdhv8WFQoSORYRaxva9Y=";
name = "${pname}_${version}.dmg";
};
in import ./mk-mac-binpkg.nix { inherit pkgs src pname appName version; }

View file

@ -0,0 +1,25 @@
{ src, version, pname, appName, pkgs, srcsubdir ? ".", ... }:
pkgs.stdenv.mkDerivation {
inherit version src;
name = pname;
nativeBuildInputs = [ pkgs.undmg pkgs.unzip pkgs.makeWrapper ];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r "${srcsubdir}/${appName}.app" $out/Applications
# wrap executable to $out/bin
mkdir -p $out/bin
makeWrapper "$out/Applications/${appName}.app/Contents/MacOS/${appName}" "$out/bin/${pname}"
runHook postInstall
'';
}

View file

@ -1,33 +1,13 @@
{ stdenv, fetchurl, pkgs, ... }:
{ pkgs, fetchurl, ... }:
let
version = "4.4.5";
appName = "qBittorrent";
pname = "qbittorrent";
in stdenv.mkDerivation {
inherit pname;
name = pname;
src = fetchurl {
url =
"https://phoenixnap.dl.sourceforge.net/project/qbittorrent/qbittorrent-mac/qbittorrent-${version}/qbittorrent-${version}.dmg";
url = "https://phoenixnap.dl.sourceforge.net/project/qbittorrent/qbittorrent-mac/qbittorrent-${version}/qbittorrent-${version}.dmg";
sha256 = "sha256-9h+gFAEU0tKrltOjnOKLfylbbBunGZqvPzQogdP9uQM=";
};
in import ./mk-mac-binpkg.nix { inherit pkgs src pname appName version; }
nativeBuildInputs = [ pkgs.undmg pkgs.makeWrapper ];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r "${appName}.app" $out/Applications
# wrap executable to $out/bin
mkdir -p $out/bin
makeWrapper "$out/Applications/${appName}.app/Contents/MacOS/${pname}" "$out/bin/${pname}"
runHook postInstall
'';
}

View file

@ -1,39 +1,21 @@
{ stdenv, pkgs, fetchurl, ... }:
let
appName = "VLC";
pname = "vlc";
version = "3.0.18";
srcs = {
aarch64-darwin = fetchurl {
url =
"http://get.videolan.org/vlc/${version}/macosx/vlc-${version}-arm64.dmg";
url = "http://get.videolan.org/vlc/${version}/macosx/vlc-${version}-arm64.dmg";
sha256 = "sha256-mcJZvbxSIf1QgX9Ri3Dpv57hdeiQdDkDyYB7x3hmj0c=";
name = "${pname}_aarch64_${version}.dmg";
};
x86_64-darwin = fetchurl {
url =
"http://get.videolan.org/vlc/${version}/macosx/vlc-${version}-intel64.dmg";
url = "http://get.videolan.org/vlc/${version}/macosx/vlc-${version}-intel64.dmg";
sha256 = "sha256-iO3N/Os70vaANn2QCdOKDBR/p1jy3TleQ0EsHgjOHMs=";
name = "${pname}_x86_64_${version}.dmg";
};
};
pname = "vlc";
in stdenv.mkDerivation {
name = pname;
src = srcs.${stdenv.hostPlatform.system};
src = srcs.${stdenv.hostPlatform.system};
in import ./mk-mac-binpkg.nix { inherit stdenv pkgs fetchurl src pname appName version; }
nativeBuildInputs = [ pkgs.undmg pkgs.makeWrapper ];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r "VLC.app" $out/Applications
# wrap executable to $out/bin
mkdir -p $out/bin
makeWrapper "$out/Applications/VLC.app/Contents/MacOS/VLC" "$out/bin/vlc"
runHook postInstall
'';
}

View file

@ -18,6 +18,7 @@ let
pass-extended = pkgs.pass.withExtensions (exts: [ exts.pass-genphrase exts.pass-otp exts.pass-import ]);
python-wp = pkgs.python310.withPackages (p: with p; [ setuptools pyaml requests latexify-py ]);
node-packages = with pkgs.nodePackages; [ bash-language-server ];
octave-wp = pkgs.octave.withPackages (p: with p; [ symbolic ]);
in {
home.packages = with pkgs;
[
@ -44,7 +45,7 @@ in {
nixfmt
nix-review
nmap
octave
octave-wp
openssh
pass-extended
plantuml

View file

@ -2,6 +2,22 @@
{
programs = {
browserpass = {
enable = true;
browsers = [
"chromium"
"firefox"
];
};
chromium = {
enable = true;
extensions = [
{ id = "naepdomgkenhinolocfifgehidddafch"; } # browserpass
{ id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin
];
};
direnv = {
enable = true;
nix-direnv = { enable = true; };
@ -12,6 +28,12 @@
enableAliases = true;
};
firefox = {
enable = true;
extensions = [
];
};
git = {
enable = true;
delta = { enable = true; };
@ -109,33 +131,33 @@
autocd = true;
defaultKeymap = "emacs";
envExtra = ''
#!/usr/bin/env zsh
export GPG_TTY=$(tty)
eval $(gpg-agent --daemon -q 2>/dev/null)
#!/usr/bin/env zsh
export GPG_TTY=$(tty)
eval $(gpg-agent --daemon -q 2>/dev/null)
function gsearch() {
open -a Safari "https://google.com/search?q=$(echo $@ | sed -e 's/ /%20/g')"
}
function gsearch() {
open -a Safari "https://google.com/search?q=$(echo $@ | sed -e 's/ /%20/g')"
}
function plistxml2nix() {
tail -n +4 |
function plistxml2nix() {
tail -n +4 |
sed -e "s/<dict>/{/g" \
-e "s/<\/dict>/\}\;/g" \
-e "s/<key>/\"/g" \
-e "s/<\/key>/\"=/g" \
-e "s/<real>//g" \
-e "s/<\/real>/;/g" \
-e "s/<integer>//g" \
-e "s/<\/integer>/;/g" \
-e "s/<string>/\"/g" \
-e "s/<\/string>/\"\;/g" \
-e "s/<array>/\[/g" \
-e "s/<\/array>/\];/g" \
-e "s/<true\/>/true;/g" \
-e "s/<false\/>/false;/g" \
-e "$ d" |
-e "s/<\/dict>/\}\;/g" \
-e "s/<key>/\"/g" \
-e "s/<\/key>/\"=/g" \
-e "s/<real>//g" \
-e "s/<\/real>/;/g" \
-e "s/<integer>//g" \
-e "s/<\/integer>/;/g" \
-e "s/<string>/\"/g" \
-e "s/<\/string>/\"\;/g" \
-e "s/<array>/\[/g" \
-e "s/<\/array>/\];/g" \
-e "s/<true\/>/true;/g" \
-e "s/<false\/>/false;/g" \
-e "$ d" |
sed \-e "$ s/;//"
}
}
'';
dotDir = ".config/zsh";
history = {
@ -144,19 +166,16 @@ function plistxml2nix() {
ignoreDups = true;
};
shellAliases = {
emw = "emacs";
cd = "z";
e = "emacsclient -c -nw";
em = "emacs -nw";
ew = "emacsclient -c";
e = "emacsclient -c -nw";
np = "nix-shell -p";
hms = "home-manager switch";
cd = "z";
l = "ls -1";
web = "open -a Safari";
email = "open -a Mail";
o = "open -a";
am = lib.mkIf pkgs.stdenv.isDarwin "zsh ~/.config/zsh/am.sh";
pinentry = "pinentry-mac";
np = "nix-shell -p";
org = "z ${config.home.sessionVariables.ORGDIR}";
ubc = "z ${config.home.sessionVariables.UBCDIR}";
emw = "emacs";
};
};