39 Commits

Author SHA1 Message Date
6933083cda adjust some zellij and helix keybinds 2025-03-27 13:01:53 -04:00
39d9cb7e5a more lsps and fix syntax var colors 2025-03-24 09:53:30 -04:00
b270e1643c update readme and tweak helix config 2025-03-23 18:41:37 -04:00
cdbd94e64e upgrade to nextcloud 31 (without apps) 2025-03-23 20:53:35 +00:00
9e3b003241 fix: enable calibre-web in preset 2025-03-23 20:47:05 +00:00
802544575f fixes for read key 2025-03-23 19:11:27 +00:00
a85180beee fix: enable prometheus stuff 2025-03-23 17:30:59 +00:00
b901b9abd9 zellij tweaks and session switching 2025-03-23 10:10:56 -04:00
870ab6894d fixes for swan 2025-03-23 13:30:57 +00:00
12604f3109 fix flame settings 2025-03-23 00:32:06 +00:00
59e67fb406 build succeed on swan 2025-03-22 23:45:06 +00:00
6a7706ca85 some conveniences for helix 2025-03-21 13:51:28 -04:00
12d0bccb42 integrate helix with fzf shortcuts 2025-03-19 14:16:01 -04:00
cf7966d73d tweaks for ghostty and zellij 2025-03-19 13:51:42 -04:00
fa1482dcfc some basic zellij and helix configs 2025-03-18 21:47:40 -04:00
8e7ccbda59 use ctrl-f to accept autosuggestions 2025-03-17 23:30:59 -04:00
59c5ca4816 zellij and helix config 2025-03-17 23:30:38 -04:00
442249c242 replace wezterm with ghostty on dock 2025-03-17 21:44:13 -04:00
5eb2b003d4 fix helix color for primary selection 2025-03-17 21:40:04 -04:00
ef6070fe6d update hammerspoon notification dismissal for macos 15 2025-03-17 12:04:21 -04:00
38906a802d reorg flake lines and remove unnecessary stanzas 2025-03-17 11:38:50 -04:00
852ecf0b91 tweaks for ghostty, helix, zed 2025-03-17 11:00:19 -04:00
a611b0ab69 move tree-sitter packages out of flake 2025-03-16 21:19:16 -04:00
6802c4de2f fix: notmuch missing from desktop 2025-03-16 20:55:03 -04:00
4dc9590ff8 replace wezterm with ghostty while i figure out issues 2025-03-16 16:22:41 -04:00
e0588878b1 darwin build 2025-03-16 15:12:07 -04:00
98356634cd switch on darwin 2025-03-16 14:00:38 -04:00
1833b4b46c add home-manager to base nixos config 2025-03-14 20:03:24 +00:00
3087b1a39c fix home-manager module in nixos rebuild 2025-03-14 15:47:08 +00:00
a3ad019f4b add generators and clean up directories 2025-03-14 00:13:56 +00:00
bdf163a50a consolidate build functions 2025-03-12 01:51:12 +00:00
bf273925ad still working on consolidating 2025-03-11 02:31:22 +00:00
1eae89b8ab coalescing code for imports 2025-03-10 03:37:48 +00:00
90fd9f54a7 add nix settings for darwin 2025-03-10 02:43:31 +00:00
2b1106ec94 move nix settings from home-manager to nixos 2025-03-10 02:40:01 +00:00
fbb00d9504 fix hosts for x86_64-linux 2025-03-09 22:29:41 +00:00
75d4dbe868 move apps into pkgs and rename hosts 2025-03-09 18:04:01 +00:00
37d1d7724a move encrypted secrets near relevant files 2025-03-09 17:09:33 +00:00
f59ac536a2 fix neovim colors 2025-03-09 16:31:29 +00:00
150 changed files with 1841 additions and 1899 deletions

View File

