WOW now that's what i call a refactor

main
mat ess 2023-10-25 22:37:42 -04:00
parent 2c0018fdb3
commit 2abcd54653
48 changed files with 1052 additions and 1167 deletions

View File

@ -16,14 +16,6 @@ $ ./result/sw/bin/darwin-rebuild switch --flake .
main entry point and glue for submodules
### default.nix
compatibility for legacy nix tooling, eg `nix-build`
### configs
non-nix configurations
### darwin
[nix-darwin](https://github.com/LnL7/nix-darwin) specific configuration

View File

@ -1,63 +0,0 @@
{ config, pkgs, lib, ... }: {
# Nix configuration ------------------------------------------------------------------------------
nix.settings = {
trusted-substituters = [
"https://cache.nixos.org/"
"https://cache.iog.io"
"https://nix-community.cachix.org"
"https://mat.cachix.org"
"https://helix.cachix.org"
"https://pre-commit-hooks.cachix.org"
"https://iohk.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
"iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo="
];
trusted-users = [ "@admin" ];
# TODO: remove and replace with a launchd job
# see https://github.com/NixOS/nix/issues/7273
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [
"x86_64-darwin"
"aarch64-darwin"
];
};
nix.configureBuildUsers = true;
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Make Fish the default shell
environment.shells = lib.mkForce
(builtins.attrValues { inherit (pkgs) bashInteractive fish zsh; });
programs.fish.enable = true;
programs.fish.useBabelfish = true;
programs.fish.babelfishPackage = pkgs.babelfish;
# Needed to address bug where $PATH is not properly set for fish:
# https://github.com/LnL7/nix-darwin/issues/122
programs.fish.shellInit = ''
for p in (string split : ${config.environment.systemPath})
if not contains $p $fish_user_paths
set -Ua fish_user_paths $p
end
end
'';
environment.variables.SHELL = "/run/current-system/sw/bin/fish";
environment.loginShell = "/run/current-system/sw/bin/fish";
# Install and setup ZSH to work with nix(-darwin) as well
programs.zsh.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}

22
darwin/default.nix Normal file
View File

@ -0,0 +1,22 @@
{ self, config, ... }: {
flake.darwinModules = {
me = let inherit (config.people) me;
in {
home-manager.users.${me} = { imports = [ self.homeModules.darwin ]; };
users.users.${me} = {
name = me;
home = "/Users/${me}";
};
};
default.imports = [
self.darwinModules.home-manager
self.darwinModules.me
self.nixosModules.common
./fish.nix
./fonts.nix
./homebrew.nix
./system-defaults.nix
];
};
}

16
darwin/fish.nix Normal file
View File

@ -0,0 +1,16 @@
{ config, pkgs, lib, ... }: {
environment.variables.SHELL = lib.getExe pkgs.fish;
environment.shells = [ pkgs.fish ];
programs.fish.enable = true;
programs.fish.useBabelfish = true;
programs.fish.babelfishPackage = pkgs.babelfish;
# needed to address bug where $PATH is not properly set for fish:
# https://github.com/LnL7/nix-darwin/issues/122
programs.fish.shellInit = ''
for p in (string split : ${config.environment.systemPath})
if not contains $p $fish_user_paths
set -Ua fish_user_paths $p
end
end
'';
}

17
darwin/fonts.nix Normal file
View File

@ -0,0 +1,17 @@
{ pkgs, ... }: {
fonts.fontDir.enable = true;
# TODO: go back to `with pkgs`?
fonts.fonts = builtins.attrValues {
inherit (pkgs)
# TODO: patch recursive with nerd-font
borg-sans-mono recursive
# code^
ia-writer-family ibm-plex
# hybrid^
inter source-sans-pro source-serif-pro
# display^
;
};
}

10
darwin/games.nix Normal file
View File

@ -0,0 +1,10 @@
{
homebrew.casks = [
# games
"crossover"
"gog-galaxy"
"origin"
"sony-ps-remote-play"
"steam"
];
}

View File

@ -1,27 +0,0 @@
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.terminal-notifier ];
# Fonts
fonts.fontDir.enable = true;
fonts.fonts = with pkgs; [
borg-sans-mono
cascadia-code
ia-writer-family
ibm-plex
inter
recursive
source-sans-pro
source-serif-pro
(nerdfonts.override { fonts = [ "CascadiaCode" ]; })
];
# Keyboard
# system.keyboard.enableKeyMapping = true;
# system.keyboard.remapCapsLockToEscape = true;
# Add ability to used TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true;
}

View File

@ -1,14 +1,8 @@
{ config, pkgs, lib, ... }:
let
inherit (config.users) primaryUser;
caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks;
{ flake, config, lib, ... }:
let caskPresent = cask: builtins.elem cask config.homebrew.casks;
in {
environment.shellInit = ''
eval "$(${config.homebrew.brewPrefix}/brew shellenv fish)"
'';
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-fish
# For some reason if the Fish completions are added at the end of `fish_complete_path` they don't
# for some reason if the Fish completions are added at the end of `fish_complete_path` they don't
# seem to work, but they do work if added at the start.
programs.fish.interactiveShellInit = ''
if test -d (brew --prefix)"/share/fish/completions"
@ -19,92 +13,87 @@ in {
end
'';
homebrew.enable = pkgs.lib.homebrew-enabled;
homebrew.enable = flake.inputs.homebrew-enabled.value;
homebrew.onActivation.autoUpdate = true;
homebrew.onActivation.upgrade = true;
# TODO: open an issue to have this make backup folders?
# homebrew.onActivation.cleanup = "zap";
homebrew.onActivation.cleanup = "uninstall";
homebrew.global.brewfile = true;
homebrew.taps = [
"homebrew/cask-versions"
"homebrew/services"
"nrlquaker/createzap"
"unisonweb/unison"
];
homebrew.taps = [ "homebrew/cask-versions" "homebrew/services" ];
homebrew.masApps = {
Bitwarden = 1352778147;
"Draw Things" = 6444050820;
GrandPerspective = 1111570163;
Reeder = 1529448980;
Spark = 1176895641;
Tailscale = 1475387142;
Xcode = 497799835;
};
# If an app isn't available in the Mac App Store, or the version in the App Store has
# limitiations, e.g., Transmit, install the Homebrew Cask.
homebrew.caskArgs.no_quarantine = true;
homebrew.casks = [
# system tools
"alfred"
"anytype"
"arc"
# "bartender"
# "discord"
# "bartender" -> dozer
"dozer"
"firefox"
"hazeover"
"jitsi-meet"
"itsycal"
"knockknock"
"krita"
# "lagrange"
"lapce"
"logi-options-plus"
"lulu"
"macsvg"
"messenger"
"nova"
# "obsidian"
"orion"
"protonvpn"
"qflipper"
"rectangle"
"remarkable"
# "rectangle" -> yabai
"secretive"
"shortcat"
"signal"
# "slack"
"stay"
"transmission-remote-gui"
"utm"
"yabai"
# "tools for thought"
"anytype"
# design
"krita"
"macsvg"
# browsers
"arc"
"firefox"
"orion"
# messaging apps
"signal"
# editors and IDEs
"lapce"
"zed"
# terminal emulators
"warp"
# peripheral tools
"logi-options-plus"
"qflipper"
"remarkable"
"via"
# "wacom-tablet"
# "zoom"
];
home-manager.users.${primaryUser.username} = let
socket =
"${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in lib.mkIf (caskPresent "secretive" && config ? home-manager) {
home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh = {
enable = true;
matchBlocks."*".extraOptions = { IdentityAgent = socket; };
};
};
# TODO: figure out `brew shellenv` settings
# environment.variables = {
# HOMEBREW_PREFIX = "";
# HOMEBREW_CELLAR = "";
# HOMEBREW_REPOSITORY = "";
# };
# environment.systemPath = [ ];
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be
# installed in `../home/programs.nix` whenever possible.
homebrew.brews = [
"ffmpeg"
"fileicon"
"fzf"
"gifsicle"
"netlify-cli"
"tarsnap"
"unison-language"
"yarn"
];
# configure ssh to use secretive's agent
# TODO: move to module?
home-manager.users.${flake.config.people.me} =
lib.mkIf (caskPresent "secretive" && config ? home-manager) (let
socket =
"${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in {
home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh.matchBlocks = {
"*".extraOptions = { IdentityAgent = socket; };
};
});
}

View File

@ -1,7 +0,0 @@
# See https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./.; }).defaultNix

View File

