more darwin config, fix freecad

This commit is contained in:
willemml 2023-02-08 13:07:50 -08:00
parent 6a027c3971
commit 32a4fc9430
Signed by: willemml
GPG key ID: C3DE5DF6198DACBD
7 changed files with 136 additions and 40 deletions

View file

@ -33,6 +33,12 @@
"${pkgs.pass}/bin/pass 'music/spotify' | head -n1"
"--backend"
"portaudio"
"--bitrate"
"320"
"--device-type"
"computer"
"--volume_controller"
"softvol"
];
KeepAlive = true;
UserName = "${config.home.username}";

View file

@ -14,7 +14,7 @@ let
spotify-mac
vlc-mac
];
linux = with pkgs; [ vlc qbittorrent ];
linux = with pkgs; [ vlc qbittorrent freecad spotify ];
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 ];
@ -44,6 +44,7 @@ in
htop
jq
nix-review
nix-zsh-completions
nixfmt
nixpkgs-fmt
nmap
@ -59,6 +60,7 @@ in
rsync
rustup
shellcheck
shfmt
spotify-tui
spotifyd
sqlite
@ -71,6 +73,7 @@ in
unzip
wget
yq
zsh-completions
]
++ lib.optionals stdenv.isDarwin darwin
++ lib.optionals stdenv.isLinux linux

View file