@ -8,38 +8,38 @@ configuration may be difficult to translate to a non-Nix system.
## System Features ## System Features
| Feature | Program | Configuration | | Feature | Program | Configuration |
|----------------|-----------------------------------------------------|-----------------------------------------------| |----------------|-----------------------------------------------------|-----------------------------------------------------------------------------------|
| OS | [NixOS](https://nixos.org) | [Link](./modules/nixos) | | OS | [NixOS](https://nixos.org) | [Link](./platforms/nixos) |
| Display Server | [X11](https://www.x.org/wiki/) | [Link](./modules/nixos/graphical/xorg.nix) | | Display Server | [X11](https://www.x.org/wiki/) | [Link](./platforms/nixos/modules/nmasur/profiles/gui.nix) |
| Compositor | [Picom](https://github.com/yshui/picom) | [Link](./modules/nixos/graphical/picom.nix) | | Compositor | [Picom](https://github.com/yshui/picom) | [Link](./platforms/home-manager/modules/nmasur/presets/services/picom.nix) |
| Window Manager | [i3](https://i3wm.org/) | [Link](./modules/nixos/graphical/i3.nix) | | Window Manager | [i3](https://i3wm.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/i3.nix) |
| Panel | [Polybar](https://polybar.github.io/) | [Link](./modules/nixos/graphical/polybar.nix) | | Panel | [Polybar](https://polybar.github.io/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/polybar.nix) |
| Font | [Victor Mono](https://rubjo.github.io/victor-mono/) | [Link](./modules/nixos/graphical/fonts.nix) | | Font | [Victor Mono](https://rubjo.github.io/victor-mono/) | [Link](./platforms/home-manager/modules/nmasur/presets/fonts.nix) |
| Launcher | [Rofi](https://github.com/davatorium/rofi) | [Link](./modules/nixos/graphical/rofi.nix) | | Launcher | [Rofi](https://github.com/davatorium/rofi) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix) |
## User Features ## User Features
| Feature | Program | Configuration | | Feature | Program | Configuration |
|--------------|----------------------------------------------------------------------------------|----------------------------------------------------| |--------------|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| Dotfiles | [Home-Manager](https://github.com/nix-community/home-manager) | [Link](./modules/common) | | Dotfiles | [Home-Manager](https://github.com/nix-community/home-manager) | [Link](./platforms/home-manager) |
| Terminal | [Kitty](https://sw.kovidgoyal.net/kitty/) | [Link](./modules/common/applications/kitty.nix) | | Terminal | [Ghostty](https://sw.kovidgoyal.net/kitty/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/ghostty.nix) |
| Shell | [Fish](https://fishshell.com/) | [Link](./modules/common/shell/fish) | | Shell | [Fish](https://fishshell.com/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/fish.nix) |
| Shell Prompt | [Starship](https://starship.rs/) | [Link](./modules/common/shell/starship.nix) | | Shell Prompt | [Starship](https://starship.rs/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/starship.nix) |
| Colorscheme | [Gruvbox](https://github.com/morhetz/gruvbox) | [Link](./colorscheme/gruvbox/default.nix) | | Colorscheme | [Gruvbox](https://github.com/morhetz/gruvbox) | [Link](./colorscheme/gruvbox/default.nix) |
| Wallpaper | [Road](https://gitlab.com/exorcist365/wallpapers/-/blob/master/gruvbox/road.jpg) | [Link](./hosts/tempest/default.nix) | | Wallpaper | [Road](https://gitlab.com/exorcist365/wallpapers/-/blob/master/gruvbox/road.jpg) | [Link](./hosts/x86_64-linux/tempest/default.nix) |
| Text Editor | [Neovim](https://neovim.io/) | [Link](./modules/common/neovim/config) | | Text Editor | [Neovim](https://neovim.io/) | [Link](./pkgs/applications/editors/neovim/nmasur/neovim/package.nix) |
| Browser | [Firefox](https://www.mozilla.org/en-US/firefox/new/) | [Link](./modules/common/applications/firefox.nix) | | Browser | [Firefox](https://www.mozilla.org/en-US/firefox/new/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/firefox.nix) |
| E-Mail | [Aerc](https://aerc-mail.org/) | [Link](./modules/common/mail/aerc.nix) | | E-Mail | [Aerc](https://aerc-mail.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/aerc.nix) |
| File Manager | [Nautilus](https://wiki.gnome.org/action/show/Apps/Files) | [Link](./modules/common/applications/nautilus.nix) | | File Manager | [Nautilus](https://wiki.gnome.org/action/show/Apps/Files) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/nautilus.nix) |
| PDF Reader | [Zathura](https://pwmt.org/projects/zathura/) | [Link](./modules/common/applications/media.nix) | | PDF Reader | [Zathura](https://pwmt.org/projects/zathura/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/zathura.nix) |
| Video Player | [mpv](https://mpv.io/) | [Link](./modules/common/applications/media.nix) | | Video Player | [mpv](https://mpv.io/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/mpv.nix) |
## macOS Features ## macOS Features
| Feature | Program | Configuration | | Feature | Program | Configuration |
|----------|---------------------------------------------|--------------------------------------| |----------|---------------------------------------------|--------------------------------------|
| Keybinds | [Hammerspoon](https://www.hammerspoon.org/) | [Link](./modules/darwin/hammerspoon) | | Keybinds | [Hammerspoon](https://www.hammerspoon.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/hammerspoon/) |
# Diagram # Diagram
@ -51,15 +51,16 @@ configuration may be difficult to translate to a non-Nix system.
This repo contains a few more elaborate elements of configuration. This repo contains a few more elaborate elements of configuration.
- [Neovim config](./modules/common/neovim/default.nix) generated with Nix2Vim - [Neovim config](./pkgs/applications/editors/neovim/nmasur/neovim/package.nix)
and source-controlled plugins, differing based on installed LSPs, for example. generated with Nix2Vim and source-controlled plugins,
- [Caddy JSON](./modules/nixos/services/caddy.nix) file (routes, etc.) based differing based on installed LSPs, for example. - [Caddy
dynamically on enabled services rendered with Nix. JSON](./platforms/nixos/modules/nmasur/presets/services/caddy.nix) file (routes,
- [Grafana config](./modules/nixos/services/grafana.nix) rendered with Nix. etc.) based dynamically on enabled services rendered with Nix. - [Grafana
- Custom [secrets deployment](./modules/nixos/services/secrets.nix) similar to config](./platforms/nixos/modules/nmasur/presets/services/grafana/grafana.nix)
agenix. rendered with Nix. - Custom [secrets
- Base16 [colorschemes](./colorscheme/) applied to multiple applications, deployment](./platforms/nixos/modules/secrets.nix) similar to agenix. - Base16
including Firefox userChrome. [colorschemes](./colorscheme/) applied to multiple applications, including
Firefox userChrome.
--- ---

View File

@ -1,9 +0,0 @@
# Apps
These are all my miscellaneous utilies and scripts to accompany this project.
They can be run with:
```
nix run github:nmasur/dotfiles#appname
```

View File

@ -1,31 +0,0 @@
{ pkgs, ... }:
rec {
# Show quick helper
default = import ./help.nix { inherit pkgs; };
# Format primary disk
format-root = import ./format-root.nix { inherit pkgs; };
# Format and install from nothing (deprecated)
installer = import ./installer.nix { inherit pkgs; };
# Display the readme for this repository
readme = import ./readme.nix { inherit pkgs; };
# Rebuild
rebuild = import ./rebuild.nix { inherit pkgs; };
# Load the SSH key for this machine
loadkey = import ./loadkey.nix { inherit pkgs; };
# Encrypt secret for all machines
encrypt-secret = import ./encrypt-secret.nix { inherit pkgs; };
# Re-encrypt secrets for all machines
reencrypt-secrets = import ./reencrypt-secrets.nix { inherit pkgs; };
# Run neovim as an app
neovim = import ./neovim.nix { inherit pkgs; };
nvim = neovim;
}

View File

@ -1,19 +0,0 @@
{ pkgs, ... }:
{
# nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age
type = "app";
program = builtins.toString (
pkgs.writeShellScript "encrypt-secret" ''
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
read -p "Secret: " secret
printf "\nEncrypting...\n\n" 1>&2
tmpfile=$(mktemp)
echo "''${secret}" > ''${tmpfile}
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${builtins.toString ../misc/public-keys} $tmpfile
rm $tmpfile
''
);
}

View File

@ -1,9 +0,0 @@
{ pkgs, ... }:
{
# This script will partition and format drives; use at your own risk!
type = "app";
program = pkgs.lib.getExe pkgs.nmasur.format-root;
}

View File

@ -1,24 +0,0 @@
{ pkgs, ... }:
{
type = "app";
program = builtins.toString (
pkgs.writeShellScript "default" ''
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
echo ""
echo ""
${pkgs.gum}/bin/gum format --type=template -- \
' {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
' {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
' {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
' {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
' {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
' {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
' {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \
echo ""
echo ""
''
);
}

View File

@ -1,50 +0,0 @@
{ pkgs, ... }:
{
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
# This script will partition and format drives; use at your own risk!
type = "app";
program = builtins.toString (
pkgs.writeShellScript "installer" ''
set -e
DISK=$1
FLAKE=$2
PARTITION_PREFIX=""
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
--foreground "#fb4934" \
"Missing required parameter." \
"Usage: installer -- <disk> <host>" \
"Example: installer -- nvme0n1 tempest" \
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest"
echo "(exiting)"
exit 1
fi
case "$DISK" in nvme*)
PARTITION_PREFIX="p"
esac
${pkgs.gum}/bin/gum confirm \
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \
--default=false
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
mount /dev/disk/by-label/nixos /mnt
mkdir --parents /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
''
);
}

View File

@ -1,12 +0,0 @@
{ pkgs, ... }:
{
type = "app";
program = "${
(import ../modules/common/neovim/package {
inherit pkgs;
colors = (import ../colorscheme/nord).dark;
})
}/bin/nvim";
}

View File

@ -1,11 +0,0 @@
{ pkgs, ... }:
{
type = "app";
program = builtins.toString (
pkgs.writeShellScript "readme" ''
${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md}
''
);
}

View File

@ -1,17 +0,0 @@
{ pkgs, ... }:
{
type = "app";
program = builtins.toString (
pkgs.writeShellScript "rebuild" ''
echo ${pkgs.system}
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
if [ "$SYSTEM" == "darwin" ]; then
sudo darwin-rebuild switch --flake ${builtins.toString ../.}
else
doas nixos-rebuild switch --flake ${builtins.toString ../.}
fi
''
);
}

View File

@ -1,5 +0,0 @@
# Disks
These are my [disko](https://github.com/nix-community/disko) configurations,
which allow me to save desired disk formatting layouts as a declarative file so
I don't have to remember how to format my disks later on.

216
flake.lock generated
View File

@ -22,11 +22,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741229100, "lastModified": 1742013980,
"narHash": "sha256-0HwrTDXp9buEwal/1ymK9uQmzUD5ozIA7CJGqnT/gLs=", "narHash": "sha256-34YbfwABU5nb0F5eaaJE3ujldaNDhmyxw7CWqhXJV08=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "adf5c88ba1fe21af5c083b4d655004431f20c5ab", "rev": "9175b4bb5f127fb7b5784b14f7e01abff24c378f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -43,11 +43,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1740485968, "lastModified": 1741786315,
"narHash": "sha256-WK+PZHbfDjLyveXAxpnrfagiFgZWaTJglewBWniTn2Y=", "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "19c1140419c4f1cdf88ad4c1cfb6605597628940", "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -155,11 +155,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741378606, "lastModified": 1741955947,
"narHash": "sha256-ytDmwV93lZ1f6jswJkxEQz5cBlwje/2rH/yUZDADZNs=", "narHash": "sha256-2lbURKclgKqBNm7hVRtWh0A7NrdsibD0EaWhahUVhhY=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "95711f926676018d279ba09fe7530d03b5d5b3e2", "rev": "4e12151c9e014e2449e0beca2c0e9534b96a26b4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -304,11 +304,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1741246872, "lastModified": 1742069588,
"narHash": "sha256-Q6pMP4a9ed636qilcYX8XUguvKl/0/LGXhHcRI91p0U=", "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "10069ef4cf863633f57238f179a0297de84bd8d3", "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -334,6 +334,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": { "nur": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
@ -343,11 +359,11 @@
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1741383898, "lastModified": 1742145955,
"narHash": "sha256-hIiLfvj0qZjBLhk5eBhIv8SZJ+bI8d06Hxp480mJ1aI=", "narHash": "sha256-ju1J45e22ebpLH3eSm0ZZYg7WHkN01ryTFv+4UNwCOA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nur", "repo": "nur",
"rev": "54352c3c3110f34e71a2ae9a0210aa6955555760", "rev": "d6ba59dd58ebe6c184f955e1d3a4bbca9484c018",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -371,17 +387,29 @@
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable": "nixpkgs-stable",
"nur": "nur", "nur": "nur",
"tree-sitter-bash": "tree-sitter-bash",
"tree-sitter-ini": "tree-sitter-ini",
"tree-sitter-lua": "tree-sitter-lua",
"tree-sitter-puppet": "tree-sitter-puppet",
"tree-sitter-python": "tree-sitter-python",
"tree-sitter-rasi": "tree-sitter-rasi",
"tree-sitter-vimdoc": "tree-sitter-vimdoc",
"wsl": "wsl", "wsl": "wsl",
"zellij-switch": "zellij-switch",
"zenyd-mpv-scripts": "zenyd-mpv-scripts" "zenyd-mpv-scripts": "zenyd-mpv-scripts"
} }
}, },
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1736476219,
"narHash": "sha256-+qyv3QqdZCdZ3cSO/cbpEY6tntyYjfe1bB12mdpNFaY=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "de30cc5963da22e9742bbbbb9a3344570ed237b9",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": { "systems": {
"locked": { "locked": {
"lastModified": 1689347925, "lastModified": 1689347925,
@ -412,118 +440,18 @@
"type": "github" "type": "github"
} }
}, },
"tree-sitter-bash": { "systems_3": {
"flake": false,
"locked": { "locked": {
"lastModified": 1738310128, "lastModified": 1681028828,
"narHash": "sha256-ODWgFpCLLPgzNYXFhfAVvDXPr5bW8/49ezsaS9MOWMk=", "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "tree-sitter", "owner": "nix-systems",
"repo": "tree-sitter-bash", "repo": "default",
"rev": "0c46d792d54c536be5ff7eb18eb95c70fccdb232", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "tree-sitter", "owner": "nix-systems",
"ref": "master", "repo": "default",
"repo": "tree-sitter-bash",
"type": "github"
}
},
"tree-sitter-ini": {
"flake": false,
"locked": {
"lastModified": 1725233451,
"narHash": "sha256-G11Aynq2rnkRwdkhspjYqtBD/h5k4aD+NvuE0QfploU=",
"owner": "justinmk",
"repo": "tree-sitter-ini",
"rev": "962568c9efa71d25720ab42c5d36e222626ef3a6",
"type": "github"
},
"original": {
"owner": "justinmk",
"repo": "tree-sitter-ini",
"type": "github"
}
},
"tree-sitter-lua": {
"flake": false,
"locked": {
"lastModified": 1738303275,
"narHash": "sha256-mE84uI5AKbLvX5CM7NvA59Z8Ux+QFdqVjZf4hi06NAM=",
"owner": "MunifTanjim",
"repo": "tree-sitter-lua",
"rev": "68d29aa745b68ae22cbbdb5dcb68c20232521ff6",
"type": "github"
},
"original": {
"owner": "MunifTanjim",
"ref": "main",
"repo": "tree-sitter-lua",
"type": "github"
}
},
"tree-sitter-puppet": {
"flake": false,
"locked": {
"lastModified": 1734835631,
"narHash": "sha256-bO5g5AdhzpB13yHklpAndUHIX7Rvd7OMjH0Ds2ATA6Q=",
"owner": "amaanq",
"repo": "tree-sitter-puppet",
"rev": "15f192929b7d317f5914de2b4accd37b349182a6",
"type": "github"
},
"original": {
"owner": "amaanq",
"repo": "tree-sitter-puppet",
"type": "github"
}
},
"tree-sitter-python": {
"flake": false,
"locked": {
"lastModified": 1738275152,
"narHash": "sha256-t9etfZcrliF7f9hfiomh2U9P+3ufAm8iSK1y9rOhP7s=",
"owner": "tree-sitter",
"repo": "tree-sitter-python",
"rev": "710796b8b877a970297106e5bbc8e2afa47f86ec",
"type": "github"
},
"original": {
"owner": "tree-sitter",
"ref": "master",
"repo": "tree-sitter-python",
"type": "github"
}
},
"tree-sitter-rasi": {
"flake": false,
"locked": {
"lastModified": 1716296585,
"narHash": "sha256-sPrIVgGGaBaXeqHNxjcdJ/S2FvxyV6rD9UPKU/tpspw=",
"owner": "Fymyte",
"repo": "tree-sitter-rasi",
"rev": "6c9bbcfdf5f0f553d9ebc01750a3aa247a37b8aa",
"type": "github"
},
"original": {
"owner": "Fymyte",
"repo": "tree-sitter-rasi",
"type": "github"
}
},
"tree-sitter-vimdoc": {
"flake": false,
"locked": {
"lastModified": 1729686839,
"narHash": "sha256-Vrl4/cZL+TWlUMEeWZoHCAWhvlefcl3ajGcwyTNKOhI=",
"owner": "neovim",
"repo": "tree-sitter-vimdoc",
"rev": "d2e4b5c172a109966c2ce0378f73df6cede39400",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "tree-sitter-vimdoc",
"type": "github" "type": "github"
} }
}, },
@ -556,11 +484,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741192150, "lastModified": 1741870048,
"narHash": "sha256-wB140alXVla1Rw/kENerUoma2qO1Jy5IYWbmiSqmJu0=", "narHash": "sha256-odXRdNZGdXg1LmwlAeWL85kgy/FVHsgKlDwrvbR2BsU=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NixOS-WSL", "repo": "NixOS-WSL",
"rev": "0e4ccdb8181da2c6193c047b50ffee5f1a3b6dc1", "rev": "5d76001e33ee19644a598ad80e7318ab0957b122",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -569,6 +497,28 @@
"type": "github" "type": "github"
} }
}, },
"zellij-switch": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay",
"systems": "systems_3"
},
"locked": {
"lastModified": 1737011317,
"narHash": "sha256-A8VGuw/jIw+NCo5aCYy8MFrWpKzZLf77RApGGMzHxCY=",
"owner": "mostafaqanbaryan",
"repo": "zellij-switch",
"rev": "15b02834c8be735fca0d9fb41f48709f97cc9afc",
"type": "github"
},
"original": {
"owner": "mostafaqanbaryan",
"repo": "zellij-switch",
"type": "github"
}
},
"zenyd-mpv-scripts": { "zenyd-mpv-scripts": {
"flake": false, "flake": false,
"locked": { "locked": {

469
flake.nix
View File

@ -34,12 +34,6 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# # Use official Firefox binary for macOS
# firefox-darwin = {
# url = "github:bandithedoge/nixpkgs-firefox-darwin";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# Better App install management in macOS # Better App install management in macOS
mac-app-util = { mac-app-util = {
url = "github:hraban/mac-app-util"; url = "github:hraban/mac-app-util";
@ -52,12 +46,6 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# # Wallpapers
# wallpapers = {
# url = "gitlab:exorcist365/wallpapers";
# flake = false;
# };
# Used to generate NixOS images for other platforms # Used to generate NixOS images for other platforms
nixos-generators = { nixos-generators = {
url = "github:nix-community/nixos-generators"; url = "github:nix-community/nixos-generators";
@ -70,117 +58,17 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# # Neovim plugins
# base16-nvim-src = {
# url = "github:RRethy/base16-nvim";
# flake = false;
# };
# nvim-lspconfig-src = {
# # https://github.com/neovim/nvim-lspconfig/tags
# url = "github:neovim/nvim-lspconfig/v0.1.8";
# flake = false;
# };
# cmp-nvim-lsp-src = {
# url = "github:hrsh7th/cmp-nvim-lsp";
# flake = false;
# };
# baleia-nvim-src = {
# # https://github.com/m00qek/baleia.nvim/tags
# url = "github:m00qek/baleia.nvim";
# flake = false;
# };
# nvim-treesitter-src = {
# # https://github.com/nvim-treesitter/nvim-treesitter/tags
# url = "github:nvim-treesitter/nvim-treesitter/v0.9.2";
# flake = false;
# };
# telescope-nvim-src = {
# # https://github.com/nvim-telescope/telescope.nvim/releases
# url = "github:nvim-telescope/telescope.nvim/0.1.8";
# flake = false;
# };
# telescope-project-nvim-src = {
# url = "github:nvim-telescope/telescope-project.nvim";
# flake = false;
# };
# toggleterm-nvim-src = {
# # https://github.com/akinsho/toggleterm.nvim/tags
# url = "github:akinsho/toggleterm.nvim/v2.12.0";
# flake = false;
# };
# bufferline-nvim-src = {
# # https://github.com/akinsho/bufferline.nvim/releases
# url = "github:akinsho/bufferline.nvim/v4.6.1";
# flake = false;
# };
# nvim-tree-lua-src = {
# url = "github:kyazdani42/nvim-tree.lua";
# flake = false;
# };
# hmts-nvim-src = {
# url = "github:calops/hmts.nvim";
# flake = false;
# };
# fidget-nvim-src = {
# # https://github.com/j-hui/fidget.nvim/tags
# url = "github:j-hui/fidget.nvim/v1.4.5";
# flake = false;
# };
# nvim-lint-src = {
# url = "github:mfussenegger/nvim-lint";
# flake = false;
# };
# tiny-inline-diagnostic-nvim-src = {
# url = "github:rachartier/tiny-inline-diagnostic.nvim";
# flake = false;
# };
# snipe-nvim-src = {
# url = "github:leath-dub/snipe.nvim";
# flake = false;
# };
# Tree-Sitter Grammars
tree-sitter-bash = {
url = "github:tree-sitter/tree-sitter-bash/master";
flake = false;
};
tree-sitter-python = {
url = "github:tree-sitter/tree-sitter-python/master";
flake = false;
};
tree-sitter-lua = {
url = "github:MunifTanjim/tree-sitter-lua/main";
flake = false;
};
tree-sitter-ini = {
url = "github:justinmk/tree-sitter-ini";
flake = false;
};
tree-sitter-puppet = {
url = "github:amaanq/tree-sitter-puppet";
flake = false;
};
tree-sitter-rasi = {
url = "github:Fymyte/tree-sitter-rasi";
flake = false;
};
tree-sitter-vimdoc = {
url = "github:neovim/tree-sitter-vimdoc";
flake = false;
};
# MPV Scripts # MPV Scripts
zenyd-mpv-scripts = { zenyd-mpv-scripts = {
url = "github:zenyd/mpv-scripts"; url = "github:zenyd/mpv-scripts";
flake = false; flake = false;
}; };
# # Git alternative # Zellij Switcher
# # Fixes: https://github.com/martinvonz/jj/issues/4784 zellij-switch = {
# jujutsu = { url = "github:mostafaqanbaryan/zellij-switch";
# url = "github:martinvonz/jj"; inputs.nixpkgs.follows = "nixpkgs";
# inputs.nixpkgs.follows = "nixpkgs"; };
# };
# Nextcloud Apps # Nextcloud Apps
nextcloud-news = { nextcloud-news = {
@ -211,276 +99,128 @@
{ nixpkgs, ... }@inputs: { nixpkgs, ... }@inputs:
let let
hostnames =
# Global configuration for my systems
globals =
let let
baseName = "masu.rs"; baseName = "masu.rs";
in in
rec { {
user = "noah"; audiobooks = "read.${baseName}";
fullName = "Noah Masur"; books = "books.${baseName}";
gitName = fullName; budget = "money.${baseName}";
gitEmail = "7386960+nmasur@users.noreply.github.com"; content = "cloud.${baseName}";
mail.server = "noahmasur.com"; download = "download.${baseName}";
mail.imapHost = "imap.purelymail.com"; files = "files.${baseName}";
mail.smtpHost = "smtp.purelymail.com"; git = "git.${baseName}";
dotfilesRepo = "https://github.com/nmasur/dotfiles"; imap = "imap.purelymail.com";
hostnames = { influxdb = "influxdb.${baseName}";
audiobooks = "read.${baseName}"; irc = "irc.${baseName}";
books = "books.${baseName}"; mail = "noahmasur.com";
budget = "money.${baseName}"; metrics = "metrics.${baseName}";
content = "cloud.${baseName}"; minecraft = "minecraft.${baseName}";
download = "download.${baseName}"; n8n = "n8n.${baseName}";
files = "files.${baseName}"; notifications = "ntfy.${baseName}";
git = "git.${baseName}"; paperless = "paper.${baseName}";
imap = "imap.purelymail.com"; photos = "photos.${baseName}";
influxdb = "influxdb.${baseName}"; prometheus = "prom.${baseName}";
irc = "irc.${baseName}"; secrets = "vault.${baseName}";
mail = "noahmasur.com"; smtp = "smtp.purelymail.com";
metrics = "metrics.${baseName}"; status = "status.${baseName}";
minecraft = "minecraft.${baseName}"; stream = "stream.${baseName}";
n8n = "n8n.${baseName}"; transmission = "transmission.${baseName}";
notifications = "ntfy.${baseName}";
paperless = "paper.${baseName}";
photos = "photos.${baseName}";
prometheus = "prom.${baseName}";
secrets = "vault.${baseName}";
smtp = "smtp.purelymail.com";
status = "status.${baseName}";
stream = "stream.${baseName}";
transmission = "transmission.${baseName}";
};
}; };
# Common overlays to always use
overlays = [
inputs.nur.overlays.default
inputs.nix2vim.overlay
# inputs.jujutsu.overlays.default # Fix: https://github.com/martinvonz/jj/issues/4784
# (import ./overlays/neovim-plugins.nix inputs)
# (import ./overlays/tree-sitter.nix inputs)
# (import ./overlays/mpv-scripts.nix inputs)
# (import ./overlays/nextcloud-apps.nix inputs)
# (import ./overlays/pkgs.nix)
] ++ (import ./overlays inputs);
# System types to support.
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# { system -> pkgs }
pkgsBySystem = forAllSystems (
system:
import nixpkgs {
inherit system overlays;
config.permittedInsecurePackages = [ "litestream-0.3.13" ];
config.allowUnfree = true;
}
);
# stablePkgsBySystem = forAllSystems (system: import nixpkgs { inherit system overlays; });
buildHome =
{ pkgs, modules }:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = modules ++ [
./platforms/home-manager
];
};
buildNixos =
{ pkgs, modules }:
nixpkgs.lib.nixosSystem {
inherit pkgs;
modules = modules ++ [
inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko
inputs.wsl.nixosModules.wsl
./platforms/nixos
{
home-manager.extraSpecialArgs = {
hostnames = globals.hostnames;
};
}
];
specialArgs = {
hostnames = globals.hostnames;
};
};
buildDarwin =
{ pkgs, modules }:
inputs.darwin.lib.darwinSystem {
inherit pkgs;
modules = modules ++ [
inputs.home-manager.darwinModules.home-manager
inputs.mac-app-util.darwinModules.default
./platforms/nix-darwin
];
};
x86_64-linux-hosts = (import ./hosts-by-platform nixpkgs).x86_64-linux-hosts;
aarch64-linux-hosts = (import ./hosts-by-platform nixpkgs).aarch64-linux-hosts;
aarch64-darwin-hosts = (import ./hosts-by-platform nixpkgs).aarch64-darwin-hosts;
in in
rec { rec {
# The plan lib = import ./lib inputs;
# Import all the host configurations as modules
# Setup the modules as nixosModules, homeModules, darwinModules
# Create nixosConfigurations using the different pkgs for each system
# What to do with home config?
nixosModules = x86_64-linux-hosts // aarch64-linux-hosts; nixosConfigurations = builtins.mapAttrs (
darwinModules = aarch64-darwin-hosts; system: hosts:
builtins.mapAttrs (
inherit buildDarwin pkgsBySystem;
# Contains my full system builds, including home-manager
# nixos-rebuild switch --flake .#tempest
nixosConfigurations =
(builtins.mapAttrs (
name: module: name: module:
buildNixos { lib.buildNixos {
pkgs = pkgsBySystem.x86_64-linux; inherit system module;
modules = [ module ]; specialArgs = { inherit hostnames; };
} }
) x86_64-linux-hosts) ) hosts
// (builtins.mapAttrs ( ) lib.linuxHosts;
name: module:
buildNixos {
pkgs = pkgsBySystem.aarch64-linux;
modules = [ module ];
}
) aarch64-linux-hosts);
# Contains my full Mac system builds, including home-manager
# darwin-rebuild switch --flake .#lookingglass
darwinConfigurations = builtins.mapAttrs ( darwinConfigurations = builtins.mapAttrs (
name: module: system: hosts:
buildDarwin { builtins.mapAttrs (
pkgs = pkgsBySystem.aarch64-darwin; name: module:
modules = [ module ]; lib.buildDarwin {
} inherit system module;
) aarch64-darwin-hosts; specialArgs = { inherit hostnames; };
}
) hosts
) lib.darwinHosts;
homeModules = builtins.mapAttrs (
system: hosts:
builtins.mapAttrs (
name: module: (builtins.head (lib.attrsToList module.home-manager.users)).value
) hosts
) lib.hosts;
# For quickly applying home-manager settings with:
# home-manager switch --flake .#tempest
homeConfigurations = builtins.mapAttrs ( homeConfigurations = builtins.mapAttrs (
name: module: system: hosts:
buildHome { builtins.mapAttrs (
pkgs = pkgsBySystem.x86_64-linux; name: module:
module = [ module ]; lib.buildHome {
} inherit system module;
) nixosModules; specialArgs = { inherit hostnames; };
}
) hosts
) homeModules;
# Disk formatting, only used once # Disk formatting, only used once
diskoConfigurations = { diskoConfigurations = {
root = import ./disks/root.nix; root = import ./hosts/x86_64-linux/swan/root.nix;
}; };
# packages = generators = builtins.mapAttrs (
# let system: hosts:
# staff = builtins.mapAttrs (name: module: {
# system: aws = lib.generateImage {
# import ./hosts/staff { inherit system module;
# inherit format = "amazon";
# inputs specialArgs = { inherit hostnames; };
# globals
# overlays
# system
# ;
# };
# neovim =
# system:
# let
# pkgs = import nixpkgs { inherit system overlays; };
# in
# import ./modules/common/neovim/package {
# inherit pkgs;
# colors = (import ./colorscheme/gruvbox-dark).dark;
# };
# in
# {
# x86_64-linux.staff = staff "x86_64-linux";
# x86_64-linux.arrow = inputs.nixos-generators.nixosGenerate rec {
# system = "x86_64-linux";
# format = "iso";
# modules = import ./hosts/arrow/modules.nix { inherit inputs globals overlays; };
# };
# x86_64-linux.arrow-aws = inputs.nixos-generators.nixosGenerate rec {
# system = "x86_64-linux";
# format = "amazon";
# modules = import ./hosts/arrow/modules.nix { inherit inputs globals overlays; } ++ [
# (
# { ... }:
# {
# boot.kernelPackages = inputs.nixpkgs.legacyPackages.x86_64-linux.linuxKernel.packages.linux_6_6;
# amazonImage.sizeMB = 16 * 1024;
# permitRootLogin = "prohibit-password";
# boot.loader.systemd-boot.enable = inputs.nixpkgs.lib.mkForce false;
# boot.loader.efi.canTouchEfiVariables = inputs.nixpkgs.lib.mkForce false;
# services.amazon-ssm-agent.enable = true;
# users.users.ssm-user.extraGroups = [ "wheel" ];
# }
# )
# ];
# };
# # Package Neovim config into standalone package
# x86_64-linux.neovim = neovim "x86_64-linux";
# x86_64-darwin.neovim = neovim "x86_64-darwin";
# aarch64-linux.neovim = neovim "aarch64-linux";
# aarch64-darwin.neovim = neovim "aarch64-darwin";
# };
mypackages = forAllSystems (system: pkgsBySystem.${system}.nmasur);
packages = mypackages;
# # Programs that can be run by calling this flake
# apps = forAllSystems (
# system:
# let
# pkgs = import nixpkgs { inherit system overlays; };
# in
# import ./apps { inherit pkgs; }
# );
# Development environments
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system overlays; };
in
{
# Used to run commands and edit files in this repo
default = pkgs.mkShell {
buildInputs = with pkgs; [
git
stylua
nixfmt-rfc-style
shfmt
shellcheck
];
}; };
iso = lib.generateImage {
inherit system module;
format = "iso";
specialArgs = { inherit hostnames; };
};
}) hosts
) lib.linuxHosts;
packages = lib.forAllSystems (
system:
# Get the configurations that we normally use
{
nixosConfigurations = nixosConfigurations.${system};
darwinConfigurations = darwinConfigurations.${system};
homeConfigurations = homeConfigurations.${system};
generators = generators.${system};
} }
//
# Get the custom packages that I have placed under the nmasur namespace
lib.pkgsBySystem.${system}.nmasur
); );
checks = forAllSystems ( # Development environments
devShells = lib.forAllSystems (system: {
default = lib.pkgsBySystem.${system}.nmasur.dotfiles-devshell;
});
checks = lib.forAllSystems (
system: system:
let let
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs {
inherit system;
overlays = lib.overlays;
};
in in
{ {
neovim = neovim =
@ -499,10 +239,13 @@
} }
); );
formatter = forAllSystems ( formatter = lib.forAllSystems (
system: system:
let let
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs {
inherit system;
inherit (lib) overlays;
};
in in
pkgs.nixfmt-rfc-style pkgs.nixfmt-rfc-style
); );

View File

@ -1,22 +0,0 @@
# Return a list of all NixOS hosts
{ nixpkgs, ... }:
let
inherit (nixpkgs) lib;
in
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix "default.nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
# Import each host function
map
(file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
})
# Convert to an attrset of hostname -> host function
(builtins.listToAttrs)
]

View File

@ -1,18 +0,0 @@
# Return a list of all nix-darwin hosts
{ lib, ... }:
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix "default.nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
# Import each host function
map
(file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
})
# Convert to an attrset of hostname -> host function
(builtins.listToAttrs)
]

View File

@ -1,22 +0,0 @@
# Return a list of all NixOS hosts
{ nixpkgs, ... }:
let
inherit (nixpkgs) lib;
in
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix "default.nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
# Import each host function
map
(file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
})
# Convert to an attrset of hostname -> host function
(builtins.listToAttrs)
]

View File

@ -1,41 +0,0 @@
# The Arrow
# System configuration for temporary VM
{
inputs,
globals,
overlays,
...
}:
inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
pkgs-caddy = import inputs.nixpkgs-caddy { inherit system; };
};
modules = import ./modules.nix { inherit inputs globals overlays; } ++ [
{
# This is the root filesystem containing NixOS
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
# This is the boot filesystem for Grub
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
virtualisation.vmVariant = {
virtualisation.forwardPorts = [
{
from = "host";
host.port = 2222;
guest.port = 22;
}
];
};
}
];
}

View File

@ -1,32 +0,0 @@
{
inputs,
globals,
overlays,
}:
[
globals
inputs.home-manager.nixosModules.home-manager
{
nixpkgs.overlays = overlays;
networking.hostName = "arrow";
physical = false;
server = true;
gui.enable = false;
theme.colors = (import ../../colorscheme/gruvbox).dark;
publicKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s personal"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKpPU2G9rSF8Q6waH62IJexDCQ6lY+8ZyVufGE3xMDGw deploy"
];
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
cloudflare.enable = true;
services.openssh.enable = true;
services.caddy.enable = true;
services.n8n.enable = true;
# nix-index seems to eat up too much memory for Vultr
home-manager.users.${globals.user}.programs.nix-index.enable = inputs.nixpkgs.lib.mkForce false;
}
../../modules/common
../../modules/nixos
]

View File

@ -1,22 +0,0 @@
# Return a list of all NixOS hosts
{ nixpkgs, ... }:
let
inherit (nixpkgs) lib;
in
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix "default.nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
# Import each host function
map
(file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
})
# Convert to an attrset of hostname -> host function
(builtins.listToAttrs)
]

View File

@ -1,51 +0,0 @@
# The Hydra
# System configuration for WSL
# See [readme](../README.md) to explain how this file works.
{
inputs,
globals,
overlays,
...
}:
inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { };
modules = [
../../modules/common
../../modules/nixos
../../modules/wsl
globals
inputs.wsl.nixosModules.wsl
inputs.home-manager.nixosModules.home-manager
{
networking.hostName = "hydra";
nixpkgs.overlays = overlays;
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = false;
theme = {
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
passwordHash = inputs.nixpkgs.lib.fileContents ../../misc/password.sha512;
wsl = {
enable = true;
wslConf.automount.root = "/mnt";
defaultUser = globals.user;
startMenuLaunchers = true;
nativeSystemd = true;
wslConf.network.generateResolvConf = true; # Turn off if it breaks VPN
interop.includePath = false; # Including Windows PATH will slow down Neovim command mode
};
neovim.enable = true;
mail.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
dotfiles.enable = true;
lua.enable = true;
}
];
}

View File

@ -1,53 +0,0 @@
# The Staff
# ISO configuration for my USB drive
{
inputs,
system,
overlays,
...
}:
inputs.nixos-generators.nixosGenerate {
inherit system;
format = "install-iso";
modules = [
{
nixpkgs.overlays = overlays;
networking.hostName = "staff";
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s"
];
services.openssh = {
enable = true;
ports = [ 22 ];
allowSFTP = true;
settings = {
GatewayPorts = "no";
X11Forwarding = false;
PasswordAuthentication = false;
PermitRootLogin = "yes";
};
};
environment.systemPackages =
let
pkgs = import inputs.nixpkgs { inherit system overlays; };
in
with pkgs;
[
git
vim
wget
curl
(import ../../modules/common/neovim/package {
inherit pkgs;
colors = (import ../../colorscheme/gruvbox).dark;
})
];
nix.extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
}
];
}