@ -46,24 +46,39 @@
"type": "github"
}
},
"darwin": {
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1696043447,
"narHash": "sha256-VbJ1dY5pVH2fX1bS+cT2+4+BYEk4lMHRP0+udu9G6tk=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "792c2e01347cb1b2e7ec84a1ef73453ca86537d8",
"lastModified": 1697995812,
"narHash": "sha256-UDlK6p/6vAiVOQ92PR0ySDZBS3yiryrlJpSOw3b9Ito=",
"owner": "nix-community",
"repo": "disko",
"rev": "4122a18340094151d7911e838237ec7627f0d0c5",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"fileicon-src": {
"flake": false,
"locked": {
"lastModified": 1690207317,
"narHash": "sha256-lkDivFJoeebFeA55kHHN9av5N7nz5zUiW+uAw74IM5U=",
"owner": "mklement0",
"repo": "fileicon",
"rev": "9c41a44fac462f66a1194e223aa26e4c3b9b5ae3",
"type": "github"
},
"original": {
"owner": "mklement0",
"repo": "fileicon",
"type": "github"
}
},
@ -115,10 +130,64 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1696343447,
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_2"
},
"locked": {
"lastModified": 1685662779,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
@ -133,16 +202,16 @@
"type": "github"
}
},
"flake-utils_2": {
"flake-utils_3": {
"inputs": {
"systems": "systems_2"
"systems": "systems_3"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@ -175,18 +244,18 @@
"helix": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils_2",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1696255829,
"narHash": "sha256-5XId/8r09qEAyBI8lFq0qpVsEvtdDl6gHkBHmhp/sMA=",
"lastModified": 1697618705,
"narHash": "sha256-BpAFX7mwV4/vpTlMLZtPICKeDPGLx1Q8s3zVZ8IEAkY=",
"owner": "helix-editor",
"repo": "helix",
"rev": "7fbfec766c2ce2570ca4160744723813dbdc3019",
"rev": "e6d2835b0907102831a8979688a8464c064ff842",
"type": "github"
},
"original": {
@ -202,11 +271,11 @@
]
},
"locked": {
"lastModified": 1696145345,
"narHash": "sha256-3dM7I/d4751SLPJah0to1WBlWiyzIiuCEUwJqwBdmr4=",
"lastModified": 1697688028,
"narHash": "sha256-d9CAOd9W2iTrgB31a8Dvyp6Vgn/gxASCNrD4Z9yzUOY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "6f9b5b83ad1f470b3d11b8a9fe1d5ef68c7d0e30",
"rev": "c5c1ea85181d2bb44e46e8a944a8a3f56ad88f19",
"type": "github"
},
"original": {
@ -265,11 +334,11 @@
"kitty-themes": {
"flake": false,
"locked": {
"lastModified": 1694832264,
"narHash": "sha256-dhzYTHaaTrbE5k+xEC01Y9jGb+ZmEyvWMb4a2WWKGCw=",
"lastModified": 1696892900,
"narHash": "sha256-W0K9fA+oTsdIgBwFlBZb2QqSvVSLh4/e5Xp/4rvDeXU=",
"owner": "kovidgoyal",
"repo": "kitty-themes",
"rev": "c9c12d20f83b9536febb21e4b53e176c0ccccb51",
"rev": "2b4f8aa76ff07fde3648c666ed244c914bf0e155",
"type": "github"
},
"original": {
@ -278,13 +347,92 @@
"type": "github"
}
},
"nil": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay_2"
},
"locked": {
"lastModified": 1697710615,
"narHash": "sha256-YL63eoy3C/WeDxwctbv9dJBjqBabx8cO7lVTlVn3FVI=",
"owner": "oxalica",
"repo": "nil",
"rev": "bd93024db616a528473a7210d2756c7118155de9",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "nil",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1697723594,
"narHash": "sha256-W7lTC+kHGS1YCOutGpxUHF0cK66iY/GYr3INaTyVa/I=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "19f75c2b45fbfc307ecfeb9dadc41a4c1e4fb980",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"nixd": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1697038389,
"narHash": "sha256-hbzFPXyQQxJObRdb+CsylUXii29UfFV7866WWgWYs6Y=",
"owner": "nix-community",
"repo": "nixd",
"rev": "29904e121cc775e7caaf4fffa6bc7da09376a43b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixd",
"type": "github"
}
},
"nixos-flake": {
"locked": {
"lastModified": 1691408332,
"narHash": "sha256-0IveIyIFaORG+SzMzXfl9A4IopQ4KDmThDeH34ryL0c=",
"owner": "squirmy",
"repo": "nixos-flake",
"rev": "531043e2c7825406fb271fb831abe656d0997706",
"type": "github"
},
"original": {
"owner": "squirmy",
"repo": "nixos-flake",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1696234590,
"narHash": "sha256-mgOzQYTvaTT4bFopVOadlndy2RPwLy60rDjIWOGujwo=",
"lastModified": 1697730408,
"narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f902cb49892d300ff15cb237e48aa1cad79d68c3",
"rev": "ff0a5a776b56e0ca32d47a4a47695452ec7f7d80",
"type": "github"
},
"original": {
@ -294,34 +442,54 @@
"type": "github"
}
},
"nixpkgs-master": {
"nixpkgs-lib": {
"locked": {
"lastModified": 1696285335,
"narHash": "sha256-dsu/cEULkVLa4u5BEw/ScCsWqN8zTUUk2o02YOb+Y+c=",
"dir": "lib",
"lastModified": 1696019113,
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2e8f277e5252b44d8b6f5c3e16335d8d543b50bf",
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "master",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_2": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1688392541,
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
"lastModified": 1697851979,
"narHash": "sha256-lJ8k4qkkwdvi+t/Xc6Fn74kUuobpu9ynPGxNZR6OwoA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
"rev": "5550a85a087c04ddcace7f892b0bdc9d8bb080c8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-22.11-darwin",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
@ -329,23 +497,19 @@
"pre-commit": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": [
"flake-utils"
],
"flake-utils": "flake-utils_3",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": [
"nixpkgs-stable"
]
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1696158581,
"narHash": "sha256-h0vY4E7Lx95lpYQbG2w4QH4yG5wCYOvPJzK93wVQbT0=",
"lastModified": 1697746376,
"narHash": "sha256-gu77VkgdfaHgNCVufeb6WP9oqFLjwK4jHcoPZmBVF3E=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "033453f85064ccac434dfd957f95d8457901ecd6",
"rev": "8cc349bfd082da8782b989cad2158c9ad5bd70fd",
"type": "github"
},
"original": {
@ -357,18 +521,21 @@
"root": {
"inputs": {
"dark-mode-notify-src": "dark-mode-notify-src",
"darwin": "darwin",
"disko": "disko",
"fileicon-src": "fileicon-src",
"fisher-src": "fisher-src",
"flake-utils": "flake-utils",
"flake-parts": "flake-parts",
"helix": "helix",
"home-manager": "home-manager",
"homebrew-enabled": "homebrew-enabled",
"ia-writer-family-src": "ia-writer-family-src",
"kitty-icon": "kitty-icon",
"kitty-themes": "kitty-themes",
"nil": "nil",
"nix-darwin": "nix-darwin",
"nixd": "nixd",
"nixos-flake": "nixos-flake",
"nixpkgs": "nixpkgs",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"pre-commit": "pre-commit",
"starship-src": "starship-src"
}
@ -398,14 +565,39 @@
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"nil",
"flake-utils"
],
"nixpkgs": [
"nil",
"nixpkgs"
]
},
"locked": {
"lastModified": 1696817516,
"narHash": "sha256-Xt9OY4Wnk9/vuUfA0OHFtmSlaen5GyiS9msgwOz3okI=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "c0df7f2a856b5ff27a3ce314f6d7aacf5fda546f",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"starship-src": {
"flake": false,
"locked": {
"lastModified": 1696143619,
"narHash": "sha256-3YcmrAdrCXU3NZ82swMVL4uhRzM17e9IbLrFeke+6ak=",
"lastModified": 1697690660,
"narHash": "sha256-c2BpZYIJ26xc6rq+rpSKtfyk1/L32PYnH31luK+7kAg=",
"owner": "starship",
"repo": "starship",
"rev": "7e82cb494c540c7a88cf126ec80aeb0f7ce611bc",
"rev": "099539fd1aa2937e9507a318becffcbc685b83b8",
"type": "github"
},
"original": {
@ -443,6 +635,21 @@
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

322
flake.nix
View File

@ -2,254 +2,138 @@
description = "mat's nix configs";
inputs = {
# Package sets
# base inputs
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin";
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
# Flake helpers
flake-utils.url = "github:numtide/flake-utils";
# Environment/system management
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
nix-darwin.url = "github:lnl7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Config "flag" for disabling homebrew
homebrew-enabled.url = "github:boolean-option/true";
# pre-commit and hooks
nixos-flake.url = "github:squirmy/nixos-flake";
# nixos-flake.url = "github:srid/nixos-flake";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.inputs.nixpkgs-stable.follows = "nixpkgs-stable";
pre-commit.inputs.flake-utils.follows = "flake-utils";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
# Extra sources
# "flag" for toggling homebrew operations
# https://www.mat.services/posts/command-line-flake-arguments/
homebrew-enabled.url = "github:boolean-option/true";
# command line text editor
helix.url = "github:helix-editor/helix";
helix.inputs.nixpkgs.follows = "nixpkgs";
# nix language servers
nil.url = "github:oxalica/nil";
nil.inputs.nixpkgs.follows = "nixpkgs";
nixd.url = "github:nix-community/nixd";
nixd.inputs.nixpkgs.follows = "nixpkgs";
# trigger some action when switching between dark and light mode on macOS
dark-mode-notify-src.url = "github:bouk/dark-mode-notify";
dark-mode-notify-src.flake = false;
# modify custom macOS file icons
fileicon-src.url = "github:mklement0/fileicon";
fileicon-src.flake = false;
# iA writer fonts
ia-writer-family-src.url = "github:iaolo/iA-Fonts";
ia-writer-family-src.flake = false;
# alternate kitty terminal icon
kitty-icon.url = "github:DinkDonk/kitty-icon";
kitty-icon.flake = false;
# standard kitty terminal themes
kitty-themes.url = "github:kovidgoyal/kitty-themes";
kitty-themes.flake = false;
# fish shell package manager
fisher-src.url = "github:jorgebucaran/fisher";
fisher-src.flake = false;
# shell prompt
starship-src.url = "github:starship/starship";
starship-src.flake = false;
};
outputs = { self, flake-utils, pre-commit, ... }@inputs:
let
# this is a "functor" that takes an option name
# this allows for creating identical modules
# which can be accessed by appropriate paths darwin or home-manager
mkPrimaryUserModule = import ./modules/mk-primary-user-module.nix;
inherit (inputs.darwin.lib) darwinSystem;
inherit (inputs.nixpkgs.lib) attrValues makeOverridable optionalAttrs;
# Configuration for `nixpkgs`
nixpkgsConfig = {
config = { allowUnfree = true; };
overlays = attrValues self.overlays;
};
homeStateVersion = "22.05";
primaryUserInfo = {
username = "mat";
fullName = "mat ess";
email = "mat@mat.services";
};
workUserInfo = {
username = "mess";
fullName = "Matthew Ess";
email = "mess@yelp.com";
};
# helper for defining nix-darwin systems
mkDarwinSystem = { modules ? [ ], homeModules ? [ ], ... }@args:
import ./lib/mkDarwinSystem.nix self inputs nixpkgsConfig (args // {
inherit homeStateVersion;
modules = attrValues self.darwinModules ++ modules;
homeModules = attrValues self.homeManagerModules ++ homeModules;
});
in {
# `nix-darwin` configs
darwinConfigurations = let
bootstrap-x86 = makeOverridable darwinSystem {
system = "x86_64-darwin";
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
outputs = { self, flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-darwin" "aarch64-linux" ];
imports = [
inputs.nixos-flake.flakeModule
inputs.pre-commit.flakeModule
./darwin
./home
./nixos
./people
./templates
];
flake = {
nixosConfigurations = {
pihole = self.nixos-flake.lib.mkLinuxSystem {
nixpkgs.hostPlatform = "aarch64-linux";
imports = [ self.nixosModules.default ./systems/nixos/pihole.nix ];
};
};
in {
# Mininal configurations to bootstrap systems
inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP
matbook = mkDarwinSystem {
primaryUser = primaryUserInfo;
modules = [{
networking.computerName = "matbook pro m1";
networking.hostName = "matbook";
networking.knownNetworkServices = [ "Wi-Fi" ];
nix.settings.cores = 2;
nix.settings.max-jobs = 4;
homebrew.casks = [
# games
"gog-galaxy"
"origin"
"sony-ps-remote-play"
"steam"
darwinConfigurations = {
matbook = self.nixos-flake.lib.mkMacosSystem {
nixpkgs.hostPlatform = "aarch64-darwin";
imports = [
self.darwinModules.default
./darwin/games.nix
./systems/darwin/m1.nix
];
home-manager.sharedModules = [{
programs.ssh.matchBlocks.remarkable = {
hostname = "10.11.99.1";
user = "root";
port = 22;
};
}];
}];
};
yelpbook-m1 = self.nixos-flake.lib.mkMacosSystem {
nixpkgs.hostPlatform = "aarch64-darwin";
people.me = "mess";
imports = [
self.darwinModules.default
./systems/darwin/m1.nix
./systems/darwin/work.nix
];
};
};
yelpbook-m1 = mkDarwinSystem {
primaryUser = workUserInfo;
modules = [
({ pkgs, lib, ... }: {
users.primaryUser = workUserInfo;
networking.knownNetworkServices = [ "Wi-Fi" ];
nix.settings.cores = 2;
nix.settings.max-jobs = 5;
homebrew.casks = [ "itsycal" ];
home-manager.sharedModules = [{
# TODO: how to remove this entirely?
home.file.".tarsnaprc" = lib.mkForce { text = ""; };
launchd.agents.tarsnap.enable = lib.mkForce false;
home.packages = [ pkgs.yubiswitch ];
programs.ssh.matchBlocks.devbox = {
hostname = "csdev6";
forwardAgent = true;
serverAliveInterval = 120;
};
programs.fish.functions.devbox.body = ''
ssh -t devbox "agenttmux attach; or agenttmux new -s yelp"
'';
# vscode is managed externally at work
programs.vscode.enable = lib.mkForce false;
}];
})
};
perSystem = { self', pkgs, config, ... }:
# formatter for this flake
let formatter = pkgs.nixfmt;
in {
# controls which flake inputs are updated by `nix run .#update`
nixos-flake.primary-inputs = [
# system inputs
"nixpkgs"
"flake-parts"
"nix-darwin"
"home-manager"
"nixos-flake"
# package inputs
"helix"
"nil"
"nixd"
];
};
};
# Overlays --------------------------------------------------------------- {{{
overlays = {
# nixpkgs overlays
pkgs-stable = _: prev: {
pkgs-stable = import inputs.nixpkgs-stable {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-unstable = _: prev: {
pkgs-unstable = import inputs.nixpkgs {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
pkgs-master = _: prev: {
pkgs-master = import inputs.nixpkgs-master {
inherit (prev.stdenv) system;
inherit (nixpkgsConfig) config;
};
};
colors = import ./overlays/colors.nix;
# Overlay useful on Macs with Apple Silicon
apple-silicon = _: prev:
optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
# Add access to x86 packages system is running Apple Silicon
pkgs-x86 = import inputs.nixpkgs {
system = "x86_64-darwin";
inherit (nixpkgsConfig) config;
};
# pre-commit hook configuration
pre-commit.settings.hooks = {
deadnix.enable = true;
nil.enable = true;
nixfmt.enable = true;
statix.enable = true;
};
homebrew-enabled = _: prev:
optionalAttrs prev.stdenv.isDarwin {
lib = prev.lib // {
homebrew-enabled = inputs.homebrew-enabled.value;
};
packages.default = self'.packages.activate;
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
echo 1>&2 "\(^^)/ welcome to the flake \(^^)/"
'';
buildInputs = [ formatter ];
};
extra-pkgs = import ./pkgs { inherit inputs; };
};
# `nix-darwin` configs and modules
darwinModules = {
# configs
bootstrap = import ./darwin/bootstrap.nix;
defaults = import ./darwin/defaults.nix;
general = import ./darwin/general.nix;
homebrew = import ./darwin/homebrew.nix;
# modules
darwin-primary-user = mkPrimaryUserModule "users";
};
# home manager configurations
homeManagerModules = {
# services
dark-mode-notify-service = import ./home/services/dark-mode-notify.nix;
tarsnap-service = import ./home/services/tarsnap.nix;
# etc
files = import ./home/files.nix;
fish = import ./home/fish.nix;
git = import ./home/git.nix;
helix = import ./home/helix.nix;
kitty = import ./home/kitty.nix;
programs = import ./home/programs.nix;
starship = import ./home/starship.nix;
starship-symbols = import ./home/starship-symbols.nix;
# modules
programs-kakoune-extras =
import ./modules/home/programs/kakoune/extras.nix; # currently unused
programs-helix-extras = import ./modules/home/programs/helix/extras.nix;
programs-kitty-extras = import ./modules/home/programs/kitty/extras.nix;
home-primary-user = mkPrimaryUserModule "home";
};
templates = import ./templates;
} // flake-utils.lib.eachDefaultSystem (system: {
legacyPackages =
import inputs.nixpkgs (nixpkgsConfig // { inherit system; });
checks.pre-commit = pre-commit.lib.${system}.run {
src = ./.;
hooks = {
deadnix.enable = true;
nil.enable = true;
nixfmt.enable = true;
statix.enable = true;
inherit formatter;
};
};
devShells = let pkgs = self.legacyPackages.${system};
in {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit) shellHook;
};
# TODO: add utility devShells here
};
});
};
}

28
home/default.nix Normal file
View File

@ -0,0 +1,28 @@
{ self, ... }: {
flake.homeModules = {
common = {
home.enableNixpkgsReleaseCheck = true;
home.stateVersion = "22.05";
imports = [
./extras/helix/auto-theme.nix
./extras/kitty/auto-theme.nix
./extras/kitty/fix-icon.nix
./extras/kitty/nerd-font.nix
./files.nix
./fish.nix
./git.nix
./helix.nix
./kitty.nix
./programs.nix
# ./starship-symbols.nix
./starship.nix
];
};
linux.imports = [ self.homeModules.common ];
darwin.imports = [
self.homeModules.common
./services/dark-mode-notify.nix
./services/tarsnap.nix
];
};
}

View File

@ -1,12 +1,11 @@
{ config, lib, pkgs, ... }:
{ config, pkgs, lib, ... }:
let
cfg = config.programs.helix;
inherit (cfg) extras;
tomlFormat = pkgs.formats.toml { };
inherit (lib) mkIf mkEnableOption mkOption types;
in {
options.programs.helix.extras = {
options.programs.helix = {
autoTheme.enable =
mkEnableOption "Automatically switch helix theme with night mode";
@ -21,12 +20,12 @@ in {
};
};
config = mkIf (cfg.enable && extras.autoTheme.enable) {
config = mkIf (cfg.enable && cfg.autoTheme.enable) {
xdg.configFile = {
"helix/light.toml".source = tomlFormat.generate "helix-autotheme"
(cfg.settings // { theme = extras.autoTheme.light; });
(cfg.settings // { theme = cfg.autoTheme.light; });
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme"
(cfg.settings // { theme = extras.autoTheme.dark; });
(cfg.settings // { theme = cfg.autoTheme.dark; });
};
programs.fish.functions = {

View File

@ -0,0 +1,73 @@
{ config, pkgs, lib, ... }:
let
cfg = config.programs.kitty;
# helper scripts for changing kitty colors
term-background = pkgs.writeShellScriptBin "term-background" ''
# Accepts the name of a theme file in color-pkg
# If shell is running in a Kitty window set the colors.
if [ -n "$KITTY_WINDOW_ID" ]; then
kitty @ --to $KITTY_LISTEN_ON set-colors --all --configured \
${cfg.colors.color-pkg}/"$1".conf &
fi
'';
term-light = pkgs.writeShellScriptBin "term-light" ''
${term-background}/bin/term-background ${cfg.colors.light-name}
'';
term-dark = pkgs.writeShellScriptBin "term-dark" ''
${term-background}/bin/term-background ${cfg.colors.dark-name}
'';
inherit (lib) mkIf mkOption types;
in {
options.programs.kitty = {
colors = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
When enabled, commands <command>term-dark</command> and <command>term-light</command>
will toggle between your dark and a light colors.
There is also <command>term-background</command> which accepts one argument, the name
of the theme.
(Note that the Kitty setting <literal>allow_remote_control = true</literal> is set to
enable this functionality.)
'';
};
color-pkg = mkOption {
type = types.package;
default = pkgs.kitty-colors;
description = "Package from which to load kitty colors.";
};
light-name = mkOption {
type = types.str;
default = "light";
description = "The name to use for the light colorscheme.";
};
dark-name = mkOption {
type = types.str;
default = "dark";
description = "The name to use for the dark colorscheme.";
};
};
};
config = mkIf cfg.enable {
home.packages =
mkIf cfg.colors.enable [ term-light term-dark term-background ];
programs.kitty.settings = mkIf cfg.colors.enable {
allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty";
};
xdg.configFile."kitty/macos-launch-services-cmdline" =
mkIf (pkgs.stdenv.isDarwin && cfg.colors.enable) {
text = "--listen-on unix:/tmp/mykitty";
};
};
}

View File

@ -0,0 +1,40 @@
{ config, pkgs, lib, ... }:
let
cfg = config.programs.kitty;
inherit (lib) hm mkIf mkOption types;
in {
options.programs.kitty.fixIcon = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
When enabled, uses fileicon to fixup the icon.
'';
};
appPath = mkOption {
type = types.str;
default = null;
description = "Path to kitty.app";
};
iconPath = mkOption {
type = types.str;
default = null;
description = "Path to kitty icns";
};
};
config = mkIf cfg.enable {
home.activation = mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
cleanupKittyIcon =
hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
if ${pkgs.fileicon} test ${cfg.fixIcon.appPath};
then
$DRY_RUN_CMD sudo ${pkgs.fileicon} rm ${cfg.fixIcon.appPath}
fi
'';
fixKittyIcon = hm.dag.entryAfter [ "darwinApps" ] ''
$DRY_RUN_CMD sudo ${pkgs.fileicon} set ${cfg.fixIcon.appPath} ${cfg.fixIcon.iconPath}
'';
};
};
}

View File

@ -0,0 +1,28 @@
{ config, lib, ... }:
let
cfg = config.programs.kitty;
inherit (lib) mkIf mkOption types;
in {
options.programs.kitty = {
useSymbolsFromNerdFont = mkOption {
type = types.str;
default = "";
example = "JetBrainsMono Nerd Font";
description = ''
NerdFont patched fonts frequently suffer from rendering issues in terminals. To mitigate
this, we can use a non-NerdFont with Kitty and use the <literal>symbol_map</literal> setting
to tell Kitty to only use a NerdFont for NerdFont symbols.
Set this option the name of an installed NerdFont (the same name you'd use in the
<literal>font_family</literal> setting), to enable this feature.
'';
};
};
config = mkIf cfg.enable {
programs.kitty.settings = mkIf (cfg.useSymbolsFromNerdFont != "") {
# https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
symbol_map =
"U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}";
};
};
}

View File

@ -1,14 +1,13 @@
{ config, ... }: {
# Misc configuration files --------------------------------------------------------------------{{{
{ flake, config, ... }: {
xdg = { enable = true; };
home.file = {
home.file = let inherit (flake.config.people) me users;
in {
".pijulconfig".text = ''
[author]
name = "${config.home.primaryUser.username}"
full_name = "${config.home.primaryUser.fullName}"
email = "${config.home.primaryUser.email}"
name = "${me}"
full_name = "${users.${me}.name}"
email = "${users.${me}.email}"
'';
".tarsnaprc".text = ''
cachedir ${config.xdg.cacheHome}
@ -19,5 +18,4 @@
humanize-numbers
'';
};
# }}}
}

View File

@ -1,30 +1,22 @@
{ config, pkgs, lib, ... }:
{
# Fish Shell
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.fish.enable
{ pkgs, lib, ... }: {
programs.fish.enable = true;
# Add Fish plugins
home.packages = builtins.attrValues {
inherit (pkgs.fishPlugins) autopair-fish colored-man-pages done;
};
programs.fish.plugins = [ pkgs.fishPlugins.fisher ];
xdg.configFile."fish/fish_plugins".text = ''
jorgebucaran/replay.fish
americanhanko/fish-spin
joseluisq/gitnow
fishpkg/fish-humanize-duration
oh-my-fish/plugin-bang-bang
matthewess/fish-autovenv
franciscolourenco/done
Gazorby/fish-abbreviation-tips
jorgebucaran/autopair.fish
jorgebucaran/replay.fish
joseluisq/gitnow
matthewess/fish-autovenv
nbsmokee/fish-spin
oh-my-fish/plugin-bang-bang
PatrickF1/colored_man_pages.fish
'';
# Fish functions ----------------------------------------------------------------------------- {{{
programs.fish.functions = {
# User functions
# user functions
mkdcd = {
argumentNames = [ "target" ];
body = ''
@ -36,69 +28,6 @@
cd $target
'';
};
unz = {
argumentNames = [ "target" ];
body = ''
# strip extensions
string match \*.zip $target; and set target (string split -r -m1 . $target)[1]
unzip -d $target $target
'';
};
# Helpers
# Toggles `$term_background` between "light" and "dark". Other Fish functions trigger when this
# variable changes. We use a universal variable so that all instances of Fish have the same
# value for the variable.
toggle-background.body = ''
if test "$term_background" = light
set -U term_background dark
else
set -U term_background light
end
'';
# Set `$term_background` based on whether macOS is light or dark mode. Other Fish functions
# trigger when this variable changes. We use a universal variable so that all instances of Fish
# have the same value for the variable.
set-background-to-macOS.body = ''
if is-dark-mode
set -U term_background dark
else
set -U term_background light
end
'';
# Set `$term_background` based on an env var.
set-background-to-env = {
argumentNames = [ "env_var" ];
body = ''
switch $$env_var
case 1
echo "Setting dark mode"
set -U term_background dark
case 0
echo "Setting light mode"
set -U term_background light
end
'';
};
# Sets Fish Shell to light or dark colorscheme based on `$term_background`.
set-shell-colors = {
body = ''
# Use correct theme for `btm` and `bat`
if test "$term_background" = light
alias btm "btm --color nord-light"
set -xg BAT_THEME OneHalfLight
else
alias btm "btm --color nord"
set -xg BAT_THEME OneHalfDark
end
# Set LS_COLORS
set -xg LS_COLORS (${pkgs.vivid}/bin/vivid generate one-$term_background)
'';
onVariable = "term_background";
};
from-dir = {
argumentNames = [ "dir" ];
@ -119,68 +48,111 @@
from-nix $editor $file
'';
};
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# light/dark mode helpers
# determine if dark mode is active
is-dark-mode.body = ''
defaults read -g AppleInterfaceStyle &>/dev/null
'';
nix-unfree = {
argumentNames = [ "cmd" ];
# toggles `$term_background` between "light" and "dark". other Fish functions trigger when this
# variable changes. we use a universal variable so that all instances of Fish have the same
# value for the variable.
toggle-background.body = ''
if test "$term_background" = light
set -U term_background dark
else
set -U term_background light
end
'';
# set `$term_background` based on whether macOS is light or dark mode
set-background-to-macOS.body = ''
if is-dark-mode
set -U term_background dark
else
set -U term_background light
end
'';
# set `$term_background` based on an env var
set-background-to-env = {
argumentNames = [ "env_var" ];
body = ''
env NIX_ALLOW_UNFREE=1 nix $cmd --impure
switch $$env_var
case 1
echo "Setting dark mode"
set -U term_background dark
case 0
echo "Setting light mode"
set -U term_background light
end
'';
};
};
# }}}
# Fish configuration ------------------------------------------------------------------------- {{{
# Aliases
programs.fish.shellAliases =
let inherit (config.home.primaryUser) nixConfigDirectory;
in {
# Nix related
from-nix = "from-dir ${nixConfigDirectory}";
# darwin-rebuild build
drb = "from-nix darwin-rebuild build --flake .";
# darwin-rebuild switch full
drsf = "from-nix darwin-rebuild switch --flake .";
# darwin-rebuild switch (no homebrew)
drs =
"from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false";
# edit darwin-rebuild config in code/codium
drc = "code ${nixConfigDirectory}";
# edit darwin-rebuild config in vim
drv = "vim ${nixConfigDirectory}";
# edit darwin-rebuild config in helix
drh = "darwin-rebuild-edit-with hx";
flakeup = "nix flake update ${nixConfigDirectory}/";
nb = "nix build";
nd = "nix develop";
nf = "nix flake";
nr = "nix run";
nru = "nix-unfree run";
ns = "nix search nixpkgs";
nsh = "nix shell";
nshu = "nix-unfree shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
nrpu =
"nix repl --expr '{ pkgs = (import <nixpkgs> { config.allowUnfree = true; }); }' --impure";
# Other
".." = "cd ..";
":q" = "exit";
cat = "${pkgs.bat}/bin/bat --style=plain --paging=never";
du = "${pkgs.du-dust}/bin/dust";
g = "${pkgs.gitAndTools.git}/bin/git";
ls = "${pkgs.eza}/bin/eza";
ll = "ls -l --time-style long-iso --icons";
la = "ll -a";
http = "${pkgs.xh}/bin/xh";
https = "${pkgs.xh}/bin/xhs";
top = "${pkgs.bottom}/bin/btm";
htop = "${pkgs.bottom}/bin/btm";
tb = "toggle-background";
colortest = "${pkgs.terminal-colors}/bin/terminal-colors -o";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
sb = "set-background-to-macOS";
# sets shell utilities to light or dark colorscheme based on `$term_background`.
set-shell-colors = {
body = ''
# Use correct theme for `btm` and `bat`
if test "$term_background" = light
alias btm "btm --color nord-light"
set -xg BAT_THEME OneHalfLight
else
alias btm "btm --color nord"
set -xg BAT_THEME OneHalfDark
end
# Set LS_COLORS
set -xg LS_COLORS (${pkgs.vivid}/bin/vivid generate one-$term_background)
'';
onVariable = "term_background";
};
};
# aliases
# TODO: refactor into abbreviations
programs.fish.shellAliases = let nixConfigDirectory = "~/dotfiles.nix";
in {
# Nix related
from-nix = "from-dir ${nixConfigDirectory}";
# darwin-rebuild build
drb = "from-nix darwin-rebuild build --flake .";
# darwin-rebuild switch full
drsf = "from-nix darwin-rebuild switch --flake .";
# darwin-rebuild switch (no homebrew)
drs = "drsf --override-input homebrew-enabled github:boolean-option/false";
# edit darwin-rebuild config in code/codium
drc = "code ${nixConfigDirectory}";
# edit darwin-rebuild config in (neo)vim
drv = "vim ${nixConfigDirectory}";
# edit darwin-rebuild config in helix
drh = "darwin-rebuild-edit-with hx";
flakeup = "nix flake update ${nixConfigDirectory}/";
nb = "nix build";
nd = "nix develop";
nf = "nix flake";
nr = "nix run";
ns = "nix search nixpkgs";
nsh = "nix shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
# Other
".." = "cd ..";
":q" = "exit";
cat = "${pkgs.bat}/bin/bat --style=plain --paging=never";
du = "${pkgs.du-dust}/bin/dust";
g = "${pkgs.gitAndTools.git}/bin/git";
ls = "${pkgs.eza}/bin/eza";
ll = "ls -l --time-style long-iso --icons";
la = "ll -a";
http = "${pkgs.xh}/bin/xh";
https = "${pkgs.xh}/bin/xhs";
top = "${pkgs.bottom}/bin/btm";
htop = "${pkgs.bottom}/bin/btm";
colortest = "${pkgs.terminal-colors}/bin/terminal-colors -o";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
tb = "toggle-background";
sb = "set-background-to-macOS";
};
# Configuration that should be above `loginShellInit` and `interactiveShellInit`.
programs.fish.shellInit = ''
@ -188,16 +160,10 @@
${lib.optionalString pkgs.stdenv.isDarwin "set-background-to-macOS"}
'';
home.sessionVariables.VIRTUAL_ENV_DISABLE_PROMPT = "true";
programs.fish.interactiveShellInit = ''
set -g fish_greeting (set_color blue)"( ³) "(set_color cyan)"h"(set_color red)"e"(set_color yellow)"l"(set_color green)"l"(set_color magenta)"o "(set_color blue)"( ³)"(set_color normal)
fish_vi_key_bindings
set VIRTUAL_ENV_DISABLE_PROMPT true
bind -M insert ! __history_previous_command
bind -M insert '$' __history_previous_command_arguments
${pkgs.thefuck}/bin/thefuck --alias | source
# Run function to set colors that are dependent on `$term_background` and to register them so
# they are triggered when the relevent event happens or variable changes.
set-shell-colors
${lib.optionalString pkgs.stdenv.isDarwin "set-shell-colors"}
'';
# }}}
}

View File

@ -1,23 +1,19 @@
{ config, ... }:
{
# Git
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.git.enable
# Aliases config imported in flake.
{ flake, ... }:
let inherit (flake.config.people) me users;
in {
programs.git.enable = true;
programs.git.userEmail = config.home.primaryUser.email;
programs.git.userName = config.home.primaryUser.fullName;
programs.git.userEmail = users.${me}.email;
programs.git.userName = users.${me}.name;
programs.git.extraConfig = {
core.editor = "hx";
diff.colorMoved = "default";
pull.rebase = true;
init.defaultBranch = "main";
help.autocorrect = "prompt";
};
programs.git.ignores = [ ".DS_Store" ".direnv" ];
programs.git.ignores = [ ".DS_Store" ".direnv" "result" ];
# Enhanced diffs
programs.git.delta.enable = true;

View File

@ -1,4 +1,4 @@
{
{ pkgs, lib, ... }: {
programs.helix.enable = true;
programs.helix.settings = {
@ -25,11 +25,11 @@
# };
# }];
programs.helix.extras.autoTheme = {
programs.helix.autoTheme = lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
light = "rose_pine_dawn";
dark = "rose_pine";
};
home.sessionVariables = { EDITOR = "hx"; };
home.sessionVariables.EDITOR = "hx";
}

View File

@ -1,41 +1,8 @@
{ pkgs, ... }:
# Let-In --------------------------------------------------------------------------------------- {{{
let
colorsToKitty = colors:
with colors; {
inherit background foreground selection_background selection_foreground
tab_bar_background active_tab_background active_tab_foreground
inactive_tab_background inactive_tab_foreground;
cursor = white;
cursor_text_color = background;
color0 = black;
color8 = black;
color1 = red;
color9 = red;
color2 = green;
color10 = lime;
color3 = yellow;
color11 = orange;
color4 = blue;
color12 = blue;
color5 = magenta;
color13 = magenta;
color6 = cyan;
color14 = cyan;
color7 = white;
color15 = white;
url_color = brightgreen;
};
font = "Rec Mono Duotone";
# }}}
{ pkgs, lib, ... }:
let font = "Rec Mono Duotone";
in {
# Kitty terminal
# https://sw.kovidgoyal.net/kitty/conf.html
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.kitty.enable
programs.kitty.enable = true;
# General config ----------------------------------------------------------------------------- {{{
programs.kitty.settings = {
font_family = font;
bold_font = "${font} Bold";
@ -45,11 +12,9 @@ in {
adjust_line_height = "120%";
disable_ligatures = "cursor"; # disable ligatures when cursor is on them
# Window layout
hide_window_decorations = "titlebar-only";
window_padding_width = "10";
# Tab bar
tab_bar_edge = "top";
tab_bar_style = "powerline";
tab_powerline_style = "angled";
@ -58,25 +23,31 @@ in {
inactive_tab_font_style = "normal";
tab_activity_symbol = "💬";
# Shell integration manually enabled for fish
# shell integration is manually enabled for fish
shell_integration = "disabled";
} // lib.optionalAttrs pkgs.stdenv.isDarwin { macos_option_as_alt = "both"; };
macos_option_as_alt = "both";
programs.fish.interactiveShellInit = ''
# Manually enable shell integration
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
set-term-colors
'';
programs.fish.shellAliases = {
s = "kitty +kitten ssh";
e = "edit-in-kitty";
};
programs.kitty.extras.useSymbolsFromNerdFont = "CaskaydiaCove Nerd Font";
# }}}
# Colors config ------------------------------------------------------------------------------ {{{
programs.kitty.extras.colors = {
programs.kitty.useSymbolsFromNerdFont = "CaskaydiaCove Nerd Font";
programs.kitty.colors = {
enable = true;
dark = colorsToKitty pkgs.lib.colors.tokyonight.dark;
light = colorsToKitty pkgs.lib.colors.tokyonight.light;
color-pkg = pkgs.kitty-themes;
dark-name = "themes/rose-pine";
light-name = "themes/rose-pine-dawn";
};
programs.fish.functions.set-term-colors = {
body = ''
if test "$term_background" = light
@ -87,25 +58,9 @@ in {
'';
onVariable = "term_background";
};
programs.fish.interactiveShellInit = ''
# Set term colors based on value of `$term_background` when shell starts up.
set-term-colors
# Manually enable shell integration
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
'';
programs.fish.shellAliases = {
s = "kitty +kitten ssh";
e = "edit-in-kitty";
};
# }}}
# Fix icon config
programs.kitty.extras.fixIcon = {
programs.kitty.fixIcon = lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
# TODO: use path to kitty package?
appPath = "~/Applications/Home\\ Manager\\ Apps/kitty.app";
iconPath = "${pkgs.kitty-icon}/kitty-dark.icns";
};

View File

@ -1,15 +1,11 @@
{ pkgs, lib, ... }: {
# Programs + packages with configuration --------------------------------------------------------------- {{{
programs = {
# a nicer cat
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.bat.enable
bat = {
enable = true;
config = { style = "auto"; };
};
# Direnv, load and unload environment variables depending on the current directory.
# https://direnv.net
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.direnv.enable
# load and unload environment variables depending on the current directory
direnv = {
enable = true;
nix-direnv.enable = true;
@ -18,27 +14,30 @@
nushell = { enable = true; };
ssh = {
enable = true;
matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin {
UseKeychain = "yes";
AddKeysToAgent = "yes";
matchBlocks = {
"*".extraOptions = lib.mkIf pkgs.stdenv.isDarwin {
UseKeychain = "yes";
AddKeysToAgent = "yes";
};
remarkable = {
hostname = "10.11.99.1";
user = "root";
};
};
};
vscode = {
enable = true;
enable = false;
# extensions = [ pijul-vscode ];
};
zoxide = { enable = true; };
};
# }}}
# Other packages ----------------------------------------------------------------------------- {{{
home.packages = builtins.attrValues ({
inherit (pkgs)
# GUI apps
cinny discord-ptb lagrange obsidian slack zoom-us
# System
# system tools
curl wget
# lightweight session management
abduco
@ -60,16 +59,16 @@
pv
# command line file encryption
rage
# backups for the truly paranoid
tarsnap
# terminal color support testing
terminal-colors
# automatic command line fixes
thefuck
# extract RAR archives
unrar
# extract XZ archives
xz
# Dev stuff
# dev tools
# source code line counter
cloc
# command line tools for digitalocean
@ -91,20 +90,17 @@
# reimplementation of `httpie` in rust
xh
# Useful nix related tools
# useful nix related tools
nixfmt nix-prefetch-git nix-tree
# adding/managing alternative binary caches hosted by Cachix
cachix
# run software from nixpkgs without installing it
comma
# nix language server
nil;
# nix language servers
nil nixd;
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs)
# useful macOS CLI commands
m-cli
# see /overlays/colors.nix
is-dark-mode;
m-cli;
});
# }}}
}

View File

@ -1,6 +1,5 @@
{ config, pkgs, ... }: {
# dark-mode-notify configuration
# {{{
launchd.agents.dark-mode-notify =
let logPath = "${config.xdg.stateHome}/dark-mode-notify";
in {
@ -18,5 +17,4 @@
];
};
};
# }}}
}

View File

@ -1,13 +1,12 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
# tarsnap periodic backup configuration
# {{{
launchd.agents.tarsnap = let
logPath = "${config.xdg.stateHome}/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo
echo "Running tarsnap backup for $date"
/opt/homebrew/bin/tarsnap -c \
${lib.getExe pkgs.tarsnap} -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
-f $(uname -n)-$date \
@ -35,9 +34,7 @@
Minute = 0;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
Program = lib.getExe tarsnapBackup;
};
};
# }}}
}

View File

@ -1,54 +0,0 @@
# taken from https://github.com/malob/nixpkgs/blob/27e04346555277687a60c0168969b3945c2b25ba/lib/mkDarwinSystem.nix
self: inputs: nixpkgs:
{ primaryUser, system ? "aarch64-darwin"
# `nix-darwin` modules to include
, modules ? [ ]
# Additional `nix-darwin` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraModules ? [ ]
# Value for `home-manager`'s `home.stateVersion` option.
, homeStateVersion
# `home-manager` modules to include
, homeModules ? [ ]
# Additional `home-manager` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraHomeModules ? [ ] }:
inputs.darwin.lib.darwinSystem {
inherit system;
modules = modules ++ extraModules ++ [
inputs.home-manager.darwinModules.home-manager
({ config, ... }:
let cfg = config.users.primaryUser;
in {
users.primaryUser = primaryUser;
inherit nixpkgs;
# Support legacy workflows that use `<nixpkgs>` etc.
nix.nixPath = {
nixpkgs = "${inputs.nixpkgs}";
darwin = "${inputs.darwin}";
};
# `home-manager` config
users.users.${cfg.username}.home = cfg.homeDirectory;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${cfg.username} = {
imports = homeModules ++ extraHomeModules;
home.stateVersion = homeStateVersion;
home.primaryUser = primaryUser;
home.homeDirectory = cfg.homeDirectory;
home.enableNixpkgsReleaseCheck = true;
};
# Make sure nixpkgs#pkg refers to this nixpkgs
nix.registry.nixpkgs.flake = inputs.nixpkgs;
# Add this flake to the registry
nix.registry.my.flake = self;
})
];
}

View File

@ -1,80 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.kakoune.extras;
makeKakouneFace = face: name:
let
mkColor = name:
if hasPrefix "#" name then
"rgb:${substring 1 (-1) name}"
else if hasPrefix "!#" name then
"rgba:${substring 2 (-1) name}"
else
name;
value = if isList name then
concatStringsSep "," (map mkColor name)
else
mkColor name;
in "face global ${face} ${value}";
makeKakouneColors = faces:
concatStringsSep "\n"
([ "# Generated by home-manager" ] ++ mapAttrsToList makeKakouneFace faces);
writeKakouneConfig = file: config:
pkgs.writeText file (makeKakouneColors config);
kakoune-colors = {
light = writeKakouneConfig "light.kak" cfg.colors.light;
dark = writeKakouneConfig "dark.kak" cfg.colors.dark;
};
kak-background = pkgs.writeShellScriptBin "kak-background" ''
for session in $(kak -l); do
kak -c $session -e "colorscheme $1;q"
done
'';
kak-light = pkgs.writeShellScriptBin "kak-light" ''
${kak-background}/bin/kak-background light
'';
kak-dark = pkgs.writeShellScriptBin "kak-dark" ''
${kak-background}/bin/kak-background dark
'';
in {
options.programs.kakoune.extras = {
colors = {
enable = mkEnableOption "Custom kakoune color handling";
dark = mkOption {
type = with types; attrsOf (either str (listOf str));
description = "Kakoune dark colors";
};
light = mkOption {
type = with types; attrsOf (either str (listOf str));
description = "Kakoune light colors";
};
};
};
config = mkIf config.programs.kakoune.enable {
home.packages =
mkIf cfg.colors.enable [ kak-light kak-dark kak-background ];
xdg.configFile."kak/colors/light.kak".source = kakoune-colors.light;
xdg.configFile."kak/colors/dark.kak".source = kakoune-colors.dark;
programs.kakoune.extraConfig = ''
eval %sh{
if is-dark-mode; then
echo "colorscheme dark"
else
echo "colorscheme light"
fi
}
'';
};
}

View File

@ -1,165 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.kitty.extras;
# Create a Kitty config string from a Nix set
setToKittyConfig = with generators;
toKeyValue { mkKeyValue = mkKeyValueDefault { } " "; };
# Write a Nix set representing a kitty config into the Nix store
writeKittyConfig = fileName: config:
pkgs.writeTextDir "${fileName}" (setToKittyConfig config);
# Path in Nix store containing light and dark kitty color configs
kitty-colors = pkgs.symlinkJoin {
name = "kitty-colors";
paths = [
(writeKittyConfig "dark.conf" cfg.colors.dark)
(writeKittyConfig "light.conf" cfg.colors.light)
];
};
# Shell scripts for changing Kitty colors
term-background = pkgs.writeShellScriptBin "term-background" ''
# Accepts the name of a theme file in color-pkg
# If shell is running in a Kitty window set the colors.
if [ -n "$KITTY_WINDOW_ID" ]; then
kitty @ --to $KITTY_LISTEN_ON set-colors --all --configured \
${cfg.colors.color-pkg}/"$1".conf &
fi
'';
term-light = pkgs.writeShellScriptBin "term-light" ''
${term-background}/bin/term-background ${cfg.colors.light-name}
'';
term-dark = pkgs.writeShellScriptBin "term-dark" ''
${term-background}/bin/term-background ${cfg.colors.dark-name}
'';
in {
options.programs.kitty.extras = {
colors = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
When enabled, commands <command>term-dark</command> and <command>term-light</command> will
toggle between your dark and a light colors.
<command>term-background</command> which accepts one argument (the value of which should
be <literal>dark</literal> or <literal>light</literal>) is also available.
(Note that the Kitty setting <literal>allow_remote_control = true</literal> is set to
enable this functionality.)
'';
};
dark = mkOption {
type = with types; attrsOf str;
description = ''
Kitty color settings for dark background colorscheme.
'';
};
light = mkOption {
type = with types; attrsOf str;
description = ''
Kitty color settings for light background colorscheme.
'';
};
color-pkg = mkOption {
type = types.package;
default = kitty-colors;
description = "Package from which to load kitty colors.";
};
light-name = mkOption {
type = types.str;
default = "light";
description = "The name to use for the light colorscheme.";
};
dark-name = mkOption {
type = types.str;
default = "dark";
description = "The name to use for the dark colorscheme.";
};
};
useSymbolsFromNerdFont = mkOption {
type = types.str;
default = "";
example = "JetBrainsMono Nerd Font";
description = ''
NerdFont patched fonts frequently suffer from rendering issues in terminals. To mitigate
this, we can use a non-NerdFont with Kitty and use the <literal>symbol_map</literal> setting
to tell Kitty to only use a NerdFont for NerdFont symbols.
Set this option the name of an installed NerdFont (the same name you'd use in the
<literal>font_family</literal> setting), to enable this feature.
'';
};
fixIcon = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
When enabled, uses fileicon (should be installed via homebrew) to fixup the icon.
'';
};
appPath = mkOption {
type = types.str;
default = null;
description = "Path to kitty.app";
};
iconPath = mkOption {
type = types.str;
default = null;
description = "Path to kitty icns";
};
};
};
config = mkIf config.programs.kitty.enable {
home.packages =
mkIf cfg.colors.enable [ term-light term-dark term-background ];
home.activation = let fileicon = "/opt/homebrew/bin/fileicon";
in mkIf (pkgs.stdenv.isDarwin && cfg.fixIcon.enable) {
cleanupKittyIcon =
lib.hm.dag.entryBetween [ "darwinApps" ] [ "writeBoundary" ] ''
if ${fileicon} test ${cfg.fixIcon.appPath};
then
$DRY_RUN_CMD sudo ${fileicon} rm ${cfg.fixIcon.appPath}
fi
'';
fixKittyIcon = lib.hm.dag.entryAfter [ "darwinApps" ] ''
$DRY_RUN_CMD sudo ${fileicon} set ${cfg.fixIcon.appPath} ${cfg.fixIcon.iconPath}
'';
};
programs.kitty.settings = optionalAttrs cfg.colors.enable {
allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty";
} // optionalAttrs (cfg.useSymbolsFromNerdFont != "") {
# https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
symbol_map =
"U+E5FA-U+E62B,U+E700-U+E7C5,U+F000-U+F2E0,U+E200-U+E2A9,U+F500-U+FD46,U+E300-U+E3EB,U+F400-U+F4A8,U+2665,U+26a1,U+F27C,U+E0A3,U+E0B4-U+E0C8,U+E0CA,U+E0CC-U+E0D2,U+E0D4,U+23FB-U+23FE,U+2B58,U+F300-U+F313,U+E000-U+E00D ${cfg.useSymbolsFromNerdFont}";
};
xdg.configFile."kitty/macos-launch-services-cmdline" =
mkIf (pkgs.stdenv.isDarwin && cfg.colors.enable) {
text = "--listen-on unix:/tmp/mykitty";
};
};
}

View File

@ -1,24 +0,0 @@
optionName:
{ config, lib, pkgs, ... }:
let
inherit (lib) mkOption types;
inherit (pkgs.stdenv) isDarwin;
cfg = config.${optionName}.primaryUser;
in {
options.${optionName}.primaryUser = {
username = mkOption { type = types.str; };
fullName = mkOption { type = types.str; };
email = mkOption { type = types.str; };
homeDirectory = mkOption {
type = types.str;
default = let prefix = if isDarwin then "/Users" else "/home";
in "${prefix}/${cfg.username}";
};
nixConfigDirectory = mkOption {
type = types.str;
default = "${cfg.homeDirectory}/dotfiles.nix";
};
};
}

16
nixos/caches/default.nix Normal file
View File

@ -0,0 +1,16 @@
{
nix.settings = {
trusted-substituters = [
"https://cache.nixos.org/"
"https://nix-community.cachix.org"
"https://mat.cachix.org"
"https://helix.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mat.cachix.org-1:AHqv9SoBEPKlJX2DDZQnjaMcvBAgpH1j8rw5USYDZno="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
];
};
}

22
nixos/default.nix Normal file
View File

@ -0,0 +1,22 @@
{ self, config, ... }: {
flake.nixosModules = {
common.imports = [ ./nix.nix ./caches ];
me = let inherit (config.people) me;
in {
home-manager.users.${me} = { imports = [ self.homeModules.linux ]; };
users.users.${me} = {
name = me;
home = "/home/${me}";
isNormalUser = true;
};
};
default.imports = [
self.nixosModules.home-manager
self.nixosModules.me
self.nixosModules.common
./ssh-access.nix
];
};
}

39
nixos/nix.nix Normal file
View File

@ -0,0 +1,39 @@
{ flake, pkgs, lib, ... }: {
nixpkgs = {
config = {
allowBroken = true;
allowUnfree = true;
allowUnsupportedSystem = true;
};
overlays = [
flake.inputs.helix.overlays.default
flake.inputs.nixd.overlays.default
flake.inputs.nil.overlays.nil
(import ../pkgs flake.inputs)
];
};
nix = {
package = pkgs.nixUnstable;
nixPath = {
nixpkgs = "${flake.inputs.nixpkgs}";
darwin = "${flake.inputs.darwin}";
};
registry = {
nixpkgs.flake = flake.inputs.nixpkgs;
self.flake = flake;
};
settings = {
max-jobs = "auto";
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [
"x86_64-darwin"
"aarch64-darwin"
];
# wipe out the registry for purity, cf. https://github.com/MatthewCroughan/nixcfg/commit/ce86bee2755127a4fdaca91e5e037d3fe625cba9
flake-registry = builtins.toFile "empty-flake-registry.json"
''{"flakes":[],"version":2}'';
trusted-users = [ flake.config.people.me "root" "@admin" "@wheel" ];
};
};
}

10
nixos/ssh-access.nix Normal file
View File

@ -0,0 +1,10 @@
{ flake, ... }: {
# remote access
users.users = let
inherit (flake.config) people;
myKeys = people.users.${people.me}.sshKeys;
in {
root.openssh.authorizedKeys.keys = myKeys;
${people.me}.openssh.authorizedKeys.keys = myKeys;
};
}

View File

@ -1,8 +0,0 @@
_final: prev: {
lib = prev.lib // {
colors = { tokyonight = import ./colors/tokyonight.nix; };
};
is-dark-mode = prev.writeShellScriptBin "is-dark-mode" ''
defaults read -g AppleInterfaceStyle &>/dev/null
'';
}

View File

@ -1,48 +0,0 @@
{
dark = {
background = "#1a1b26";
foreground = "#a9b1d6";
selection_background = "#28344a";
selection_foreground = "none";
tab_bar_background = "#101014";
active_tab_background = "#787c99";
active_tab_foreground = "#3d59a1";
inactive_tab_background = "#16161e";
inactive_tab_foreground = "#9aa5ce";
comment = "#565f89";
white = "#c0caf5";
black = "#414868";
red = "#f7768e";
yellow = "#e0af68";
orange = "#ff9e64";
green = "#73daca";
lime = "#2ac3de";
blue = "#7aa2f7";
magenta = "#bb9af7";
cyan = "#7dcfff";
brightgreen = "#9ece6a";
};
light = rec {
background = "#d5d6db";
foreground = white;
selection_background = "#fafbff";
selection_foreground = "none";
tab_bar_background = "#e9e9ed";
active_tab_foreground = "#d4d6e4";
active_tab_background = "#2e7de9";
inactive_tab_foreground = "#8990b3";
inactive_tab_background = "#c4c8da";
comment = "#9699a3";
white = "#343b58";
black = "#0f0f14";
red = "#8c4351";
yellow = "#8f5e15";
orange = white;
green = "#33635c";
lime = "#166775";
blue = "#34548a";
magenta = "#5a4a78";
cyan = "#0f4b6e";
brightgreen = "#485e30";
};
}

20
people/config.nix Normal file
View File

@ -0,0 +1,20 @@
{
me = "mat";
users = {
mat = {
name = "mat ess";
email = "mat@mat.services";
sshKeys = [
# secretive
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKTVoMVtHSvosU9SCam4S5RTP0R2V09vqw5Xiuff+x4J7NtUxsBhqIrkPSfJHSbYlBKITX5RFyFBo5mtsTa95v0= mat"
];
};
mess = {
name = "Matthew Ess";
email = "mess@yelp.com";
sshKeys = [
# TODO: work secretive keys
];
};
};
}

39
people/default.nix Normal file
View File

@ -0,0 +1,39 @@
{ lib, ... }:
let
userSubmodule = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = ''
full name
'';
};
email = lib.mkOption { type = lib.types.str; };
sshKeys = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
SSH public keys
'';
};
};
};
peopleSubmodule = lib.types.submodule {
options = {
users = lib.mkOption { type = lib.types.attrsOf userSubmodule; };
me = lib.mkOption {
type = lib.types.str;
description = ''
The name of the user that represents me.
Admin user in all contexts.
Should be a key into the `users` attribute set.
'';
};
};
};
in {
# TODO: can we hack in an assertion that `me` is a key in `users`?
options = { people = lib.mkOption { type = peopleSubmodule; }; };
config = { people = import ./config.nix; };
}

View File

@ -1,23 +0,0 @@
{ stdenv, fetchurl, undmg, unzip, version ? "2.2.4", ... }:
stdenv.mkDerivation {
inherit version;
pname = "cinny";
nativeBuildInputs = [ undmg unzip ];
src = fetchurl {
url =
"https://github.com/cinnyapp/cinny-desktop/releases/download/v${version}/Cinny_desktop-x86_64.dmg";
sha256 = "sha256-m8sYA7YjvhqGFuU1L1y7BtndHGd6MpuH+hKzPSukxD0=";
};
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r Cinny.app $out/Applications/Cinny.app
runHook postInstall
'';
}

View File

@ -1,19 +1,23 @@
{ stdenv, lib, xcodeenv, dark-mode-notify-src, sdkVersion, ... }:
{ stdenv, lib, xcodeenv, dark-mode-notify-src }:
let
xcode = xcodeenv.composeXcodeWrapper {
version = sdkVersion;
version = "*.*";
xcodeBaseDir = "/Applications/Xcode.app";
};
in stdenv.mkDerivation {
name = "dark-mode-notify";
pname = "dark-mode-notify";
version = dark-mode-notify-src.shortRev;
src = dark-mode-notify-src;
buildPhase = ''
${xcode}/bin/xcrun swift build -c release --disable-sandbox
'';
installPhase = ''
mkdir -p $out/bin
cp .build/release/dark-mode-notify $out/bin
'';
meta.platforms = lib.platforms.darwin;
}

View File

@ -1,19 +1,17 @@
{ inputs }:
_: prev:
{
inputs: self: super: {
inherit (inputs) kitty-icon kitty-themes;
fishPlugins = prev.fishPlugins // {
dark-mode-notify = self.callPackage ./dark-mode-notify.nix {
inherit (inputs) dark-mode-notify-src;
};
fileicon = self.callPackage ./fileicon.nix { inherit (inputs) fileicon-src; };
fishPlugins = super.fishPlugins // {
fisher = {
name = "fisher";
src = inputs.fisher-src;
};
};
helix = inputs.helix.packages.${prev.stdenv.system}.default;
} // builtins.mapAttrs (name: extras:
prev.callPackage (./. + "/${name}.nix")
({ "${name}-src" = inputs."${name}-src"; } // extras)) {
cinny = { };
dark-mode-notify = { sdkVersion = "*.*"; };
ia-writer-family = { };
yubiswitch = { };
}
ia-writer-family = self.callPackage ./ia-writer-family.nix {
inherit (inputs) ia-writer-family-src;
};
yubiswitch = self.callPackage ./yubiswitch.nix { };
}

11
pkgs/fileicon.nix Normal file
View File

@ -0,0 +1,11 @@
{ buildNpmPackage, fileicon-src }:
buildNpmPackage {
pname = "fileicon";
version = fileicon-src.shortRev;
src = fileicon-src;
npmDepsHash = "sha256-xQ/lTXomYARpawiMa8iccpq/7VUo/X/5Exovfjq3XHU=";
meta = { };
}

View File

@ -1,8 +1,7 @@
{ ia-writer-family-src, lib, stdenv }:
let version = "20181224";
in stdenv.mkDerivation {
name = "ia-writer-family-${version}";
{ stdenv, lib, ia-writer-family-src }:
stdenv.mkDerivation {
pname = "ia-writer-family";
version = ia-writer-family-src.shortRev;
src = ia-writer-family-src;
@ -11,9 +10,9 @@ in stdenv.mkDerivation {
cp "iA Writer "{Mono,Duo,Quattro}/Variable/*.ttf $out/share/fonts/truetype/
'';
meta = with lib; {
meta = {
description = "iA Writer Typeface Family";
license = licenses.ofl;
platforms = platforms.all;
license = lib.licenses.ofl;
platforms = lib.platforms.all;
};
}

View File

@ -1,8 +1,9 @@
{ stdenv, fetchurl, undmg, unzip, version ? "0.12", ... }:
stdenv.mkDerivation {
inherit version;
{ stdenv, fetchurl, undmg, unzip }:
let version = "0.16";
in stdenv.mkDerivation {
pname = "yubiswitch";
inherit version;
nativeBuildInputs = [ undmg unzip ];
src = fetchurl {
url =

14
systems/darwin/m1.nix Normal file
View File

@ -0,0 +1,14 @@
{ pkgs, ... }: {
environment.systemPackages = [ pkgs.terminal-notifier ];
# manage build users, package, and daemon
nix.configureBuildUsers = true;
services.nix-daemon.enable = true;
# use TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true;
# used for backwards compatibility, please read the changelog before changing
# $ darwin-rebuild changelog
system.stateVersion = 4;
}

14
systems/darwin/work.nix Normal file
View File

@ -0,0 +1,14 @@
{ pkgs, lib, ... }: {
home-manager.sharedModules = [{
launchd.agents.tarsnap.enable = lib.mkForce false;
home.packages = [ pkgs.yubiswitch ];
programs.ssh.matchBlocks.devbox = {
hostname = "csdev6";
forwardAgent = true;
serverAliveInterval = 120;
};
programs.fish.functions.devbox.body = ''
ssh -t devbox "agenttmux attach; or agenttmux new -s yelp"
'';
}];
}

1
systems/nixos/pihole.nix Normal file
View File

@ -0,0 +1 @@
{ }

View File

@ -1,13 +1,13 @@
let
mkTemplates =
builtins.mapAttrs (name: attrs: attrs // { path = ./. + "/${name}"; });
in mkTemplates {
rust = {
description = "A rust flake template based on flake.parts";
welcomeText = ''
welcome to a new rust project ()
{
flake.templates = {
rust = {
path = ./rust;
description = "A rust flake template based on flake.parts and crane";
welcomeText = ''
welcome to a new rust project ()
run `direnv allow` and `cargo init` to start a new project
'';
run `direnv allow` and `cargo init` to start a new project
'';
};
};
}

View File

@ -5,18 +5,3 @@ Copyright mat ess. All rights reserved.
This software may not be used by anyone, for any reason.
As far as the law allows, this software comes as is, without any warranty or condition, and no contributor will be liable to anyone for any damages related to this software or this license, under any kind of legal claim.
===
this is not a license.
free software as envisioned by rms and gnu has failed to defend the freedom of users.
open source software is a tool for corporate cooption, control, and profit.
software should be written for the benefit of the masses.
if you're still reading this: use, change, or share this code however you want. intellectual property is a farce.
https://asternova.top/LICENSE.txt
https://iliana.fyi/treachery
https://www.boringcactus.com/2021/09/29/anti-license-manifesto.html