@ -2,6 +2,8 @@
{
programs = {
bash.enableCompletion = true;
browserpass = {
enable = true;
browsers = [
@ -138,57 +140,62 @@
zsh = {
enable = true;
enableCompletion = true;
enableSyntaxHighlighting = true;
enableVteIntegration = true;
autocd = true;
defaultKeymap = "emacs";
envExtra = ''
#!/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 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" |
sed \-e "$ s/;//"
}
'';
dotDir = ".config/zsh";
enableAutosuggestions = true;
enableCompletion = true;
enableSyntaxHighlighting = true;
enableVteIntegration = true;
history = {
path = "$HOME/.local/zsh/history";
extended = true;
ignoreDups = true;
};
historySubstringSearch.enable = true;
loginExtra = ''
#!/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 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" |
sed \-e "$ s/;//"
}
'';
shellAliases = {
cd = "z";
drs = "darwin-rebuild switch --flake ${config.home.homeDirectory}/.config/dotfiles.nix#";
e = "emacsclient -c -nw";
em = "emacs -nw";
emw = "emacs";
ew = "emacsclient -c";
drs = "darwin-rebuild switch --flake ${config.home.homeDirectory}/.config/dotfiles.nix#";
l = "ls -1";
np = "nix-shell -p";
org = "z ${config.home.sessionVariables.ORGDIR}";
ubc = "z ${config.home.sessionVariables.UBCDIR}";
emw = "emacs";
};
};

View file

@ -0,0 +1,32 @@
# taken from nix-darwin repo
# https://github.com/LnL7/nix-darwin/blob/87b9d090ad39b25b2400029c64825fc2a8868943/modules/examples/lnl.nix
{ pkgs, stdenv, ... }:
stdenv.runCommand "darwin-zsh-completions-0.0.0"
{ preferLocalBuild = true; }
''
mkdir -p $out/share/zsh/site-functions
cat <<-'EOF' > $out/share/zsh/site-functions/_darwin-rebuild
#compdef darwin-rebuild
#autoload
_nix-common-options
local -a _1st_arguments
_1st_arguments=(
'switch:Build, activate, and update the current generation'\
'build:Build without activating or updating the current generation'\
'check:Build and run the activation sanity checks'\
'changelog:Show most recent entries in the changelog'\
)
_arguments \
'--list-generations[Print a list of all generations in the active profile]'\
'--rollback[Roll back to the previous configuration]'\
{--switch-generation,-G}'[Activate specified generation]'\
'(--profile-name -p)'{--profile-name,-p}'[Profile to use to track current and previous system configurations]:Profile:_nix_profiles'\
'1:: :->subcmds' && return 0
case $state in
subcmds)
_describe -t commands 'darwin-rebuild subcommands' _1st_arguments
;;
esac
EOF
''

View file

@ -1,5 +1,6 @@
self: super: {
chromium-mac = super.callPackage ./chromium-mac.nix { pkgs = super; };
darwin-zsh-completions = import ./darwin-zsh-completions.nix { pkgs = super; };
firefox-mac = super.callPackage ./firefox-mac.nix { pkgs = super; };
freecad-mac = super.callPackage ./freecad-mac.nix { pkgs = super; };
pinentry-touchid = super.callPackage ./pinentry-touchid.nix { pkgs = super; };

View file

@ -1,15 +1,15 @@
{ pkgs, fetchurl, ... }:
let
version = "31483";
date = "2022-12-31";
version = "0.20.2";
date = "2022-12-27";
appName = "FreeCAD";
pname = "freecad";
src = fetchurl {
url =
"https://github.com/FreeCAD/FreeCAD-Bundle/releases/download/weekly-builds/FreeCAD_weekly-builds-${version}-${date}-conda-macOS-arm-py311.dmg";
sha256 = "sha256-dm6QbAazx1vFrkakkCsfCqyGzRED9guI7yFMQ24mU9o=";
"https://github.com/FreeCAD/FreeCAD/releases/download/${version}/FreeCAD_${version}-${date}-conda-macOS-x86_64-py310.dmg";
sha256 = "sha256-OAi98HUacHcLHVYSadnQFPnEhutJvE4YfRBtPSZk00c=";
};
in
pkgs.stdenv.mkDerivation {

View file

@ -1,6 +1,22 @@
{ pkgs, ... }:
{
environment.etc."nix/user-sandbox.sb".text = ''
(version 1)
(allow default)
(deny file-write*
(subpath "/nix"))
(allow file-write*
(subpath "/nix/var/nix/gcroots/per-user")
(subpath "/nix/var/nix/profiles/per-user"))
(allow process-exec
(literal "/bin/ps")
(with no-sandbox))
'';
environment.loginShell = "${pkgs.zsh}/bin/zsh -l";
environment.variables.SHELL = "${pkgs.zsh}/bin/zsh";
environment.variables.LANG = "en_US.UTF-8";
environment.systemPackages = with pkgs; [ ];
nix = {
@ -15,8 +31,39 @@
};
programs.bash.enable = true;
programs.nix-index.enable = true;
programs.zsh.enable = true;
programs.zsh.enableBashCompletion = true;
programs.zsh.enableFzfCompletion = true;
programs.zsh.enableFzfGit = true;
programs.zsh.enableFzfHistory = true;
programs.zsh.loginShellInit = ''
reexec() {
unset __NIX_DARWIN_SET_ENVIRONMENT_DONE
unset __ETC_ZPROFILE_SOURCED __ETC_ZSHENV_SOURCED __ETC_ZSHRC_SOURCED
exec $SHELL -c 'echo >&2 "reexecuting shell: $SHELL" && exec $SHELL -l'
}
reexec-sandbox() {
unset __NIX_DARWIN_SET_ENVIRONMENT_DONE
unset __ETC_ZPROFILE_SOURCED __ETC_ZSHENV_SOURCED __ETC_ZSHRC_SOURCED
export IN_NIX_SANDBOX=1
exec /usr/bin/sandbox-exec -f /etc/nix/user-sandbox.sb $SHELL -l
}
'';
programs.zsh.promptInit = ''
autoload -U promptinit && promptinit
setopt PROMPTSUBST
_prompt_nix() {
[ -z "$IN_NIX_SHELL" ] || echo "%F{yellow}%B[''${name:+$name}]%b%f "
}
PS1='%F{red}%B%(?..%? )%b%f%# '
RPS1='$(_prompt_nix)%F{green}%~%f'
if [ -n "$IN_NIX_SANDBOX" ]; then
PS1+='%F{red}[sandbox]%f '
fi
'';
services.nix-daemon.enable = true;