View File

@ -29,9 +29,12 @@ rec {
work.enable = true; work.enable = true;
experimental.enable = true; experimental.enable = true;
}; };
nmasur.presets.programs.git = { nmasur.presets.programs.git-work.work = {
name = "Noah-Masur_1701"; name = "Noah-Masur_1701";
email = "${nmasur.settings.username}@take2games.com"; email = "${nmasur.settings.username}@take2games.com";
}; };
home.stateVersion = "23.05";
}; };
system.stateVersion = 5;
} }

View File

@ -52,7 +52,7 @@ rec {
nmasur.presets.services.cloudflared = { nmasur.presets.services.cloudflared = {
tunnel = { tunnel = {
id = "bd250ee1-ed2e-42d2-b627-039f1eb5a4d2"; id = "bd250ee1-ed2e-42d2-b627-039f1eb5a4d2";
credentialsFile = ../../../private/cloudflared-flame.age; credentialsFile = ./cloudflared-flame.age;
ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK/6oyVqjFGX3Uvrc3VS8J9sphxzAnRzKC85xgkHfYgR3TK6qBGXzHrknEj21xeZrr3G2y1UsGzphWJd9ZfIcdA= open-ssh-ca@cloudflareaccess.org"; ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK/6oyVqjFGX3Uvrc3VS8J9sphxzAnRzKC85xgkHfYgR3TK6qBGXzHrknEj21xeZrr3G2y1UsGzphWJd9ZfIcdA= open-ssh-ca@cloudflareaccess.org";
}; };
}; };

View File

@ -34,10 +34,11 @@ in
]; ];
x86_64-linux-hosts = lib.pipe (lib.filesystem.listFilesRecursive ./x86_64-linux) [ x86_64-linux-hosts = lib.pipe (lib.filesystem.listFilesRecursive ./x86_64-linux) [
# Get only files ending in default.nix # Get only files ending in default.nix
(builtins.filter (name: lib.hasSuffix ".nix" name)) (builtins.filter (name: lib.hasSuffix "default.nix" name))
# Import each host function # Import each host function
(map (file: { (map (file: {
name = lib.removeSuffix ".nix" (builtins.baseNameOf file); # name = lib.removeSuffix ".nix" (builtins.baseNameOf file);
name = builtins.baseNameOf (builtins.dirOf file);
value = import file; value = import file;
})) }))
# Convert to an attrset of hostname -> host function # Convert to an attrset of hostname -> host function

View File

@ -0,0 +1,32 @@
# The Arrow
# System configuration for temporary VM
rec {
# Hardware
networking.hostName = "arrow";
nmasur.settings = {
username = "noah";
fullName = "Noah Masur";
};
nmasur.profiles = {
base.enable = true;
server.enable = true;
};
home-manager.users."noah" = {
nmasur.settings = {
username = nmasur.settings.username;
fullName = nmasur.settings.fullName;
};
nmasur.profiles = {
common.enable = true;
linux-base.enable = true;
};
home.stateVersion = "23.05";
};
system.stateVersion = "23.05";
}

View File

@ -0,0 +1,33 @@
# The Hydra
# System configuration for WSL
rec {
# Hardware
networking.hostName = "hydra";
nmasur.settings = {
username = "noah";
fullName = "Noah Masur";
};
nmasur.profiles = {
base.enable = true;
wsl.enable = true;
};
home-manager.users."noah" = {
nmasur.settings = {
username = nmasur.settings.username;
fullName = nmasur.settings.fullName;
};
nmasur.profiles = {
common.enable = true;
linux-base.enable = true;
power-user.enable = true;
};
home.stateVersion = "23.05";
};
system.stateVersion = "23.05";
}

View File

@ -7,21 +7,6 @@ rec {
nmasur.settings = { nmasur.settings = {
username = "noah"; username = "noah";
fullName = "Noah Masur"; fullName = "Noah Masur";
# hostnames =
# let
# baseName = "masu.rs";
# in
# {
# audiobooks = "read.${baseName}";
# books = "books.${baseName}";
# content = "cloud.${baseName}";
# download = "download.${baseName}";
# files = "files.${baseName}";
# paperless = "paper.${baseName}";
# photos = "photos.${baseName}";
# prometheus = "prom.${baseName}";
# stream = "stream.${baseName}";
# };
}; };
nmasur.profiles = { nmasur.profiles = {
@ -29,6 +14,7 @@ rec {
server.enable = true; server.enable = true;
home.enable = true; home.enable = true;
nas.enable = true; nas.enable = true;
shared-media.enable = true;
}; };
home-manager.users."noah" = { home-manager.users."noah" = {
@ -39,10 +25,13 @@ rec {
nmasur.profiles = { nmasur.profiles = {
common.enable = true; common.enable = true;
linux-base.enable = true; linux-base.enable = true;
power-user.enable = true;
}; };
home.stateVersion = "23.05"; home.stateVersion = "23.05";
}; };
system.stateVersion = "23.05";
# Not sure what's necessary but too afraid to remove anything # Not sure what's necessary but too afraid to remove anything
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [
"xhci_pci" "xhci_pci"
@ -78,14 +67,14 @@ rec {
# Sets root ext4 filesystem instead of declaring it manually # Sets root ext4 filesystem instead of declaring it manually
disko = { disko = {
enableConfig = true; enableConfig = true;
devices = (import ../../../disks/root.nix { disk = "/dev/nvme0n1"; }); devices = (import ./root.nix { disk = "/dev/nvme0n1"; });
}; };
# Allows private remote access over the internet # Allows private remote access over the internet
nmasur.presets.services.cloudflared = { nmasur.presets.services.cloudflared = {
tunnel = { tunnel = {
id = "646754ac-2149-4a58-b51a-e1d0a1f3ade2"; id = "646754ac-2149-4a58-b51a-e1d0a1f3ade2";
credentialsFile = ../../private/cloudflared-swan.age; credentialsFile = ./cloudflared-swan.age;
ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCHF/UMtJqPFrf6f6GRY0ZFnkCW7b6sYgUTjTtNfRj1RdmNic1NoJZql7y6BrqQinZvy7nsr1UFDNWoHn6ah3tg= open-ssh-ca@cloudflareaccess.org"; ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCHF/UMtJqPFrf6f6GRY0ZFnkCW7b6sYgUTjTtNfRj1RdmNic1NoJZql7y6BrqQinZvy7nsr1UFDNWoHn6ah3tg= open-ssh-ca@cloudflareaccess.org";
}; };
}; };

View File

@ -17,6 +17,8 @@ rec {
gaming.enable = true; gaming.enable = true;
}; };
nmasur.presets.services.grub.enable = true;
home-manager.users."noah" = { home-manager.users."noah" = {
nmasur.settings = { nmasur.settings = {
username = nmasur.settings.username; username = nmasur.settings.username;
@ -31,14 +33,11 @@ rec {
developer.enable = true; developer.enable = true;
experimental.enable = true; experimental.enable = true;
}; };
nmasur.presets.services.mbsync = {
user = nmasur.settings.username;
server = "noahmasur.com";
};
home.stateVersion = "23.05"; home.stateVersion = "23.05";
}; };
system.stateVersion = "23.05"; system.stateVersion = "23.05";
# Not sure what's necessary but too afraid to remove anything # Not sure what's necessary but too afraid to remove anything
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [
"nvme" "nvme"
@ -98,7 +97,7 @@ rec {
nmasur.presets.services.cloudflared = { nmasur.presets.services.cloudflared = {
tunnel = { tunnel = {
id = "ac133a82-31fb-480c-942a-cdbcd4c58173"; id = "ac133a82-31fb-480c-942a-cdbcd4c58173";
credentialsFile = ../../../private/cloudflared-tempest.age; credentialsFile = ./cloudflared-tempest.age;
ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPY6C0HmdFCaxYtJxFr3qV4/1X4Q8KrYQ1hlme3u1hJXK+xW+lc9Y9glWHrhiTKilB7carYTB80US0O47gI5yU4= open-ssh-ca@cloudflareaccess.org"; ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPY6C0HmdFCaxYtJxFr3qV4/1X4Q8KrYQ1hlme3u1hJXK+xW+lc9Y9glWHrhiTKilB7carYTB80US0O47gI5yU4= open-ssh-ca@cloudflareaccess.org";
}; };
}; };

223
lib/default.nix Normal file
View File

@ -0,0 +1,223 @@
inputs:
let
lib = inputs.nixpkgs.lib;
in
lib
// rec {
# Returns all files in a directory matching a suffix
filesInDirectoryWithSuffix =
directory: suffix:
lib.pipe (lib.filesystem.listFilesRecursive directory) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix suffix name))
];
# Returns all files ending in .nix for a directory
nixFiles = directory: filesInDirectoryWithSuffix directory ".nix";
# Returns all files ending in default.nix for a directory
defaultFiles = directory: filesInDirectoryWithSuffix directory "default.nix";
# Imports all files in a directory and passes inputs
importOverlays =
directory:
lib.pipe (nixFiles directory) [
# Import each overlay file
(map (file: (import file) inputs))
];
# Import default files as attrset with keys provided by parent directory
defaultFilesToAttrset =
directory:
lib.pipe (defaultFiles directory) [
# Import each file
(map (file: {
name = builtins.baseNameOf (builtins.dirOf file);
value = import file;
}))
# Convert to an attrset of parent dir name -> file
(builtins.listToAttrs)
];
# [ package1/package.nix package2/package.nix package2/hello.sh ]
buildPkgsFromDirectoryAndPkgs =
directory: pkgs:
lib.pipe (filesInDirectoryWithSuffix directory "package.nix") [
# Apply callPackage to create a derivation
# Must use final.callPackage to avoid infinite recursion
# [ package1.drv package2.drv ]
(builtins.map (name: pkgs.callPackage name { }))
# Convert the list to an attrset with keys from pname or name attr
# { package1 = package1.drv, package2 = package2.drv }
(builtins.listToAttrs (
map (v: {
name = v."pname" or v."name";
value = v;
})
))
];
# Common overlays to always use
overlays = [
inputs.nur.overlays.default
inputs.nix2vim.overlay
inputs.zellij-switch.overlays.default
] ++ (importOverlays ../overlays);
# System types to support.
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
# Split system types by operating system
linuxSystems = builtins.filter (lib.hasSuffix "linux") supportedSystems;
darwinSystems = builtins.filter (lib.hasSuffix "darwin") supportedSystems;
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forSystems = systems: lib.genAttrs systems;
forAllSystems = lib.genAttrs supportedSystems;
# { x86_64-linux = { tempest = { settings = ...; }; }; };
hosts = forAllSystems (system: defaultFilesToAttrset ../hosts/${system});
linuxHosts = lib.filterAttrs (name: value: builtins.elem name linuxSystems) hosts;
darwinHosts = lib.filterAttrs (name: value: builtins.elem name darwinSystems) hosts;
# { system -> pkgs }
pkgsBySystem = forAllSystems (
system:
import inputs.nixpkgs {
inherit system overlays;
config.permittedInsecurePackages = [ "litestream-0.3.13" ];
config.allowUnfree = true;
}
);
colorscheme = defaultFilesToAttrset ../colorscheme;
homeModule = {
home-manager = {
# Include home-manager config in NixOS
sharedModules = nixFiles ../platforms/home-manager;
# Use the system-level nixpkgs instead of Home Manager's
useGlobalPkgs = lib.mkDefault true;
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
# using multiple profiles for one user
useUserPackages = lib.mkDefault true;
};
};
buildHome =
{
system,
module,
specialArgs,
}:
inputs.home-manager.lib.homeManagerConfiguration {
pkgs = pkgsBySystem.${system};
modules = [
{ imports = (nixFiles ../platforms/home-manager); }
module
];
extraSpecialArgs = {
inherit colorscheme;
} // specialArgs;
};
buildNixos =
{
system,
module,
specialArgs,
}:
inputs.nixpkgs.lib.nixosSystem {
inherit specialArgs;
pkgs = pkgsBySystem.${system};
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko
inputs.wsl.nixosModules.wsl
{ imports = (nixFiles ../platforms/nixos); }
module
{
home-manager = {
extraSpecialArgs = {
inherit colorscheme;
} // specialArgs;
} // homeModule.home-manager;
}
];
};
buildDarwin =
{
system,
module,
specialArgs,
}:
inputs.darwin.lib.darwinSystem {
inherit system specialArgs;
modules = [
inputs.home-manager.darwinModules.home-manager
inputs.mac-app-util.darwinModules.default
{
imports = (nixFiles ../platforms/nix-darwin);
nixpkgs.pkgs = pkgsBySystem.${system};
}
module
{
home-manager = {
extraSpecialArgs = {
inherit colorscheme;
} // specialArgs;
} // homeModule.home-manager;
}
];
};
generatorOptions = {
amazon = {
aws.enable = true;
};
iso = { };
};
generateImage =
{
system,
module,
format,
specialArgs,
}:
inputs.nixos-generators.nixosGenerate {
inherit system format;
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko
inputs.wsl.nixosModules.wsl
{
imports = (nixFiles ../platforms/nixos) ++ (nixFiles ../platforms/generators);
}
generatorOptions.${format}
module
{
home-manager = {
extraSpecialArgs = {
inherit colorscheme;
} // specialArgs;
} // homeModule.home-manager;
}
];
specialArgs = {
} // specialArgs;
};
}

View File

@ -1,9 +0,0 @@
# Modules
| Module | Purpose |
| --- | --- |
| [common](./common/default.nix) | User programs and OS-agnostic configuration |
| [darwin](./darwin/default.nix) | macOS-specific configuration |
| [nixos](./nixos/default.nix) | NixOS-specific configuration |
| [wsl](./wsl/default.nix) | WSL-specific configuration |

View File

@ -1,167 +0,0 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [
./applications
./mail
./neovim
./programming
./repositories
./shell
];
options = {
# user = lib.mkOption {
# type = lib.types.str;
# description = "Primary user of the system";
# };
# fullName = lib.mkOption {
# type = lib.types.str;
# description = "Human readable name of the user";
# };
# userDirs = {
# # Required to prevent infinite recursion when referenced by himalaya
# download = lib.mkOption {
# type = lib.types.str;
# description = "XDG directory for downloads";
# default = if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
# };
# };
# identityFile = lib.mkOption {
# type = lib.types.str;
# description = "Path to existing private key file.";
# default = "/etc/ssh/ssh_host_ed25519_key";
# };
# homePath = lib.mkOption {
# type = lib.types.path;
# description = "Path of user's home directory.";
# default = builtins.toPath (
# if pkgs.stdenv.isDarwin then "/Users/${config.user}" else "/home/${config.user}"
# );
# };
# dotfilesPath = lib.mkOption {
# type = lib.types.path;
# description = "Path of dotfiles repository.";
# default = config.homePath + "/dev/personal/dotfiles";
# };
# dotfilesRepo = lib.mkOption {
# type = lib.types.str;
# description = "Link to dotfiles repository HTTPS URL.";
# };
# unfreePackages = lib.mkOption {
# type = lib.types.listOf lib.types.str;
# description = "List of unfree packages to allow.";
# default = [ ];
# };
# insecurePackages = lib.mkOption {
# type = lib.types.listOf lib.types.str;
# description = "List of insecure packages to allow.";
# default = [ ];
# };
# hostnames = {
# audiobooks = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for audiobook server (Audiobookshelf).";
# };
# budget = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for budgeting server (ActualBudget).";
# };
# files = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for files server (Filebrowser).";
# };
# git = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for git server (Gitea).";
# };
# metrics = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for metrics server.";
# };
# minecraft = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for Minecraft server.";
# };
# paperless = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for document server (paperless-ngx).";
# };
# photos = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for photo management (Immich).";
# };
# prometheus = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for Prometheus server.";
# };
# influxdb = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for InfluxDB2 server.";
# };
# secrets = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for passwords and secrets (Vaultwarden).";
# };
# stream = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for video/media library (Jellyfin).";
# };
# content = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for personal content system (Nextcloud).";
# };
# books = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for books library (Calibre-Web).";
# };
# download = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for download services.";
# };
# irc = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for IRC services.";
# };
# n8n = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for n8n automation.";
# };
# notifications = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for push notification services (ntfy).";
# };
# status = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for status page (Uptime-Kuma).";
# };
# transmission = lib.mkOption {
# type = lib.types.str;
# description = "Hostname for peer2peer downloads (Transmission).";
# };
# };
};
config =
let
stateVersion = "23.05";
in
{
# Allow specified unfree packages (identified elsewhere)
# Retrieves package object based on string name
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.unfreePackages;
# Allow specified insecure packages (identified elsewhere)
nixpkgs.config.permittedInsecurePackages = config.insecurePackages;
# Pin a state version to prevent warnings
home-manager.users.${config.user}.home.stateVersion = stateVersion;
home-manager.users.root.home.stateVersion = stateVersion;
};
}

View File

@ -1,29 +0,0 @@
inputs: _final: prev: {
# Based on:
# https://git.sr.ht/~rycee/nur-expressions/tree/master/item/pkgs/firefox-addons/default.nix#L34
bypass-paywalls-clean =
let
addonId = "magnolia@12.34";
in
prev.stdenv.mkDerivation rec {
pname = "bypass-paywalls-clean";
version = "4.0.6.0";
src = builtins.fetchGit {
url = "https://gitflic.ru/project/magnolia1234/bpc_uploads.git";
# owner = "magnolia1234";
# repo = "bpc_uploads";
ref = "main";
rev = "a3012f84bad9719760150832803f2ea07af8dae3";
# sha256 = "0000000000000000000000000000000000000000000000000000";
};
preferLocalBuild = true;
allowSubstitutes = true;
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "${src}" "$dst/${addonId}.xpi"
'';
};
}

View File

@ -1,16 +0,0 @@
# Return a list of all overlays
inputs:
let
lib = inputs.nixpkgs.lib;
in
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
# Import each overlay file
(map (file: (import file) inputs))
]

View File

@ -1,43 +0,0 @@
inputs: _final: prev: {
tree-sitter-grammars = prev.tree-sitter-grammars // {
# Fix: bash highlighting doesn't work as of this commit:
# https://github.com/NixOS/nixpkgs/commit/49cce41b7c5f6b88570a482355d9655ca19c1029
tree-sitter-bash = prev.tree-sitter-grammars.tree-sitter-bash.overrideAttrs (old: {
src = inputs.tree-sitter-bash;
});
# Fix: invalid node in position. Broken as of this commit (replaced with newer):
# https://github.com/NixOS/nixpkgs/commit/8ec3627796ecc899e6f47f5bf3c3220856ead9c5
tree-sitter-python = prev.tree-sitter-grammars.tree-sitter-python.overrideAttrs (old: {
src = inputs.tree-sitter-python;
});
# Fix: invalid structure in position.
tree-sitter-lua = prev.tree-sitter-grammars.tree-sitter-lua.overrideAttrs (old: {
src = inputs.tree-sitter-lua;
});
# Add grammars not in nixpks
tree-sitter-ini = prev.tree-sitter.buildGrammar {
language = "ini";
version = "1.0.0";
src = inputs.tree-sitter-ini;
};
tree-sitter-puppet = prev.tree-sitter.buildGrammar {
language = "puppet";
version = "1.0.0";
src = inputs.tree-sitter-puppet;
};
tree-sitter-rasi = prev.tree-sitter.buildGrammar {
language = "rasi";
version = "0.1.1";
src = inputs.tree-sitter-rasi;
};
tree-sitter-vimdoc = prev.tree-sitter.buildGrammar {
language = "vimdoc";
version = "2.1.0";
src = inputs.tree-sitter-vimdoc;
};
};
}

