Init
This commit is contained in:
11
modules/darwin/README.md
Normal file
11
modules/darwin/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
## Layout
|
||||
```
|
||||
.
|
||||
├── dock # MacOS dock configuration
|
||||
├── casks.nix # List of homebrew casks
|
||||
├── default.nix # Defines module, system-level config
|
||||
├── files.nix # Non-Nix, static configuration files (now immutable!)
|
||||
├── home-manager.nix # Defines user programs
|
||||
├── packages.nix # List of packages to install for MacOS
|
||||
```
|
||||
6
modules/darwin/casks.nix
Normal file
6
modules/darwin/casks.nix
Normal file
@@ -0,0 +1,6 @@
|
||||
_:
|
||||
|
||||
[
|
||||
"raycast"
|
||||
"1password"
|
||||
]
|
||||
107
modules/darwin/dock/default.nix
Normal file
107
modules/darwin/dock/default.nix
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
# Original source: https://gist.github.com/antifuchs/10138c4d838a63c0a05e725ccd7bccdd
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.local.dock;
|
||||
inherit (pkgs) stdenv dockutil;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
local.dock = {
|
||||
enable = mkOption {
|
||||
description = "Enable dock";
|
||||
default = stdenv.isDarwin;
|
||||
example = false;
|
||||
};
|
||||
|
||||
entries = mkOption {
|
||||
description = "Entries on the Dock";
|
||||
type =
|
||||
with types;
|
||||
listOf (submodule {
|
||||
options = {
|
||||
path = lib.mkOption { type = str; };
|
||||
section = lib.mkOption {
|
||||
type = str;
|
||||
default = "apps";
|
||||
};
|
||||
options = lib.mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
});
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
username = mkOption {
|
||||
description = "Username to apply the dock settings to";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
normalize = path: if hasSuffix ".app" path then path + "/" else path;
|
||||
entryURI =
|
||||
path:
|
||||
"file://"
|
||||
+ (builtins.replaceStrings
|
||||
[
|
||||
" "
|
||||
"!"
|
||||
"\""
|
||||
"#"
|
||||
"$"
|
||||
"%"
|
||||
"&"
|
||||
"'"
|
||||
"("
|
||||
")"
|
||||
]
|
||||
[
|
||||
"%20"
|
||||
"%21"
|
||||
"%22"
|
||||
"%23"
|
||||
"%24"
|
||||
"%25"
|
||||
"%26"
|
||||
"%27"
|
||||
"%28"
|
||||
"%29"
|
||||
]
|
||||
(normalize path)
|
||||
);
|
||||
wantURIs = concatMapStrings (entry: "${entryURI entry.path}\n") cfg.entries;
|
||||
createEntries = concatMapStrings (
|
||||
entry:
|
||||
"${dockutil}/bin/dockutil --no-restart --add '${entry.path}' --section ${entry.section} ${entry.options}\n"
|
||||
) cfg.entries;
|
||||
in
|
||||
{
|
||||
system.activationScripts.postActivation.text = ''
|
||||
echo >&2 "Setting up the Dock for ${cfg.username}..."
|
||||
su ${cfg.username} -s /bin/sh <<'USERBLOCK'
|
||||
haveURIs="$(${dockutil}/bin/dockutil --list | ${pkgs.coreutils}/bin/cut -f2)"
|
||||
if ! diff -wu <(echo -n "$haveURIs") <(echo -n '${wantURIs}') >&2 ; then
|
||||
echo >&2 "Resetting Dock."
|
||||
${dockutil}/bin/dockutil --no-restart --remove all
|
||||
${createEntries}
|
||||
killall Dock
|
||||
else
|
||||
echo >&2 "Dock setup complete."
|
||||
fi
|
||||
USERBLOCK
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
34
modules/darwin/files.nix
Normal file
34
modules/darwin/files.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{ user, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
xdg_configHome = "${config.users.users.${user}.home}/.config";
|
||||
xdg_dataHome = "${config.users.users.${user}.home}/.local/share";
|
||||
xdg_stateHome = "${config.users.users.${user}.home}/.local/state"; in
|
||||
{
|
||||
|
||||
# Raycast script so that "Run Emacs" is available and uses Emacs daemon
|
||||
"${xdg_dataHome}/bin/emacsclient" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/bin/zsh
|
||||
#
|
||||
# Required parameters:
|
||||
# @raycast.schemaVersion 1
|
||||
# @raycast.title Run Emacs
|
||||
# @raycast.mode silent
|
||||
#
|
||||
# Optional parameters:
|
||||
# @raycast.packageName Emacs
|
||||
# @raycast.icon ${xdg_dataHome}/img/icons/Emacs.icns
|
||||
# @raycast.iconDark ${xdg_dataHome}/img/icons/Emacs.icns
|
||||
|
||||
if [[ $1 = "-t" ]]; then
|
||||
# Terminal mode
|
||||
${pkgs.emacs}/bin/emacsclient -t $@
|
||||
else
|
||||
# GUI mode
|
||||
${pkgs.emacs}/bin/emacsclient -c -n $@
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
96
modules/darwin/home-manager.nix
Normal file
96
modules/darwin/home-manager.nix
Normal file
@@ -0,0 +1,96 @@
|
||||
{ config, pkgs, lib, home-manager, ... }:
|
||||
|
||||
let
|
||||
user = "cschmatzler";
|
||||
# Define the content of your file as a derivation
|
||||
myEmacsLauncher = pkgs.writeScript "emacs-launcher.command" ''
|
||||
#!/bin/sh
|
||||
emacsclient -c -n &
|
||||
'';
|
||||
sharedFiles = import ../shared/files.nix { inherit config pkgs; };
|
||||
additionalFiles = import ./files.nix { inherit user config pkgs; };
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./dock
|
||||
];
|
||||
|
||||
# It me
|
||||
users.users.${user} = {
|
||||
name = "${user}";
|
||||
home = "/Users/${user}";
|
||||
isHidden = false;
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
|
||||
homebrew = {
|
||||
enable = true;
|
||||
casks = pkgs.callPackage ./casks.nix {};
|
||||
# onActivation.cleanup = "uninstall";
|
||||
|
||||
# These app IDs are from using the mas CLI app
|
||||
# mas = mac app store
|
||||
# https://github.com/mas-cli/mas
|
||||
#
|
||||
# $ nix shell nixpkgs#mas
|
||||
# $ mas search <app name>
|
||||
#
|
||||
# If you have previously added these apps to your Mac App Store profile (but not installed them on this system),
|
||||
# you may receive an error message "Redownload Unavailable with This Apple ID".
|
||||
# This message is safe to ignore. (https://github.com/dustinlyons/nixos-config/issues/83)
|
||||
|
||||
masApps = {
|
||||
# "wireguard" = 1451685025;
|
||||
};
|
||||
};
|
||||
|
||||
# Enable home-manager
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
users.${user} = { pkgs, config, lib, ... }:{
|
||||
home = {
|
||||
enableNixpkgsReleaseCheck = false;
|
||||
packages = pkgs.callPackage ./packages.nix {};
|
||||
file = lib.mkMerge [
|
||||
sharedFiles
|
||||
additionalFiles
|
||||
{ "emacs-launcher.command".source = myEmacsLauncher; }
|
||||
];
|
||||
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
programs = {} // import ../shared/home-manager.nix { inherit config pkgs lib; };
|
||||
|
||||
# Marked broken Oct 20, 2022 check later to remove this
|
||||
# https://github.com/nix-community/home-manager/issues/3344
|
||||
manual.manpages.enable = false;
|
||||
};
|
||||
};
|
||||
|
||||
# Fully declarative dock using the latest from Nix Store
|
||||
local = {
|
||||
dock = {
|
||||
enable = true;
|
||||
username = user;
|
||||
entries = [
|
||||
{ path = "/Applications/Safari.app/"; }
|
||||
{ path = "/System/Applications/Messages.app/"; }
|
||||
{ path = "/System/Applications/Notes.app/"; }
|
||||
{ path = "${pkgs.alacritty}/Applications/Alacritty.app/"; }
|
||||
{ path = "/System/Applications/Music.app/"; }
|
||||
{ path = "/System/Applications/Photos.app/"; }
|
||||
{ path = "/System/Applications/Photo Booth.app/"; }
|
||||
{ path = "/System/Applications/System Settings.app/"; }
|
||||
{
|
||||
path = toString myEmacsLauncher;
|
||||
section = "others";
|
||||
}
|
||||
{
|
||||
path = "${config.users.users.${user}.home}/Downloads";
|
||||
section = "others";
|
||||
options = "--sort name --view grid --display stack";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
7
modules/darwin/packages.nix
Normal file
7
modules/darwin/packages.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{ pkgs }:
|
||||
|
||||
with pkgs;
|
||||
let shared-packages = import ../shared/packages.nix { inherit pkgs; }; in
|
||||
shared-packages ++ [
|
||||
dockutil
|
||||
]
|
||||
37
modules/darwin/secrets.nix
Normal file
37
modules/darwin/secrets.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{ config, pkgs, agenix, secrets, ... }:
|
||||
|
||||
let user = "cschmatzler"; in
|
||||
{
|
||||
age.identityPaths = [
|
||||
"/Users/${user}/.ssh/id_ed25519"
|
||||
];
|
||||
|
||||
# Your secrets go here
|
||||
#
|
||||
# Note: the installWithSecrets command you ran to boostrap the machine actually copies over
|
||||
# a Github key pair. However, if you want to store the keypair in your nix-secrets repo
|
||||
# instead, you can reference the age files and specify the symlink path here. Then add your
|
||||
# public key in shared/files.nix.
|
||||
#
|
||||
# If you change the key name, you'll need to update the SSH configuration in shared/home-manager.nix
|
||||
# so Github reads it correctly.
|
||||
|
||||
#
|
||||
# age.secrets."github-ssh-key" = {
|
||||
# symlink = true;
|
||||
# path = "/Users/${user}/.ssh/id_github";
|
||||
# file = "${secrets}/github-ssh-key.age";
|
||||
# mode = "600";
|
||||
# owner = "${user}";
|
||||
# group = "staff";
|
||||
# };
|
||||
|
||||
# age.secrets."github-signing-key" = {
|
||||
# symlink = false;
|
||||
# path = "/Users/${user}/.ssh/pgp_github.key";
|
||||
# file = "${secrets}/github-signing-key.age";
|
||||
# mode = "600";
|
||||
# owner = "${user}";
|
||||
# };
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user