View File

@ -8,20 +8,39 @@
# Sets Neovim colors based on Nix colorscheme # Sets Neovim colors based on Nix colorscheme
# options.colors = lib.mkOption { options.colors = lib.mkOption {
# type = lib.types.attrsOf lib.types.str; type = lib.types.attrsOf lib.types.str;
# description = "Attrset of base16 colorscheme key value pairs."; description = "Attrset of base16 colorscheme key value pairs.";
# }; default = {
# Nord
base00 = "#2E3440";
base01 = "#3B4252";
base02 = "#434C5E";
base03 = "#4C566A";
base04 = "#D8DEE9";
base05 = "#E5E9F0";
base06 = "#ECEFF4";
base07 = "#8FBCBB";
base08 = "#88C0D0";
base09 = "#81A1C1";
base0A = "#5E81AC";
base0B = "#BF616A";
base0C = "#D08770";
base0D = "#EBCB8B";
base0E = "#A3BE8C";
base0F = "#B48EAD";
};
};
# config = lib.mkIf config.colors { config = {
# plugins = [ pkgs.vimPlugins.base16-nvim ]; plugins = [ pkgs.vimPlugins.base16-nvim ];
# setup.base16-colorscheme = config.colors; setup.base16-colorscheme = config.colors;
#
# # Telescope isn't working, shut off for now # Telescope isn't working, shut off for now
# lua = '' lua = ''
# require('base16-colorscheme').with_config { require('base16-colorscheme').with_config {
# telescope = false, telescope = false,
# } }
# ''; '';
# }; };
} }

View File

@ -2,26 +2,24 @@
{ {
plugins = [ plugins = [
(pkgs.vimPlugins.nvim-treesitter.withPlugins ( (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: [
_plugins: with pkgs.tree-sitter-grammars; [ pkgs.nmasur.ini-grammar
tree-sitter-bash pkgs.nmasur.puppet-grammar
tree-sitter-c pkgs.nmasur.rasi-grammar
tree-sitter-fish pkgs.nmasur.vimdoc-grammar
tree-sitter-hcl pkgs.tree-sitter-grammars.tree-sitter-bash
tree-sitter-ini pkgs.tree-sitter-grammars.tree-sitter-c
tree-sitter-json pkgs.tree-sitter-grammars.tree-sitter-fish
tree-sitter-lua pkgs.tree-sitter-grammars.tree-sitter-hcl
tree-sitter-markdown pkgs.tree-sitter-grammars.tree-sitter-json
tree-sitter-markdown-inline pkgs.tree-sitter-grammars.tree-sitter-lua
tree-sitter-nix pkgs.tree-sitter-grammars.tree-sitter-markdown
tree-sitter-puppet pkgs.tree-sitter-grammars.tree-sitter-markdown-inline
tree-sitter-python pkgs.tree-sitter-grammars.tree-sitter-nix
tree-sitter-rasi pkgs.tree-sitter-grammars.tree-sitter-python
tree-sitter-toml pkgs.tree-sitter-grammars.tree-sitter-toml
tree-sitter-vimdoc pkgs.tree-sitter-grammars.tree-sitter-yaml
tree-sitter-yaml ]))
]
))
pkgs.vimPlugins.vim-matchup # Better % jumping in languages pkgs.vimPlugins.vim-matchup # Better % jumping in languages
pkgs.vimPlugins.playground # Tree-sitter experimenting pkgs.vimPlugins.playground # Tree-sitter experimenting
pkgs.vimPlugins.nginx-vim pkgs.vimPlugins.nginx-vim

View File

@ -28,10 +28,10 @@
{ {
pkgs, pkgs,
# colors ? null, colors ? null,
# terraform ? false, terraform ? false,
# github ? false, github ? false,
# kubernetes ? false, kubernetes ? false,
... ...
}: }:
@ -40,15 +40,15 @@
pkgs.neovimBuilder { pkgs.neovimBuilder {
package = pkgs.neovim-unwrapped; package = pkgs.neovim-unwrapped;
inherit inherit
# colors colors
# terraform terraform
# github github
# kubernetes kubernetes
; ;
imports = [ imports = [
./config/align.nix ./config/align.nix
./config/bufferline.nix ./config/bufferline.nix
# ./config/colors.nix ./config/colors.nix
./config/completion.nix ./config/completion.nix
./config/gitsigns.nix ./config/gitsigns.nix
./config/lsp.nix ./config/lsp.nix

View File

@ -0,0 +1,12 @@
{ pkgs, fetchFromGitHub }:
pkgs.tree-sitter.buildGrammar {
language = "ini";
version = "1.3.0";
src = fetchFromGitHub {
owner = "justinmk";
repo = "tree-sitter-ini";
rev = "32b31863f222bf22eb43b07d4e9be8017e36fb31";
sha256 = "sha256-kWCaOIC81GP5EHCqzPZP9EUgYy39CZ6/8TVS6soB6Wo=";
};
}

View File

@ -0,0 +1,12 @@
{ pkgs, fetchFromGitHub }:
pkgs.tree-sitter.buildGrammar {
language = "puppet";
version = "1.3.0";
src = fetchFromGitHub {
owner = "tree-sitter-grammars";
repo = "tree-sitter-puppet";
rev = "15f192929b7d317f5914de2b4accd37b349182a6";
sha256 = "sha256-bO5g5AdhzpB13yHklpAndUHIX7Rvd7OMjH0Ds2ATA6Q=";
};
}

View File

@ -0,0 +1,12 @@
{ pkgs, fetchFromGitHub }:
pkgs.tree-sitter.buildGrammar {
language = "rasi";
version = "0.1.2";
src = fetchFromGitHub {
owner = "Fymyte";
repo = "tree-sitter-rasi";
rev = "6c9bbcfdf5f0f553d9ebc01750a3aa247a37b8aa";
sha256 = "sha256-sPrIVgGGaBaXeqHNxjcdJ/S2FvxyV6rD9UPKU/tpspw=";
};
}

View File

@ -0,0 +1,12 @@
{ pkgs, fetchFromGitHub }:
pkgs.tree-sitter.buildGrammar {
language = "vimdoc";
version = "3.0.0";
src = fetchFromGitHub {
owner = "neovim";
repo = "tree-sitter-vimdoc";
rev = "d2e4b5c172a109966c2ce0378f73df6cede39400";
sha256 = "sha256-Vrl4/cZL+TWlUMEeWZoHCAWhvlefcl3ajGcwyTNKOhI=";
};
}

View File

@ -5,11 +5,11 @@
pkgs.stdenv.mkDerivation rec { pkgs.stdenv.mkDerivation rec {
pname = "bypass-paywalls-clean"; pname = "bypass-paywalls-clean";
version = "4.0.6.0"; version = "4.0.6.1";
src = builtins.fetchGit { src = builtins.fetchGit {
url = "https://gitflic.ru/project/magnolia1234/bpc_uploads.git"; url = "https://gitflic.ru/project/magnolia1234/bpc_uploads.git";
ref = "main"; ref = "main";
rev = "a3012f84bad9719760150832803f2ea07af8dae3"; rev = "85a367220f5ae2181354f65fb1093e2f1ac9e417";
}; };
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = true; allowSubstitutes = true;

View File

@ -0,0 +1,18 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "default" ''
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
echo ""
echo ""
${pkgs.gum}/bin/gum format --type=template -- \
' {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
' {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
' {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
' {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
' {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
' {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
' {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}'
echo ""
echo ""
''

View File

@ -0,0 +1,12 @@
{ pkgs, ... }:
pkgs.mkShell {
name = "dotfiles-devshell";
buildInputs = with pkgs; [
git
stylua
nixfmt-rfc-style
shfmt
shellcheck
];
}

View File

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "encrypt-secret" ''
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
read -p "Secret: " secret
printf "\nEncrypting...\n\n" 1>&2
tmpfile=$(mktemp)
echo "''${secret}" > ''${tmpfile}
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${builtins.toString ../../../../misc/public-keys} $tmpfile
rm $tmpfile
''

View File

@ -0,0 +1,44 @@
{ pkgs, ... }:
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
# This script will partition and format drives; use at your own risk!
pkgs.writeShellScriptBin "installer" ''
set -e
DISK=$1
FLAKE=$2
PARTITION_PREFIX=""
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
--foreground "#fb4934" \
"Missing required parameter." \
"Usage: installer -- <disk> <host>" \
"Example: installer -- nvme0n1 tempest" \
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest"
echo "(exiting)"
exit 1
fi
case "$DISK" in nvme*)
PARTITION_PREFIX="p"
esac
${pkgs.gum}/bin/gum confirm \
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \
--default=false
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
mount /dev/disk/by-label/nixos /mnt
mkdir --parents /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
''

View File

@ -8,7 +8,7 @@ TEXT_FILE="/tmp/ocr.txt"
IMAGE_FILE="/tmp/ocr.png" IMAGE_FILE="/tmp/ocr.png"
function notify-send() { function notify-send() {
/usr/bin/osascript -e "display notification \"$2\" with title \"OCR\"" /usr/bin/osascript -e "display notification \"$2\" with title \"OCR\""
} }
PATH="/usr/local/bin/:$PATH" PATH="/usr/local/bin/:$PATH"
@ -32,8 +32,8 @@ STATUS=$?
# specify /tmp/ocr.txt as the file path, tesseract would out the text to # specify /tmp/ocr.txt as the file path, tesseract would out the text to
# /tmp/ocr.txt.txt # /tmp/ocr.txt.txt
cd /tmp || { cd /tmp || {
echo "Failed to jump to directory." echo "Failed to jump to directory."
exit 1 exit 1
} }
tesseract "$IMAGE_FILE" "${TEXT_FILE//\.txt/}" tesseract "$IMAGE_FILE" "${TEXT_FILE//\.txt/}"
@ -41,8 +41,8 @@ tesseract "$IMAGE_FILE" "${TEXT_FILE//\.txt/}"
# of lines in the file # of lines in the file
LINES=$(wc -l <$TEXT_FILE) LINES=$(wc -l <$TEXT_FILE)
if [ "$LINES" -eq 0 ]; then if [ "$LINES" -eq 0 ]; then
notify-send "ocr" "no text was detected" notify-send "ocr" "no text was detected"
exit 1 exit 1
fi fi
# Copy text to clipboard # Copy text to clipboard

View File

@ -0,0 +1,5 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "readme" ''
${pkgs.glow}/bin/glow --pager ${builtins.toString ../../../../README.md}
''

View File

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "rebuild" ''
echo ${pkgs.system}
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
if [ "$SYSTEM" == "darwin" ]; then
sudo darwin-rebuild switch --flake ${builtins.toString ../../../../.}
else
doas nixos-rebuild switch --flake ${builtins.toString ../../../../.}
fi
''

View File

@ -14,17 +14,16 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# AWS settings require this nmasur.presets.services.openssh-aws.enable = lib.mkDefault true;
permitRootLogin = "prohibit-password";
# Make sure disk size is large enough # Make sure disk size is large enough
# https://github.com/nix-community/nixos-generators/issues/150 # https://github.com/nix-community/nixos-generators/issues/150
amazonImage.sizeMB = 16 * 1024; virtualisation.diskSize = lib.mkDefault (16 * 1024); # In MB
boot.kernelPackages = pkgs.legacyPackages.x86_64-linux.linuxKernel.packages.linux_6_6; boot.kernelPackages = lib.mkDefault pkgs.linuxKernel.packages.linux_6_6;
boot.loader.systemd-boot.enable = lib.mkForce false; boot.loader.systemd-boot.enable = false;
boot.loader.efi.canTouchEfiVariables = lib.mkForce false; boot.loader.efi.canTouchEfiVariables = false;
services.amazon-ssm-agent.enable = true; services.amazon-ssm-agent.enable = lib.mkDefault true;
users.users.ssm-user.extraGroups = [ "wheel" ]; users.users.ssm-user.extraGroups = [ "wheel" ];
}; };

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -15,7 +15,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ home.packages = [
pkgs.victor-mono # Used for Vim and Terminal pkgs.nerd-fonts.victor-mono # Used for Vim and Terminal
pkgs.nerd-fonts.hack # For Polybar, Rofi pkgs.nerd-fonts.hack # For Polybar, Rofi
]; ];
fonts.fontconfig = { fonts.fontconfig = {
@ -33,6 +33,7 @@ in
programs.alacritty.settings.font.normal.family = "VictorMono"; programs.alacritty.settings.font.normal.family = "VictorMono";
programs.kitty.font.name = "VictorMono Nerd Font Mono"; programs.kitty.font.name = "VictorMono Nerd Font Mono";
nmasur.presets.programs.wezterm.font = "VictorMono Nerd Font Mono"; nmasur.presets.programs.wezterm.font = "VictorMono Nerd Font Mono";
programs.ghostty.settings.font-family = "VictorMono Nerd Font Mono";
services.dunst.settings.global.font = "Hack Nerd Font 14"; services.dunst.settings.global.font = "Hack Nerd Font 14";
}; };
} }

View File

@ -23,7 +23,7 @@ in
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox; package = if pkgs.stdenv.isDarwin then pkgs.firefox-unwrapped else pkgs.firefox;
profiles.default = { profiles.default = {
id = 0; id = 0;
name = "default"; name = "default";

View File

@ -24,9 +24,12 @@ in
nmasur.presets.programs.fish.fish_user_key_bindings = # fish nmasur.presets.programs.fish.fish_user_key_bindings = # fish
'' ''
# Shift-Enter (defined by terminal) for mode in insert default visual
bind -M insert \x1F accept-autosuggestion # Shift-Enter (defined by terminal)
bind -M default \x1F accept-autosuggestion bind -M $mode \x1F accept-autosuggestion
# Ctrl-f to accept auto-suggestions
bind -M $mode \cf forward-char
end
''; '';
programs.fish = { programs.fish = {

View File

@ -25,7 +25,13 @@ in
functions = { functions = {
edit = { edit = {
description = "Open a file in Vim"; description = "Open a file in Vim";
body = builtins.readFile ./fish/edit.fish; body = # fish
''
set vimfile (fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} \"$vimfile\""
and commandline -f execute
'';
}; };
fcd = { fcd = {
description = "Jump to directory"; description = "Jump to directory";
@ -51,11 +57,40 @@ in
}; };
recent = { recent = {
description = "Open a recent file in Vim"; description = "Open a recent file in Vim";
body = builtins.readFile ./fish/recent.fish; body = # fish
''
set vimfile (fd -t f --exec /usr/bin/stat -f "%m%t%N" | sort -nr | cut -f2 | fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} $vimfile"
and commandline -f execute
'';
}; };
search-and-edit = { search-and-edit = {
description = "Search and open the relevant file in Vim"; description = "Search and open the relevant file in Vim";
body = builtins.readFile ./fish/search-and-edit.fish; body = # fish
''
set vimfile ( \
rg \
--color=always \
--line-number \
--no-heading \
--smart-case \
--iglob "!/Library/**" \
--iglob "!/System/**" \
--iglob "!Users/$HOME/Library/*" \
".*" \
| fzf --ansi \
--height "80%" \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
)
and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2)
and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1)
and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} +$line_number \"$vimfile\""
and commandline -f execute
'';
}; };
}; };
shellAbbrs = { shellAbbrs = {
@ -77,9 +112,6 @@ in
# Ctrl-e # Ctrl-e
bind -M insert \ce recent bind -M insert \ce recent
bind -M default \ce recent bind -M default \ce recent
# Ctrl-f
bind -M insert \cf fcd
bind -M default \cf fcd
# Ctrl-p # Ctrl-p
bind -M insert \cp projects bind -M insert \cp projects
bind -M default \cp projects bind -M default \cp projects

View File

@ -1,4 +0,0 @@
set vimfile (fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "vim \"$vimfile\""
and commandline -f execute

View File

@ -1,4 +0,0 @@
set vimfile (fd -t f --exec /usr/bin/stat -f "%m%t%N" | sort -nr | cut -f2 | fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "vim $vimfile"
and commandline -f execute

View File

@ -1,21 +0,0 @@
set vimfile ( \
rg \
--color=always \
--line-number \
--no-heading \
--smart-case \
--iglob "!/Library/**" \
--iglob "!/System/**" \
--iglob "!Users/$HOME/Library/*" \
".*" \
| fzf --ansi \
--height "80%" \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
)
and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2)
and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1)
and commandline -r "vim +$line_number \"$vimfile\""
and commandline -f execute

View File

@ -0,0 +1,76 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.ghostty;
in
{
options.nmasur.presets.programs.ghostty.enable = lib.mkEnableOption "Ghostty terminal";
config = lib.mkIf cfg.enable {
programs.ghostty = {
enable = true;
package = if pkgs.stdenv.isDarwin then pkgs.nur.repos.DimitarNestorov.ghostty else pkgs.ghostty;
enableFishIntegration = true;
enableBashIntegration = true;
enableZshIntegration = true;
installBatSyntax = false; # The file doesn't seem to exist in the pkg
settings = {
theme = config.theme.name;
font-size = 16;
macos-titlebar-style = "hidden";
window-decoration = false;
macos-non-native-fullscreen = true;
fullscreen = true;
keybind = [
"super+t=unbind" # Pass super-t to underlying tool (e.g. zellij tabs)
"super+shift+]=unbind"
"super+shift+[=unbind"
"ctrl+tab=unbind"
"ctrl+shift+tab=unbind"
];
};
themes."gruvbox" = {
background = config.theme.colors.base00;
cursor-color = config.theme.colors.base04;
foreground = config.theme.colors.base05;
palette = [
"0=${config.theme.colors.base00}"
"1=${config.theme.colors.base08}"
"2=${config.theme.colors.base0B}"
"3=${config.theme.colors.base0A}"
"4=${config.theme.colors.base0D}"
"5=${config.theme.colors.base0E}"
"6=${config.theme.colors.base0C}"
"7=${config.theme.colors.base05}"
"8=${config.theme.colors.base03}"
"9=${config.theme.colors.base08}"
"10=${config.theme.colors.base0B}"
"11=${config.theme.colors.base0A}"
"12=${config.theme.colors.base0C}"
"13=${config.theme.colors.base0E}"
"14=${config.theme.colors.base0C}"
"15=${config.theme.colors.base07}"
"16=${config.theme.colors.base09}"
"17=${config.theme.colors.base0F}"
"18=${config.theme.colors.base01}"
"19=${config.theme.colors.base02}"
"20=${config.theme.colors.base04}"
"21=${config.theme.colors.base06}"
];
selection-background = config.theme.colors.base02;
selection-foreground = config.theme.colors.base00;
};
};
};
}

View File

@ -27,10 +27,12 @@ in
name = lib.mkOption { name = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Name to use for personal git commits"; description = "Name to use for personal git commits";
default = config.nmasur.presets.programs.git.name;
}; };
email = lib.mkOption { email = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Email to use for personal git commits"; description = "Email to use for personal git commits";
default = config.nmasur.presets.programs.git.email;
}; };
}; };
}; };
@ -42,7 +44,7 @@ in
userEmail = lib.mkForce cfg.work.email; userEmail = lib.mkForce cfg.work.email;
includes = [ includes = [
{ {
path = "${config.xdg.configHome}/${config.xdg.configFile."git/personal".target}"; path = "${config.home.homeDirectory}/${config.xdg.configFile."git/personal".target}";
condition = "gitdir:~/dev/personal/"; condition = "gitdir:~/dev/personal/";
} }
]; ];
@ -50,7 +52,7 @@ in
}; };
# Personal git config # Personal git config
xdg.configFile."git/personal".text = pkgs.formats.gitIni { xdg.configFile."git/personal".text = lib.generators.toGitINI {
user = { user = {
name = cfg.personal.name; name = cfg.personal.name;
email = cfg.personal.email; email = cfg.personal.email;

View File

@ -32,7 +32,7 @@ in
userName = cfg.name; userName = cfg.name;
userEmail = cfg.email; userEmail = cfg.email;
extraConfig = { extraConfig = {
core.pager = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F"; core.pager = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less --no-init";
interactive.difffilter = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight"; interactive.difffilter = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight";
pager = { pager = {
branch = "false"; branch = "false";

View File

@ -0,0 +1,382 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.helix;
in
{
options.nmasur.presets.programs.helix.enable = lib.mkEnableOption "Helix text editor";
config = lib.mkIf cfg.enable {
# Use Neovim as the editor for git commit messages
programs.git.extraConfig.core.editor = lib.mkForce "${lib.getExe pkgs.helix}";
programs.jujutsu.settings.ui.editor = lib.mkForce "${lib.getExe pkgs.helix}";
# Set Neovim as the default app for text editing and manual pages
home.sessionVariables = {
EDITOR = lib.mkForce "${lib.getExe pkgs.helix}";
};
# Create quick aliases for launching Helix
programs.fish = {
shellAbbrs = {
h = lib.mkForce "hx";
};
};
programs.helix = {
enable = true;
package = pkgs.helix; # pkgs.evil-helix
languages = {
language-server.nixd = {
command = "${pkgs.nixd}/bin/nixd";
};
language-server.fish-lsp = {
command = "${pkgs.fish-lsp}/bin/fish-lsp";
};
language-server.yaml-language-server = {
command = lib.getExe pkgs.yaml-language-server;
};
language-server.marksman = {
command = lib.getExe pkgs.marksman;
};
language-server.terraform-ls = {
command = "${lib.getExe pkgs.terraform-ls} serve";
};
language-server.bash-language-server = {
command = lib.getExe (
pkgs.bash-language-server.overrideAttrs {
buildInputs = [
pkgs.shellcheck
pkgs.shfmt
];
}
);
};
language = [
{
name = "nix";
auto-format = true;
language-servers = [ "nixd" ];
}
{
name = "markdown";
auto-format = true;
language-servers = [ "marksman" ];
formatter = {
command = lib.getExe pkgs.mdformat;
args = [ "-" ];
};
}
{
name = "tfvars";
auto-format = true;
language-servers = [ "terraform-ls" ];
formatter = {
command = lib.getExe pkgs.terraform;
args = [
"fmt"
"-"
];
};
}
{
name = "hcl";
auto-format = true;
language-servers = [ "terraform-ls" ];
formatter = {
command = lib.getExe pkgs.terraform;
args = [
"fmt"
"-"
];
};
}
{
name = "bash";
auto-format = true;
}
];
};
settings = {
theme = "base16";
keys.normal = {
# Enable and disable inlay hints
space.H = ":toggle lsp.display-inlay-hints";
# Extend selection above
X = "select_line_above";
# Move lines up or down
A-j = [
"extend_to_line_bounds"
"delete_selection"
"paste_after"
];
A-k = [
"extend_to_line_bounds"
"delete_selection"
"move_line_up"
"paste_before"
];
# Copy lines up or down
A-J = [
"extend_to_line_bounds"
"yank"
"paste_after"
];
A-K = [
"extend_to_line_bounds"
"yank"
"paste_before"
];
};
editor = {
# Change cursors depending on the mode
cursor-shape = {
insert = "bar";
normal = "block";
select = "underline";
};
# Text width
soft-wrap = {
enable = true;
};
# View line numbers relative to the current cursors
line-number = "relative";
# Show hidden files
file-picker = {
hidden = false;
git-ignore = true;
git-global = true;
git-exclude = true;
};
# Show whitespace visible to the user
# Waiting for trailing whitespace option ideally
whitespace = {
render = {
# space = "all";
tab = "all";
};
characters = {
# space = "·";
tab = "";
};
};
};
};
themes."${config.programs.helix.settings.theme}" = {
"attributes" = config.theme.colors.base09;
"comment" = {
fg = config.theme.colors.base03;
modifiers = [ "italic" ];
};
"constant" = config.theme.colors.base09;
"constant.character.escape" = config.theme.colors.base0C;
"constant.numeric" = config.theme.colors.base09;
"constructor" = config.theme.colors.base0D;
"debug" = config.theme.colors.base03;
"diagnostic" = {
modifiers = [ "underlined" ];
};
"diff.delta" = config.theme.colors.base09;
"diff.minus" = config.theme.colors.base08;
"diff.plus" = config.theme.colors.base0B;
"error" = config.theme.colors.base08;
"function" = config.theme.colors.base0D;
"hint" = config.theme.colors.base03;
"info" = config.theme.colors.base0D;
"keyword" = config.theme.colors.base0E;
"label" = config.theme.colors.base0E;
"namespace" = config.theme.colors.base0E;
"operator" = config.theme.colors.base05;
"special" = config.theme.colors.base0D;
"string" = config.theme.colors.base0B;
"type" = config.theme.colors.base0A;
"variable" = config.theme.colors.base08;
"variable.other.member" = config.theme.colors.base05;
"warning" = config.theme.colors.base09;
"markup.bold" = {
fg = config.theme.colors.base0A;
modifiers = [ "bold" ];
};
"markup.heading" = config.theme.colors.base0D;
"markup.italic" = {
fg = config.theme.colors.base0E;
modifiers = [ "italic" ];
};
"markup.link.text" = config.theme.colors.base08;
"markup.link.url" = {
fg = config.theme.colors.base09;
modifiers = [ "underlined" ];
};
"markup.list" = config.theme.colors.base08;
"markup.quote" = config.theme.colors.base0C;
"markup.raw" = config.theme.colors.base0B;
"markup.strikethrough" = {
modifiers = [ "crossed_out" ];
};
"diagnostic.hint" = {
underline = {
style = "curl";
};
};
"diagnostic.info" = {
underline = {
style = "curl";
};
};
"diagnostic.warning" = {
underline = {
style = "curl";
};
};
"diagnostic.error" = {
underline = {
style = "curl";
};
};
"ui.background" = {
bg = config.theme.colors.base00;
};
"ui.bufferline.active" = {
fg = config.theme.colors.base00;
bg = config.theme.colors.base03;
modifiers = [ "bold" ];
};
"ui.bufferline" = {
fg = config.theme.colors.base04;
bg = config.theme.colors.base00;
};
"ui.cursor" = {
fg = config.theme.colors.base0A;
modifiers = [ "reversed" ];
};
"ui.cursor.insert" = {
fg = config.theme.colors.base0A;
modifiers = [ "reversed" ];
};
"ui.cursorline.primary" = {
fg = config.theme.colors.base05;
bg = config.theme.colors.base01;
};
"ui.cursor.match" = {
fg = config.theme.colors.base0A;
modifiers = [ "reversed" ];
};
"ui.cursor.select" = {
fg = config.theme.colors.base0A;
modifiers = [ "reversed" ];
};
"ui.gutter" = {
bg = config.theme.colors.base00;
};
"ui.help" = {
fg = config.theme.colors.base06;
bg = config.theme.colors.base01;
};
"ui.linenr" = {
fg = config.theme.colors.base03;
bg = config.theme.colors.base00;
};
"ui.linenr.selected" = {
fg = config.theme.colors.base04;
bg = config.theme.colors.base01;
modifiers = [ "bold" ];
};
"ui.menu" = {
fg = config.theme.colors.base05;
bg = config.theme.colors.base01;
};
"ui.menu.scroll" = {
fg = config.theme.colors.base03;
bg = config.theme.colors.base01;
};
"ui.menu.selected" = {
fg = config.theme.colors.base01;
bg = config.theme.colors.base04;
};
"ui.popup" = {
bg = config.theme.colors.base01;
};
"ui.selection" = {
bg = config.theme.colors.base01;
};
"ui.selection.primary" = {
bg = config.theme.colors.base02;
};
"ui.statusline" = {
fg = config.theme.colors.base04;
bg = config.theme.colors.base01;
};
"ui.statusline.inactive" = {
bg = config.theme.colors.base01;
fg = config.theme.colors.base03;
};
"ui.statusline.insert" = {
fg = config.theme.colors.base00;
bg = config.theme.colors.base0B;
};
"ui.statusline.normal" = {
fg = config.theme.colors.base00;
bg = config.theme.colors.base03;
};
"ui.statusline.select" = {
fg = config.theme.colors.base00;
bg = config.theme.colors.base0F;
};
"ui.text" = config.theme.colors.base05;
"ui.text.focus" = config.theme.colors.base05;
"ui.virtual.indent-guide" = {
fg = config.theme.colors.base03;
};
"ui.virtual.inlay-hint" = {
fg = config.theme.colors.base03;
};
"ui.virtual.ruler" = {
bg = config.theme.colors.base01;
};
"ui.virtual.jump-label" = {
fg = config.theme.colors.base0A;
modifiers = [ "bold" ];
};
"ui.window" = {
bg = config.theme.colors.base01;
};
};
};
};
}

View File

@ -28,13 +28,14 @@ in
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
#nmasur.presets.programs.neovim.package = lib.mkDefault pkgs.nmasur-neovim.override { nmasur.presets.programs.neovim.package = lib.mkDefault (
# colors = cfg.colors; pkgs.nmasur.neovim.override {
# github = cfg.github.enable; colors = cfg.colors;
# terraform = cfg.terraform.enable; github = cfg.github.enable;
# kubernetes = cfg.kubernetes.enable; terraform = cfg.terraform.enable;
#}; kubernetes = cfg.kubernetes.enable;
nmasur.presets.programs.neovim.package = pkgs.nmasur.neovim; }
);
# Use Neovim as the editor for git commit messages # Use Neovim as the editor for git commit messages
programs.git.extraConfig.core.editor = "${lib.getExe cfg.package}"; programs.git.extraConfig.core.editor = "${lib.getExe cfg.package}";
@ -61,14 +62,16 @@ in
# Create a desktop option for launching Neovim from a file manager # Create a desktop option for launching Neovim from a file manager
# (Requires launching the terminal and then executing Neovim) # (Requires launching the terminal and then executing Neovim)
xdg.desktopEntries.nvim = lib.mkIf (pkgs.stdenv.isLinux && config.nmasur.presets.services.i3.enable) { xdg.desktopEntries.nvim =
name = "Neovim wrapper"; lib.mkIf (pkgs.stdenv.isLinux && config.nmasur.presets.services.i3.enable)
exec = "${lib.getExe config.nmasur.presets.services.i3.terminal} nvim %F"; # TODO: change to generic {
mimeType = [ name = "Neovim wrapper";
"text/plain" exec = "${lib.getExe config.nmasur.presets.services.i3.terminal} nvim %F"; # TODO: change to generic
"text/markdown" mimeType = [
]; "text/plain"
}; "text/markdown"
];
};
xdg.mimeApps.defaultApplications = { xdg.mimeApps.defaultApplications = {
"text/plain" = [ "nvim.desktop" ]; "text/plain" = [ "nvim.desktop" ];
"text/markdown" = [ "nvim.desktop" ]; "text/markdown" = [ "nvim.desktop" ];

View File

@ -0,0 +1,53 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.zed-editor;
in
{
options.nmasur.presets.programs.zed-editor.enable = lib.mkEnableOption "Zed text editor";
config = lib.mkIf cfg.enable {
programs.zed-editor = {
enable = true;
extensions = [
"nix"
"rust"
];
extraPackages = [ pkgs.nixd ];
installRemoteServer = false;
userKeymaps = [
{
context = "Workspace";
bindings = {
ctrl-shift-t = "workspace::NewTerminal";
};
}
];
userSettings = {
features = {
copilot = false;
};
telemetry = {
metrics = false;
};
vim_mode = true;
ui_font_size = 16;
buffer_font_size = 16;
};
};
};
}

View File

@ -0,0 +1,141 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.zellij;
in
{
options.nmasur.presets.programs.zellij.enable = lib.mkEnableOption "Zellij terminal multiplexer";
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.zellij-switch ];
programs.fish = {
shellAbbrs.z = "zellij";
functions = {
zellij-session = {
# description = "Open a session in Zellij";
body = # fish
''
zoxide query --interactive | xargs -I {} sh -c 'zellij pipe --plugin file:$(which zellij-switch.wasm) -- "--cwd {} --layout default --session $(basename {})"' \\;
'';
};
};
};
xdg.configFile."zellij/layouts/compact-top.kdl".text = # kdl
''
layout {
pane size=1 borderless=true {
plugin location="compact-bar"
}
pane
}
'';
xdg.configFile."zellij/layouts/default.kdl".text = # kdl
''
layout {
pane size=1 borderless=true {
plugin location="tab-bar"
}
pane
pane size=1 borderless=true {
plugin location="status-bar"
}
}
'';
programs.zellij = {
enable = true;
enableBashIntegration = true;
enableFishIntegration = true;
enableZshIntegration = true;
# Not yet available in unstable
# attachExistingSession = true;
# exitShellOnExit = true;
settings = {
# default_layout = "compact-top";
# Remove border
pane_frames = false;
# Scrollback
scrollback_editor = config.home.sessionVariables.EDITOR;
# plugins = {
# autolock = {
# _props = {
# location = "https://github.com/fresh2dev/zellij-autolock/releases/download/0.2.2/zellij-autolock.wasm";
# };
# is_enabled = {
# _args = [ true ];
# };
# triggers = {
# _args = [ "vim|nvim|hx|git|fzf|zoxide|atuin|gh" ];
# };
# reaction_seconds = {
# _args = [ "0.3" ];
# };
# print_to_log = {
# _args = [ true ];
# };
# };
# };
# load_plugins = {
# autolock = { };
# };
keybinds = {
normal = {
};
shared = {
"bind \"Alt Shift p\"" = {
"Run" = {
_args = [
"${pkgs.fish}/bin/fish"
"-c"
"zellij-session"
];
close_on_exit = true;
};
};
"bind \"Super Shift ]\"" = {
"GoToNextTab" = { };
};
"bind \"Super Shift [\"" = {
"GoToPreviousTab" = { };
};
"bind \"Super t\"" = {
"NewTab" = { };
};
};
};
theme = "custom";
themes.custom = {
fg = "${config.theme.colors.base05}";
bg = "${config.theme.colors.base02}";
black = "${config.theme.colors.base00}";
red = "${config.theme.colors.base08}";
green = "${config.theme.colors.base0B}";
yellow = "${config.theme.colors.base0A}";
blue = "${config.theme.colors.base0D}";
magenta = "${config.theme.colors.base0E}";
cyan = "${config.theme.colors.base0C}";
white = "${config.theme.colors.base05}";
orange = "${config.theme.colors.base09}";
};
};
};
};
}

View File

@ -1,21 +1,96 @@
# Credit: https://github.com/Ptujec/LaunchBar/blob/f7b5a0dba9919c2fec879513f68a044f78748539/Notifications/Dismiss%20all%20notifications.lbaction/Contents/Scripts/default.applescript # Credit: https://github.com/Ptujec/LaunchBar/blob/a6dca4f21f3474eab0454fdd306bff6bab0d4f16/Notifications/Dismiss%20all%20notifications.lbaction/Contents/Scripts/default.applescript
tell application "System Events" (*
try Close notifications Applescript Action for LaunchBar
set _groups to groups of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" by Christian Bender (@ptujec)
2024-10-15
repeat with _group in _groups requires macOS 15.2
set _actions to actions of _group Copyright see: https://github.com/Ptujec/LaunchBar/blob/master/LICENSE
repeat with _action in _actions Helpful:
if description of _action is in {"Schlie§en", "Alle entfernen", "Close", "Clear All"} then - https://applehelpwriter.com/2016/08/09/applescript-get-item-number-of-list-item/
perform _action - https://www.macscripter.net/t/coerce-gui-scripting-information-into-string/62842/3
- https://forum.keyboardmaestro.com/t/understanding-applescript-ui-scripting-to-click-menus/29039/23?page=2
*)
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
property NSArray : a reference to current application's NSArray
property alertAndBannerSet : {"AXNotificationCenterAlert", "AXNotificationCenterBanner"}
property closeActionSet : {"Close", "Clear All", "Schließen", "Alle entfernen", "Cerrar", "Borrar todo", "关闭", "清除全部", "Fermer", "Tout effacer", "Закрыть", "Очистить все", "إغلاق", "مسح الكل", "Fechar", "Limpar tudo", "閉じる", "すべてクリア", "बंद करें", "सभी हटाएं", "Zamknij", "Wyczyść wszystko"}
on run
tell application "System Events"
try
set _main_group to group 1 of scroll area 1 of group 1 of group 1 of window 1 of application process "NotificationCenter"
on error eStr number eNum
display notification eStr with title "Error " & eNum sound name "Frog"
return
end try
set _headings to UI elements of _main_group whose role is "AXHeading"
set _headingscount to count of _headings
end tell
repeat _headingscount times
tell application "System Events" to set _roles to role of UI elements of _main_group
set _headingIndex to its getIndexOfItem:"AXHeading" inList:_roles
set _closeButtonIndex to _headingIndex + 1
tell application "System Events" to click item _closeButtonIndex of UI elements of _main_group
delay 0.4
end repeat
tell application "System Events"
try
set _groups to groups of _main_group
if _groups is {} then
if subrole of _main_group is in alertAndBannerSet then
set _actions to actions of _main_group
repeat with _action in _actions
if description of _action is in closeActionSet then
perform _action
end if
end repeat
end if end if
return
end if
repeat with _group in _groups
set _actions to actions of first item of _groups # always picking the first to avoid index error
repeat with _action in _actions
if description of _action is in closeActionSet then
perform _action
end if
end repeat
end repeat end repeat
on error
if subrole of _main_group is in alertAndBannerSet then
set _actions to actions of _main_group
repeat with _action in _actions
if description of _action is in closeActionSet then
perform _action
end if
end repeat
end if
end try
end tell
end run
end repeat on getIndexOfItem:anItem inList:aList
set anArray to NSArray's arrayWithArray:aList
end try set ind to ((anArray's indexOfObject:anItem) as number) + 1
end tell if ind is greater than (count of aList) then
display dialog "Item '" & anItem & "' not found in list." buttons "OK" default button "OK" with icon 2 with title "Error"
return 0
else
return ind
end if
end getIndexOfItem:inList:

View File

@ -1,298 +0,0 @@
/* Credit: https://gist.github.com/lancethomps/a5ac103f334b171f70ce2ff983220b4f */
function run(input, parameters) {
const appNames = [];
const skipAppNames = [];
const verbose = true;
const scriptName = "close_notifications_applescript";
const CLEAR_ALL_ACTION = "Clear All";
const CLEAR_ALL_ACTION_TOP = "Clear";
const CLOSE_ACTION = "Close";
const notNull = (val) => {
return val !== null && val !== undefined;
};
const isNull = (val) => {
return !notNull(val);
};
const notNullOrEmpty = (val) => {
return notNull(val) && val.length > 0;
};
const isNullOrEmpty = (val) => {
return !notNullOrEmpty(val);
};
const isError = (maybeErr) => {
return notNull(maybeErr) && (maybeErr instanceof Error || maybeErr.message);
};
const systemVersion = () => {
return Application("Finder").version().split(".").map(val => parseInt(val));
};
const systemVersionGreaterThanOrEqualTo = (vers) => {
return systemVersion()[0] >= vers;
};
const isBigSurOrGreater = () => {
return systemVersionGreaterThanOrEqualTo(11);
};
const V11_OR_GREATER = isBigSurOrGreater();
const APP_NAME_MATCHER_ROLE = V11_OR_GREATER ? "AXStaticText" : "AXImage";
const hasAppNames = notNullOrEmpty(appNames);
const hasSkipAppNames = notNullOrEmpty(skipAppNames);
const hasAppNameFilters = hasAppNames || hasSkipAppNames;
const appNameForLog = hasAppNames ? ` [${appNames.join(",")}]` : "";
const logs = [];
const log = (message, ...optionalParams) => {
let message_with_prefix = `${new Date().toISOString().replace("Z", "").replace("T", " ")} [${scriptName}]${appNameForLog} ${message}`;
console.log(message_with_prefix, optionalParams);
logs.push(message_with_prefix);
};
const logError = (message, ...optionalParams) => {
if (isError(message)) {
let err = message;
message = `${err}${err.stack ? (" " + err.stack) : ""}`;
}
log(`ERROR ${message}`, optionalParams);
};
const logErrorVerbose = (message, ...optionalParams) => {
if (verbose) {
logError(message, optionalParams);
}
};
const logVerbose = (message) => {
if (verbose) {
log(message);
}
};
const getLogLines = () => {
return logs.join("\n");
};
const getSystemEvents = () => {
let systemEvents = Application("System Events");
systemEvents.includeStandardAdditions = true;
return systemEvents;
};
const getNotificationCenter = () => {
try {
return getSystemEvents().processes.byName("NotificationCenter");
} catch (err) {
logError("Could not get NotificationCenter");
throw err;
}
};
const getNotificationCenterGroups = (retryOnError = false) => {
try {
let notificationCenter = getNotificationCenter();
if (notificationCenter.windows.length <= 0) {
return [];
}
if (!V11_OR_GREATER) {
return notificationCenter.windows();
}
return notificationCenter.windows[0].uiElements[0].uiElements[0].uiElements();
} catch (err) {
logError("Could not get NotificationCenter groups");
if (retryOnError) {
logError(err);
log("Retrying getNotificationCenterGroups...");
return getNotificationCenterGroups(false);
} else {
throw err;
}
}
};
const isClearButton = (description, name) => {
return description === "button" && name === CLEAR_ALL_ACTION_TOP;
};
const matchesAnyAppNames = (value, checkValues) => {
if (isNullOrEmpty(checkValues)) {
return false;
}
let lowerAppName = value.toLowerCase();
for (let checkValue of checkValues) {
if (lowerAppName === checkValue.toLowerCase()) {
return true;
}
}
return false;
};
const matchesAppName = (role, value) => {
if (role !== APP_NAME_MATCHER_ROLE) {
return false;
}
if (hasAppNames) {
return matchesAnyAppNames(value, appNames);
}
return !matchesAnyAppNames(value, skipAppNames);
};
const notificationGroupMatches = (group) => {
try {
let description = group.description();
if (V11_OR_GREATER && isClearButton(description, group.name())) {
return true;
}
if (V11_OR_GREATER && description !== "group") {
return false;
}
if (!V11_OR_GREATER) {
let matchedAppName = !hasAppNameFilters;
if (!matchedAppName) {
for (let elem of group.uiElements()) {
if (matchesAppName(elem.role(), elem.description())) {
matchedAppName = true;
break;
}
}
}
if (matchedAppName) {
return notNull(findCloseActionV10(group, -1));
}
return false;
}
if (!hasAppNameFilters) {
return true;
}
let firstElem = group.uiElements[0];
return matchesAppName(firstElem.role(), firstElem.value());
} catch (err) {
logErrorVerbose(`Caught error while checking window, window is probably closed: ${err}`);
logErrorVerbose(err);
}
return false;
};
const findCloseActionV10 = (group, closedCount) => {
try {
for (let elem of group.uiElements()) {
if (elem.role() === "AXButton" && elem.title() === CLOSE_ACTION) {
return elem.actions["AXPress"];
}
}
} catch (err) {
logErrorVerbose(`(group_${closedCount}) Caught error while searching for close action, window is probably closed: ${err}`);
logErrorVerbose(err);
return null;
}
log("No close action found for notification");
return null;
};
const findCloseAction = (group, closedCount) => {
try {
if (!V11_OR_GREATER) {
return findCloseActionV10(group, closedCount);
}
let checkForPress = isClearButton(group.description(), group.name());
let clearAllAction;
let closeAction;
for (let action of group.actions()) {
let description = action.description();
if (description === CLEAR_ALL_ACTION) {
clearAllAction = action;
break;
} else if (description === CLOSE_ACTION) {
closeAction = action;
} else if (checkForPress && description === "press") {
clearAllAction = action;
break;
}
}
if (notNull(clearAllAction)) {
return clearAllAction;
} else if (notNull(closeAction)) {
return closeAction;
}
} catch (err) {
logErrorVerbose(`(group_${closedCount}) Caught error while searching for close action, window is probably closed: ${err}`);
logErrorVerbose(err);
return null;
}
log("No close action found for notification");
return null;
};
const closeNextGroup = (groups, closedCount) => {
try {
for (let group of groups) {
if (notificationGroupMatches(group)) {
let closeAction = findCloseAction(group, closedCount);
if (notNull(closeAction)) {
try {
closeAction.perform();
return [true, 1];
} catch (err) {
logErrorVerbose(`(group_${closedCount}) Caught error while performing close action, window is probably closed: ${err}`);
logErrorVerbose(err);
}
}
return [true, 0];
}
}
return false;
} catch (err) {
logError("Could not run closeNextGroup");
throw err;
}
};
try {
let groupsCount = getNotificationCenterGroups(true).filter(group => notificationGroupMatches(group)).length;
if (groupsCount > 0) {
logVerbose(`Closing ${groupsCount}${appNameForLog} notification group${(groupsCount > 1 ? "s" : "")}`);
let startTime = new Date().getTime();
let closedCount = 0;
let maybeMore = true;
let maxAttempts = 2;
let attempts = 1;
while (maybeMore && ((new Date().getTime() - startTime) <= (1000 * 30))) {
try {
let closeResult = closeNextGroup(getNotificationCenterGroups(), closedCount);
maybeMore = closeResult[0];
if (maybeMore) {
closedCount = closedCount + closeResult[1];
}
} catch (innerErr) {
if (maybeMore && closedCount === 0 && attempts < maxAttempts) {
log(`Caught an error before anything closed, trying ${maxAttempts - attempts} more time(s).`)
attempts++;
} else {
throw innerErr;
}
}
}
} else {
throw Error(`No${appNameForLog} notifications found...`);
}
} catch (err) {
logError(err);
logError(err.message);
getLogLines();
throw err;
}
return getLogLines();
}

View File

@ -56,11 +56,15 @@ function obj:init()
-- Launcher shortcuts -- Launcher shortcuts
self.launcher:bind("ctrl", "space", function() end) self.launcher:bind("ctrl", "space", function() end)
self.launcher:bind("", "return", function() self.launcher:bind("", "return", function()
self:switch("@wezterm@") -- self:switch("@wezterm@")
self:switch("@ghostty@")
end) end)
self.launcher:bind("", "C", function() self.launcher:bind("", "C", function()
self:switch("Calendar.app") self:switch("Calendar.app")
end) end)
self.launcher:bind("", "D", function()
self:switch("@discord@")
end)
self.launcher:bind("shift", "D", function() self.launcher:bind("shift", "D", function()
hs.execute("launchctl remove com.paloaltonetworks.gp.pangps") hs.execute("launchctl remove com.paloaltonetworks.gp.pangps")
hs.execute("launchctl remove com.paloaltonetworks.gp.pangpa") hs.execute("launchctl remove com.paloaltonetworks.gp.pangpa")

View File

@ -42,6 +42,7 @@ local function worklayout()
-- set the layout -- set the layout
local left = { local left = {
{ "WezTerm", nil, WORK_ONLY_MONITOR, u(0, 0, 1 / 2, 1), nil, nil, visible = true }, { "WezTerm", nil, WORK_ONLY_MONITOR, u(0, 0, 1 / 2, 1), nil, nil, visible = true },
{ "Ghostty", nil, WORK_ONLY_MONITOR, u(0, 0, 1 / 2, 1), nil, nil, visible = true },
} }
local right = { local right = {
{ "Slack", nil, WORK_ONLY_MONITOR, u(1 / 2, 0, 1 / 2, 1), nil, nil, visible = true }, { "Slack", nil, WORK_ONLY_MONITOR, u(1 / 2, 0, 1 / 2, 1), nil, nil, visible = true },

View File

@ -20,11 +20,12 @@ in
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = ./Spoons/DismissAlerts.spoon; xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = ./Spoons/DismissAlerts.spoon;
xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = pkgs.substituteAll { xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = pkgs.substituteAll {
src = ./Spoons/Launcher.spoon/init.lua; src = ./Spoons/Launcher.spoon/init.lua;
firefox = "${pkgs.firefox-bin}/Applications/Firefox.app";
discord = "${pkgs.discord}/Applications/Discord.app"; discord = "${pkgs.discord}/Applications/Discord.app";
wezterm = "${pkgs.wezterm}/Applications/WezTerm.app"; firefox = "${pkgs.firefox-unwrapped}/Applications/Firefox.app";
ghostty = "${config.programs.ghostty.package}/Applications/Ghostty.app";
obsidian = "${pkgs.obsidian}/Applications/Obsidian.app"; obsidian = "${pkgs.obsidian}/Applications/Obsidian.app";
slack = "${pkgs.slack}/Applications/Slack.app"; slack = "${pkgs.slack}/Applications/Slack.app";
wezterm = "${pkgs.wezterm}/Applications/WezTerm.app";
}; };
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./Spoons/MoveWindow.spoon; xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./Spoons/MoveWindow.spoon;

View File

@ -6,7 +6,7 @@
}: }:
let let
inherit (config.nmasur.settings) fullName hostnames; inherit (config.nmasur.settings) username fullName hostnames;
cfg = config.nmasur.presets.services.mbsync; cfg = config.nmasur.presets.services.mbsync;
in in
@ -17,10 +17,12 @@ in
user = lib.mkOption { user = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "User name for the email address."; description = "User name for the email address.";
default = username;
}; };
server = lib.mkOption { server = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Server name for the email address."; description = "Server name for the email address.";
default = hostnames.mail;
}; };
imapHost = lib.mkOption { imapHost = lib.mkOption {
type = lib.types.str; type = lib.types.str;
@ -112,7 +114,7 @@ in
notmuch.enable = true; notmuch.enable = true;
# Used to login and send and receive emails # Used to login and send and receive emails
passwordCommand = "${lib.getExe pkgs.age} --decrypt --identity ~/.ssh/id_ed25519 ${pkgs.writeText "mailpass.age" (builtins.readFile ../../../../../../private/mailpass.age)}"; passwordCommand = "${lib.getExe pkgs.age} --decrypt --identity ~/.ssh/id_ed25519 ${pkgs.writeText "mailpass.age" (builtins.readFile ./mailpass.age)}";
smtp = { smtp = {
host = cfg.smtpHost; host = cfg.smtpHost;

View File

@ -129,7 +129,7 @@ in
folder:main/Inbox \ folder:main/Inbox \
2>/dev/null 2>/dev/null
) )
if [ $UNREAD = "0" ]; then if [ "$UNREAD" = "0" ]; then
echo "" echo ""
else else
echo "%{T2}%{T-} $UNREAD " echo "%{T2}%{T-} $UNREAD "

View File

@ -13,6 +13,10 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.username = config.nmasur.settings.username;
home.homeDirectory =
if pkgs.stdenv.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}";
home.packages = [ home.packages = [
pkgs.dig # DNS lookup pkgs.dig # DNS lookup
pkgs.fd # find pkgs.fd # find
@ -35,7 +39,6 @@ in
nixpkgs.enable = lib.mkDefault true; nixpkgs.enable = lib.mkDefault true;
}; };
services = { services = {
nix.enable = lib.mkDefault true;
loadkey.enable = lib.mkDefault true; loadkey.enable = lib.mkDefault true;
}; };
}; };

View File

@ -14,6 +14,15 @@ in
options.nmasur.profiles.darwin-base.enable = lib.mkEnableOption "Base macOS home-manager config"; options.nmasur.profiles.darwin-base.enable = lib.mkEnableOption "Base macOS home-manager config";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nmasur.presets = {
fonts.enable = lib.mkDefault true;
services.hammerspoon.enable = lib.mkDefault true;
programs.nixpkgs-darwin.enable = lib.mkDefault true;
};
home.homeDirectory = lib.mkForce "/Users/${config.home.username}";
# Default shell setting doesn't work # Default shell setting doesn't work
home.sessionVariables = { home.sessionVariables = {
SHELL = "${pkgs.fish}/bin/fish"; SHELL = "${pkgs.fish}/bin/fish";
@ -22,6 +31,8 @@ in
# Used for aerc # Used for aerc
xdg.enable = lib.mkDefault pkgs.stdenv.isDarwin; xdg.enable = lib.mkDefault pkgs.stdenv.isDarwin;
programs.fish.shellAbbrs.t = "trash";
# Add homebrew paths to CLI path # Add homebrew paths to CLI path
home.sessionPath = [ home.sessionPath = [
"/opt/homebrew/bin/" "/opt/homebrew/bin/"

View File

@ -15,6 +15,13 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nmasur.presets.programs = {
zed-editor.enable = lib.mkDefault true;
ghostty.enable = lib.mkDefault true;
helix.enable = lib.mkDefault true;
zellij.enable = lib.mkDefault true;
};
home.packages = [ home.packages = [
# Charm tools # Charm tools
@ -24,11 +31,11 @@ in
pkgs.charm # Manage account and filesystem pkgs.charm # Manage account and filesystem
pkgs.pop # Send emails from a TUI pkgs.pop # Send emails from a TUI
pkgs.yazi # TUI file explorer
]; ];
programs.gh-dash.enable = lib.mkDefault true; programs.gh-dash.enable = lib.mkDefault true;
programs.helix.enable = lib.mkDefault true;
programs.zed-editor.enable = lib.mkDefault true;
programs.himalaya.enable = lib.mkDefault true; programs.himalaya.enable = lib.mkDefault true;
}; };

View File

@ -26,11 +26,12 @@ in
firefox.enable = lib.mkDefault true; firefox.enable = lib.mkDefault true;
mpv.enable = lib.mkDefault true; mpv.enable = lib.mkDefault true;
nautilus.enable = lib.mkDefault true; nautilus.enable = lib.mkDefault true;
notmuch.enable = lib.mkDefault true;
nsxiv.enable = lib.mkDefault true; nsxiv.enable = lib.mkDefault true;
obsidian.enable = lib.mkDefault true; obsidian.enable = lib.mkDefault true;
rofi.enable = lib.mkDefault true; rofi.enable = lib.mkDefault true;
xclip.enable = lib.mkDefault true;
wezterm.enable = lib.mkDefault true; wezterm.enable = lib.mkDefault true;
xclip.enable = lib.mkDefault true;
zathura.enable = lib.mkDefault true; zathura.enable = lib.mkDefault true;
}; };
services = { services = {

View File

@ -15,25 +15,26 @@ in
home.packages = [ home.packages = [
pkgs.age # Encryption pkgs.age # Encryption
pkgs.bc # Calculator pkgs.bc # Calculator
pkgs.bottom # System monitor (top)
pkgs.delta # Fancy diffs pkgs.delta # Fancy diffs
pkgs.difftastic # Other fancy diffs pkgs.difftastic # Other fancy diffs
pkgs.doggo # DNS client (dig)
pkgs.du-dust # Disk usage tree (ncdu)
pkgs.dua # File sizes (du)
pkgs.duf # Basic disk information (df)
pkgs.jless # JSON viewer pkgs.jless # JSON viewer
pkgs.jo # JSON output pkgs.jo # JSON output
pkgs.mpd # TUI slideshows
pkgs.nmasur.jqr # FZF fq JSON tool
pkgs.nmasur.osc # Clipboard over SSH pkgs.nmasur.osc # Clipboard over SSH
pkgs.qrencode # Generate qr codes
pkgs.nmasur.ren-find # Rename files pkgs.nmasur.ren-find # Rename files
pkgs.nmasur.rep-grep # Replace text in files pkgs.nmasur.rep-grep # Replace text in files
pkgs.pandoc # Convert text documents
pkgs.qrencode # Generate qr codes
pkgs.spacer # Output lines in terminal pkgs.spacer # Output lines in terminal
pkgs.tealdeer # Cheatsheets pkgs.tealdeer # Cheatsheets
pkgs.tree # Print tree in terminal
pkgs.vimv-rs # Batch rename files pkgs.vimv-rs # Batch rename files
pkgs.dua # File sizes (du)
pkgs.du-dust # Disk usage tree (ncdu)
pkgs.duf # Basic disk information (df)
pkgs.pandoc # Convert text documents
pkgs.mpd # TUI slideshows
pkgs.doggo # DNS client (dig)
pkgs.bottom # System monitor (top)
pkgs.nmasur.jqr # FZF fq JSON tool
]; ];
programs.fish.shellAliases = { programs.fish.shellAliases = {

View File

@ -1,4 +1,4 @@
{ lib, ... }: { lib, colorscheme, ... }:
{ {
@ -11,7 +11,7 @@
colors = lib.mkOption { colors = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrs;
description = "Base16 color scheme."; description = "Base16 color scheme.";
default = (import ../../colorscheme/gruvbox).dark; default = colorscheme.gruvbox.dark;
}; };
mode = lib.mkOption { mode = lib.mkOption {
type = lib.types.enum [ type = lib.types.enum [

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

View File

@ -6,6 +6,7 @@
}: }:
let let
inherit (config.nmasur.settings) username;
cfg = config.nmasur.presets.services.dock; cfg = config.nmasur.presets.services.dock;
in in
@ -45,13 +46,13 @@ in
"/Applications/1Password.app" "/Applications/1Password.app"
"${pkgs.slack}/Applications/Slack.app" "${pkgs.slack}/Applications/Slack.app"
"/System/Applications/Calendar.app" "/System/Applications/Calendar.app"
"${pkgs.firefox-bin}/Applications/Firefox.app" "${pkgs.firefox-unwrapped}/Applications/Firefox.app"
"/System/Applications/Messages.app" "/System/Applications/Messages.app"
"/System/Applications/Mail.app" "/System/Applications/Mail.app"
"/Applications/zoom.us.app" "/Applications/zoom.us.app"
"${config.home-manager.users.${username}.programs.ghostty.package}/Applications/Ghostty.app"
"${pkgs.discord}/Applications/Discord.app" "${pkgs.discord}/Applications/Discord.app"
"${pkgs.obsidian}/Applications/Obsidian.app" "${pkgs.obsidian}/Applications/Obsidian.app"
"${pkgs.wezterm}/Applications/WezTerm.app"
]; ];
}; };
}; };

View File

@ -1,24 +0,0 @@
{
config,
lib,
...
}:
let
cfg = config.nmasur.presets.services.nix-daemon;
in
{
options.nmasur.presets.services.nix-daemon.enable = lib.mkEnableOption "Nix garbage collection";
config = lib.mkIf cfg.enable {
services.nix-daemon.enable = true;
nix.gc.interval = {
Hour = 12;
Minute = 15;
Day = 1;
};
};
}

View File

@ -0,0 +1,67 @@
{
config,
pkgs,
lib,
...
}:
let
inherit (config.nmasur.settings) username;
cfg = config.nmasur.presets.services.nix;
in
{
options.nmasur.presets.services.nix.enable = lib.mkEnableOption "Nix settings and presets";
config = lib.mkIf cfg.enable {
nix = {
enable = true;
# Set channel to flake packages, used for nix-shell commands
nixPath = [ "nixpkgs=${pkgs.path}" ];
# For security, only allow specific users
settings.allowed-users = [
"@wheel" # Anyone in the wheel group
username # The current user
];
# Enable features in Nix commands
extraOptions = ''
experimental-features = nix-command flakes
warn-dirty = false
'';
# Set automatic generation cleanup for home-manager
gc = {
automatic = true;
options = "--delete-older-than 10d";
interval = {
Hour = 12;
Minute = 15;
Day = 1;
};
};
settings = {
# Trust users for messing with Nix stuff
trusted-users = [
"root"
"@wheel"
username
];
# Scans and hard links identical files in the store
# Not working with macOS: https://github.com/NixOS/nix/issues/7273
auto-optimise-store = false;
};
};
};
}

View File

@ -14,7 +14,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.pam.enableSudoTouchIdAuth = true; security.pam.services.sudo_local.touchIdAuth = true;
system = { system = {

View File

@ -16,7 +16,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.users."${username}" = { users.users."${username}" = {
# macOS user # macOS user
home = config.home-manager.users.${username}.home.homeDirectory; home = "/Users/${username}";
uid = 502; uid = 502;
# shell = pkgs.fish; # Default shell # shell = pkgs.fish; # Default shell
}; };

View File

@ -14,9 +14,20 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nmasur.presets.programs = { nmasur.presets = {
fish = lib.mkDefault true; programs = {
homebrew = lib.mkDefault true; fish.enable = lib.mkDefault true;
homebrew.enable = lib.mkDefault true;
};
services = {
dock.enable = lib.mkDefault true;
finder.enable = lib.mkDefault true;
hammerspoon.enable = lib.mkDefault true;
menubar.enable = lib.mkDefault true;
nix.enable = lib.mkDefault true;
settings.enable = lib.mkDefault true;
user.enable = lib.mkDefault true;
};
}; };
homebrew.brews = [ homebrew.brews = [
@ -25,20 +36,8 @@ in
homebrew.casks = [ homebrew.casks = [
"scroll-reverser" # Different scroll style for mouse vs. trackpad "scroll-reverser" # Different scroll style for mouse vs. trackpad
"notunes" # Don't launch Apple Music with the play button "notunes" # Don't launch Apple Music with the play button
"topnotch" # Darkens the menu bar to complete black
]; ];
# Include home-manager config in nix-darwin
home-manager = {
sharedModules = [ ../../../../home-manager ];
# Use the system-level nixpkgs instead of Home Manager's
useGlobalPkgs = lib.mkDefault true;
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
# using multiple profiles for one user
useUserPackages = lib.mkDefault true;
};
}; };
} }

View File

@ -1,9 +0,0 @@
{ lib, ... }:
{
imports = lib.pipe (lib.filesystem.listFilesRecursive ./.) [
# Get only files ending in .nix
(builtins.filter (name: lib.hasSuffix ".nix" name))
# Remove this file
(builtins.filter (name: name != ./default.nix))
];
}

Some files were not shown because too many files have changed in this diff Show More