Compare commits

...

2 Commits

Author SHA1 Message Date
mat ess 6e6f41f061 Refactor and clean up based on manual testing 2023-11-03 00:34:40 -04:00
mat ess 2abcd54653 WOW now that's what i call a refactor 2023-10-26 21:29:15 -04:00
52 changed files with 1485 additions and 1455 deletions

View File

@ -16,14 +16,6 @@ $ ./result/sw/bin/darwin-rebuild switch --flake .
main entry point and glue for submodules main entry point and glue for submodules
### default.nix
compatibility for legacy nix tooling, eg `nix-build`
### configs
non-nix configurations
### darwin ### darwin
[nix-darwin](https://github.com/LnL7/nix-darwin) specific configuration [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 = {
home = let inherit (config.users) 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.home
self.nixosModules.common
./fish.nix
./fonts.nix
./homebrew.nix
./system-defaults.nix
];
};
}

View File

@ -1,50 +0,0 @@
{
system.defaults.NSGlobalDomain = {
AppleInterfaceStyleSwitchesAutomatically = true;
NSAutomaticCapitalizationEnabled = false;
_HIHideMenuBar = false;
};
# Firewall
system.defaults.alf = {
globalstate = 1;
allowsignedenabled = 1;
allowdownloadsignedenabled = 1;
stealthenabled = 1;
};
# Dock and Mission Control
system.defaults.dock = {
autohide = true;
expose-group-by-app = false;
mru-spaces = false;
tilesize = 80;
# Disable all hot corners
wvous-bl-corner = 1;
wvous-br-corner = 1;
wvous-tl-corner = 1;
wvous-tr-corner = 1;
};
# Finder
system.defaults.finder = {
AppleShowAllExtensions = true;
FXEnableExtensionChangeWarning = true;
};
# Login and lock screen
system.defaults.loginwindow = {
GuestEnabled = false;
DisableConsoleAccess = true;
};
# Spaces
system.defaults.spaces.spans-displays = false;
# Trackpad
system.defaults.trackpad = {
Clicking = true;
TrackpadRightClick = true;
TrackpadThreeFingerDrag = true;
};
}

18
darwin/fish.nix Normal file
View File

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

15
darwin/fonts.nix Normal file
View File

@ -0,0 +1,15 @@
{ pkgs, ... }: {
fonts.fontDir.enable = true;
fonts.fonts = builtins.attrValues {
inherit (pkgs)
borg-sans-mono recursive recursive-patched
# 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,110 +1,84 @@
{ config, pkgs, lib, ... }: { flake, config, ... }: {
let
inherit (config.users) primaryUser;
caskPresent = cask: lib.any (x: x.name == cask) config.homebrew.casks;
in {
environment.shellInit = ''
eval "$(${config.homebrew.brewPrefix}/brew shellenv fish)"
'';
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-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. # seem to work, but they do work if added at the start.
programs.fish.interactiveShellInit = '' programs.fish = {
if test -d (brew --prefix)"/share/fish/completions" shellInit = ''
set -p fish_complete_path (brew --prefix)/share/fish/completions eval "$(${config.homebrew.brewPrefix}/brew shellenv fish)"
end '';
if test -d (brew --prefix)"/share/fish/vendor_completions.d" interactiveShellInit = ''
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d if test -d (brew --prefix)"/share/fish/completions"
end set -p fish_complete_path (brew --prefix)/share/fish/completions
''; end
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
homebrew.enable = pkgs.lib.homebrew-enabled; set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
homebrew.onActivation.autoUpdate = true; end
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.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 homebrew = {
# limitiations, e.g., Transmit, install the Homebrew Cask. enable = flake.inputs.homebrew-enabled.value;
homebrew.caskArgs.no_quarantine = true; onActivation.autoUpdate = true;
homebrew.casks = [ onActivation.upgrade = true;
"alfred" onActivation.cleanup = "uninstall";
"anytype" global.brewfile = true;
"arc"
# "bartender"
# "discord"
"dozer"
"firefox"
"hazeover"
"jitsi-meet"
"knockknock"
"krita"
# "lagrange"
"lapce"
"logi-options-plus"
"lulu"
"macsvg"
"messenger"
"nova"
# "obsidian"
"orion"
"protonvpn"
"qflipper"
"rectangle"
"remarkable"
"secretive"
"shortcat"
"signal"
# "slack"
"stay"
"transmission-remote-gui"
"utm"
"via"
# "wacom-tablet"
# "zoom"
];
home-manager.users.${primaryUser.username} = let taps = [ "homebrew/cask-versions" "homebrew/services" ];
socket =
"${primaryUser.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"; masApps = {
in lib.mkIf (caskPresent "secretive" && config ? home-manager) { Bitwarden = 1352778147;
home.sessionVariables.SSH_AUTH_SOCK = socket; "Draw Things" = 6444050820;
programs.ssh = { GrandPerspective = 1111570163;
enable = true; Reeder = 1529448980;
matchBlocks."*".extraOptions = { IdentityAgent = socket; }; Tailscale = 1475387142;
Xcode = 497799835;
}; };
};
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be caskArgs.no_quarantine = true;
# installed in `../home/programs.nix` whenever possible. casks = [
homebrew.brews = [ # system tools
"ffmpeg" "alfred"
"fileicon" # "bartender" -> dozer
"fzf" "dozer"
"gifsicle" "knockknock"
"netlify-cli" "lulu"
"tarsnap" "protonvpn"
"unison-language" "rectangle"
"yarn" "secretive"
]; "shortcat"
"stay"
"utm"
# "tools for thought"
"anytype"
"obsidian"
# design
"krita"
"macsvg"
# browsers
"arc"
"firefox"
"orion"
# messaging apps
"messenger"
"signal"
# editors and IDEs
"lapce"
"zed"
# terminal emulators
"kitty"
"warp"
# peripheral tools
"logi-options-plus"
"qflipper"
"remarkable"
"via"
];
};
} }

View File

@ -0,0 +1,47 @@
{
system.defaults = {
NSGlobalDomain = {
AppleInterfaceStyleSwitchesAutomatically = true;
NSAutomaticCapitalizationEnabled = false;
_HIHideMenuBar = false;
};
# firewall
alf = {
globalstate = 1;
allowsignedenabled = 1;
allowdownloadsignedenabled = 1;
stealthenabled = 1;
};
dock = {
autohide = true;
expose-group-by-app = false;
mru-spaces = false;
tilesize = 80;
# disable all hot corners
wvous-bl-corner = 1;
wvous-br-corner = 1;
wvous-tl-corner = 1;
wvous-tr-corner = 1;
};
finder = {
AppleShowAllExtensions = true;
FXEnableExtensionChangeWarning = true;
};
loginwindow = {
GuestEnabled = false;
DisableConsoleAccess = true;
};
spaces.spans-displays = false;
trackpad = {
Clicking = true;
TrackpadRightClick = true;
TrackpadThreeFingerDrag = true;
};
};
}

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,40 +46,119 @@
"type": "github" "type": "github"
} }
}, },
"darwin": { "disko": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1696043447, "lastModified": 1698422527,
"narHash": "sha256-VbJ1dY5pVH2fX1bS+cT2+4+BYEk4lMHRP0+udu9G6tk=", "narHash": "sha256-SDu3Xg263t3oXIyTaH0buOvFnKIDeZsvKDBtOz+jRbs=",
"owner": "lnl7", "owner": "nix-community",
"repo": "nix-darwin", "repo": "disko",
"rev": "792c2e01347cb1b2e7ec84a1ef73453ca86537d8", "rev": "944d338d24a9d043a3f7461c30ee6cfe4f9cca30",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "lnl7", "owner": "nix-community",
"ref": "master", "repo": "disko",
"repo": "nix-darwin",
"type": "github" "type": "github"
} }
}, },
"fisher-src": { "fish-plugin-autopair": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1692640630, "lastModified": 1656950411,
"narHash": "sha256-e8gIaVbuUzTwKtuMPNXBT5STeddYqQegduWBtURLT3M=", "narHash": "sha256-qt3t1iKRRNuiLWiVoiAYOu+9E7jsyECyIqZJ/oRIT1A=",
"owner": "jorgebucaran", "owner": "jorgebucaran",
"repo": "fisher", "repo": "autopair.fish",
"rev": "2efd33ccd0777ece3f58895a093f32932bd377b6", "rev": "4d1752ff5b39819ab58d7337c69220342e9de0e2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "jorgebucaran", "owner": "jorgebucaran",
"repo": "fisher", "repo": "autopair.fish",
"type": "github"
}
},
"fish-plugin-colored-man-pages": {
"flake": false,
"locked": {
"lastModified": 1651274650,
"narHash": "sha256-ii9gdBPlC1/P1N9xJzqomrkyDqIdTg+iCg0mwNVq2EU=",
"owner": "PatrickF1",
"repo": "colored_man_pages.fish",
"rev": "f885c2507128b70d6c41b043070a8f399988bc7a",
"type": "github"
},
"original": {
"owner": "PatrickF1",
"repo": "colored_man_pages.fish",
"type": "github"
}
},
"fish-plugin-done": {
"flake": false,
"locked": {
"lastModified": 1698312794,
"narHash": "sha256-7aeSE88tvLx64EWvHqLSikRjOjTrZRXj2fdK5vygsqA=",
"owner": "franciscolourenco",
"repo": "done",
"rev": "054347d2a4aa5e0e7920c850f5999651dc90219c",
"type": "github"
},
"original": {
"owner": "franciscolourenco",
"repo": "done",
"type": "github"
}
},
"fish-plugin-fish-abbr-tips": {
"flake": false,
"locked": {
"lastModified": 1674487577,
"narHash": "sha256-F1t81VliD+v6WEWqj1c1ehFBXzqLyumx5vV46s/FZRU=",
"owner": "Gazorby",
"repo": "fish-abbreviation-tips",
"rev": "8ed76a62bb044ba4ad8e3e6832640178880df485",
"type": "github"
},
"original": {
"owner": "Gazorby",
"repo": "fish-abbreviation-tips",
"type": "github"
}
},
"fish-plugin-fish-bang-bang": {
"flake": false,
"locked": {
"lastModified": 1690139185,
"narHash": "sha256-oPPCtFN2DPuM//c48SXb4TrFRjJtccg0YPXcAo0Lxq0=",
"owner": "oh-my-fish",
"repo": "plugin-bang-bang",
"rev": "ec991b80ba7d4dda7a962167b036efc5c2d79419",
"type": "github"
},
"original": {
"owner": "oh-my-fish",
"repo": "plugin-bang-bang",
"type": "github"
}
},
"fish-plugin-replay": {
"flake": false,
"locked": {
"lastModified": 1655689996,
"narHash": "sha256-bM6+oAd/HXaVgpJMut8bwqO54Le33hwO9qet9paK1kY=",
"owner": "jorgebucaran",
"repo": "replay.fish",
"rev": "bd8e5b89ec78313538e747f0292fcaf631e87bd2",
"type": "github"
},
"original": {
"owner": "jorgebucaran",
"repo": "replay.fish",
"type": "github" "type": "github"
} }
}, },
@ -115,10 +194,64 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1698882062,
"narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
"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": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "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": { "locked": {
"lastModified": 1694529238, "lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
@ -133,16 +266,16 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": { "flake-utils_3": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_3"
}, },
"locked": { "locked": {
"lastModified": 1689068808, "lastModified": 1685518550,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -151,6 +284,21 @@
"type": "github" "type": "github"
} }
}, },
"ghostty": {
"locked": {
"lastModified": 1695482156,
"narHash": "sha256-PFyViLT7eCi/jN6fZ9kFUZF4mYye9Mplm/SEwhUvCDM=",
"owner": "clo4",
"repo": "ghostty-hm-module",
"rev": "3ccb4b02eb84316e7ccbf007a6e29495f7e6bee4",
"type": "github"
},
"original": {
"owner": "clo4",
"repo": "ghostty-hm-module",
"type": "github"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -175,18 +323,18 @@
"helix": { "helix": {
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1696255829, "lastModified": 1698790188,
"narHash": "sha256-5XId/8r09qEAyBI8lFq0qpVsEvtdDl6gHkBHmhp/sMA=", "narHash": "sha256-sAp4RIto3fDjb/HJ4NR3HlHo3J8R7tK4/qSGYkhudUA=",
"owner": "helix-editor", "owner": "helix-editor",
"repo": "helix", "repo": "helix",
"rev": "7fbfec766c2ce2570ca4160744723813dbdc3019", "rev": "a069b928973aad99b85dffb9d5ade7dae4b58c43",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -202,11 +350,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1696145345, "lastModified": 1698873617,
"narHash": "sha256-3dM7I/d4751SLPJah0to1WBlWiyzIiuCEUwJqwBdmr4=", "narHash": "sha256-FfGFcfbULwbK1vD+H0rslIOfmy4g8f2hXiPkQG3ZCTk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "6f9b5b83ad1f470b3d11b8a9fe1d5ef68c7d0e30", "rev": "48b0a30202516e25d9885525fbb200a045f23f26",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -246,45 +394,92 @@
"type": "github" "type": "github"
} }
}, },
"kitty-icon": { "nil": {
"flake": false, "inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay_2"
},
"locked": { "locked": {
"lastModified": 1659349637, "lastModified": 1697710615,
"narHash": "sha256-Vy+iLGnysrJMSLfkaYq15pb/wG4kIbfsXRrPgSc3OFs=", "narHash": "sha256-YL63eoy3C/WeDxwctbv9dJBjqBabx8cO7lVTlVn3FVI=",
"owner": "DinkDonk", "owner": "oxalica",
"repo": "kitty-icon", "repo": "nil",
"rev": "269c0f0bd1c792cebc7821f299ce9250ed9bcd67", "rev": "bd93024db616a528473a7210d2756c7118155de9",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "DinkDonk", "owner": "oxalica",
"repo": "kitty-icon", "repo": "nil",
"type": "github" "type": "github"
} }
}, },
"kitty-themes": { "nix-darwin": {
"flake": false, "inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1694832264, "lastModified": 1698429334,
"narHash": "sha256-dhzYTHaaTrbE5k+xEC01Y9jGb+ZmEyvWMb4a2WWKGCw=", "narHash": "sha256-Gq3+QabboczSu7RMpcy79RSLMSqnySO3wsnHQk4DfbE=",
"owner": "kovidgoyal", "owner": "lnl7",
"repo": "kitty-themes", "repo": "nix-darwin",
"rev": "c9c12d20f83b9536febb21e4b53e176c0ccccb51", "rev": "afe83cbc2e673b1f08d32dd0f70df599678ff1e7",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "kovidgoyal", "owner": "lnl7",
"repo": "kitty-themes", "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": 1698598244,
"narHash": "sha256-YbvPFt+9CbCiqnuS0dTx+P+W1YRCqzhLXen94sef3Kk=",
"owner": "srid",
"repo": "nixos-flake",
"rev": "f6b7757ad88483afca306c9f3bf387887fba7284",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "nixos-flake",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1696234590, "lastModified": 1698890957,
"narHash": "sha256-mgOzQYTvaTT4bFopVOadlndy2RPwLy60rDjIWOGujwo=", "narHash": "sha256-DJ+SppjpPBoJr0Aro9TAcP3sxApCSieY6BYBCoWGUX8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f902cb49892d300ff15cb237e48aa1cad79d68c3", "rev": "c082856b850ec60cda9f0a0db2bc7bd8900d708c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -294,34 +489,54 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-master": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1696285335, "dir": "lib",
"narHash": "sha256-dsu/cEULkVLa4u5BEw/ScCsWqN8zTUUk2o02YOb+Y+c=", "lastModified": 1698611440,
"narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2e8f277e5252b44d8b6f5c3e16335d8d543b50bf", "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735",
"type": "github" "type": "github"
}, },
"original": { "original": {
"dir": "lib",
"owner": "NixOS", "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", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1688392541, "lastModified": 1685801374,
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", "rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-22.11-darwin", "ref": "nixos-23.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -329,23 +544,19 @@
"pre-commit": { "pre-commit": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
"flake-utils": [ "flake-utils": "flake-utils_3",
"flake-utils"
],
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"nixpkgs-stable": [ "nixpkgs-stable": "nixpkgs-stable"
"nixpkgs-stable"
]
}, },
"locked": { "locked": {
"lastModified": 1696158581, "lastModified": 1698852633,
"narHash": "sha256-h0vY4E7Lx95lpYQbG2w4QH4yG5wCYOvPJzK93wVQbT0=", "narHash": "sha256-Hsc/cCHud8ZXLvmm8pxrXpuaPEeNaaUttaCvtdX/Wug=",
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "033453f85064ccac434dfd957f95d8457901ecd6", "rev": "dec10399e5b56aa95fcd530e0338be72ad6462a0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -357,20 +568,27 @@
"root": { "root": {
"inputs": { "inputs": {
"dark-mode-notify-src": "dark-mode-notify-src", "dark-mode-notify-src": "dark-mode-notify-src",
"darwin": "darwin", "disko": "disko",
"fisher-src": "fisher-src", "fish-plugin-autopair": "fish-plugin-autopair",
"flake-utils": "flake-utils", "fish-plugin-colored-man-pages": "fish-plugin-colored-man-pages",
"fish-plugin-done": "fish-plugin-done",
"fish-plugin-fish-abbr-tips": "fish-plugin-fish-abbr-tips",
"fish-plugin-fish-bang-bang": "fish-plugin-fish-bang-bang",
"fish-plugin-replay": "fish-plugin-replay",
"flake-parts": "flake-parts",
"ghostty": "ghostty",
"helix": "helix", "helix": "helix",
"home-manager": "home-manager", "home-manager": "home-manager",
"homebrew-enabled": "homebrew-enabled", "homebrew-enabled": "homebrew-enabled",
"ia-writer-family-src": "ia-writer-family-src", "ia-writer-family-src": "ia-writer-family-src",
"kitty-icon": "kitty-icon", "nil": "nil",
"kitty-themes": "kitty-themes", "nix-darwin": "nix-darwin",
"nixd": "nixd",
"nixos-flake": "nixos-flake",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"pre-commit": "pre-commit", "pre-commit": "pre-commit",
"starship-src": "starship-src" "starship-src": "starship-src",
"terminal-themes": "terminal-themes"
} }
}, },
"rust-overlay": { "rust-overlay": {
@ -398,14 +616,39 @@
"type": "github" "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": { "starship-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1696143619, "lastModified": 1698919886,
"narHash": "sha256-3YcmrAdrCXU3NZ82swMVL4uhRzM17e9IbLrFeke+6ak=", "narHash": "sha256-rV1Sf5MbmHVn8sUEn07STsSdXoPZClTqGp3Tmkvp1+0=",
"owner": "starship", "owner": "starship",
"repo": "starship", "repo": "starship",
"rev": "7e82cb494c540c7a88cf126ec80aeb0f7ce611bc", "rev": "6abc83decdf176842985b4daa5b09771c6b93415",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -443,6 +686,37 @@
"repo": "default", "repo": "default",
"type": "github" "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"
}
},
"terminal-themes": {
"flake": false,
"locked": {
"lastModified": 1697035060,
"narHash": "sha256-Qctds28CIMeyIc6VbWj1jEAlx/HZyBEZJj7u3aZeBog=",
"owner": "mbadolato",
"repo": "iTerm2-Color-Schemes",
"rev": "aed2a8f0565a51913e8ddc1731f25bc71978a1e0",
"type": "github"
},
"original": {
"owner": "mbadolato",
"repo": "iTerm2-Color-Schemes",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

336
flake.nix
View File

@ -2,254 +2,142 @@
description = "mat's nix configs"; description = "mat's nix configs";
inputs = { inputs = {
# Package sets # base inputs
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixpkgs-22.11-darwin"; flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs-master.url = "github:NixOS/nixpkgs/master"; nix-darwin.url = "github:lnl7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# Flake helpers
flake-utils.url = "github:numtide/flake-utils";
# Environment/system management
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager"; home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-flake.url = "github:srid/nixos-flake";
# Config "flag" for disabling homebrew
homebrew-enabled.url = "github:boolean-option/true";
# pre-commit and hooks
pre-commit.url = "github:cachix/pre-commit-hooks.nix"; pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs"; pre-commit.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.inputs.nixpkgs-stable.follows = "nixpkgs-stable"; disko.url = "github:nix-community/disko";
pre-commit.inputs.flake-utils.follows = "flake-utils"; disko.inputs.nixpkgs.follows = "nixpkgs";
ghostty.url = "github:clo4/ghostty-hm-module";
# 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.url = "github:helix-editor/helix";
helix.inputs.nixpkgs.follows = "nixpkgs"; 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.url = "github:bouk/dark-mode-notify";
dark-mode-notify-src.flake = false; dark-mode-notify-src.flake = false;
# iA writer fonts
ia-writer-family-src.url = "github:iaolo/iA-Fonts"; ia-writer-family-src.url = "github:iaolo/iA-Fonts";
ia-writer-family-src.flake = false; ia-writer-family-src.flake = false;
kitty-icon.url = "github:DinkDonk/kitty-icon";
kitty-icon.flake = false; # standard kitty terminal themes
kitty-themes.url = "github:kovidgoyal/kitty-themes"; terminal-themes.url = "github:mbadolato/iTerm2-Color-Schemes";
kitty-themes.flake = false; terminal-themes.flake = false;
fisher-src.url = "github:jorgebucaran/fisher";
fisher-src.flake = false; # shell prompt
starship-src.url = "github:starship/starship"; starship-src.url = "github:starship/starship";
starship-src.flake = false; starship-src.flake = false;
# extra fish shell plugins
fish-plugin-done.url = "github:franciscolourenco/done";
fish-plugin-done.flake = false;
fish-plugin-fish-abbr-tips.url = "github:Gazorby/fish-abbreviation-tips";
fish-plugin-fish-abbr-tips.flake = false;
fish-plugin-autopair.url = "github:jorgebucaran/autopair.fish";
fish-plugin-autopair.flake = false;
fish-plugin-replay.url = "github:jorgebucaran/replay.fish";
fish-plugin-replay.flake = false;
fish-plugin-fish-bang-bang.url = "github:oh-my-fish/plugin-bang-bang";
fish-plugin-fish-bang-bang.flake = false;
fish-plugin-colored-man-pages.url =
"github:PatrickF1/colored_man_pages.fish";
fish-plugin-colored-man-pages.flake = false;
}; };
outputs = { self, flake-utils, pre-commit, ... }@inputs: outputs = { self, flake-parts, ... }@inputs:
let flake-parts.lib.mkFlake { inherit inputs; } {
# this is a "functor" that takes an option name systems = [ "aarch64-darwin" "aarch64-linux" ];
# this allows for creating identical modules imports = [
# which can be accessed by appropriate paths darwin or home-manager inputs.nixos-flake.flakeModule
mkPrimaryUserModule = import ./modules/mk-primary-user-module.nix; inputs.pre-commit.flakeModule
./darwin
inherit (inputs.darwin.lib) darwinSystem; ./home
inherit (inputs.nixpkgs.lib) attrValues makeOverridable optionalAttrs; ./nixos
./templates
# Configuration for `nixpkgs` ./users
nixpkgsConfig = { ];
config = { allowUnfree = true; }; flake = {
overlays = attrValues self.overlays; nixosConfigurations = {
}; # pihole = self.nixos-flake.lib.mkLinuxSystem {
# nixpkgs.hostPlatform = "aarch64-linux";
homeStateVersion = "22.05"; # imports = [ self.nixosModules.default ./systems/nixos/pihole.nix ];
# };
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; } ];
}; };
in {
# Mininal configurations to bootstrap systems
inherit bootstrap-x86;
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
# M1 MBP darwinConfigurations = {
matbook = mkDarwinSystem { matbook = self.nixos-flake.lib.mkMacosSystem {
primaryUser = primaryUserInfo; nixpkgs.hostPlatform = "aarch64-darwin";
modules = [{ imports = [
networking.computerName = "matbook pro m1"; self.darwinModules.default
networking.hostName = "matbook"; ./darwin/games.nix
networking.knownNetworkServices = [ "Wi-Fi" ]; ./systems/darwin/m1.nix
nix.settings.cores = 2;
nix.settings.max-jobs = 4;
homebrew.casks = [
# games
"gog-galaxy"
"origin"
"sony-ps-remote-play"
"steam"
]; ];
home-manager.sharedModules = [{ };
programs.ssh.matchBlocks.remarkable = {
hostname = "10.11.99.1"; yelpbook-m1 = self.nixos-flake.lib.mkMacosSystem {
user = "root"; nixpkgs.hostPlatform = "aarch64-darwin";
port = 22; users.me = "mess";
}; imports = [
}]; self.darwinModules.default
}]; ./systems/darwin/m1.nix
./systems/darwin/work.nix
];
};
}; };
};
yelpbook-m1 = mkDarwinSystem { perSystem = { self', pkgs, config, ... }:
primaryUser = workUserInfo; # formatter for this flake
modules = [ let formatter = pkgs.nixfmt;
({ pkgs, lib, ... }: { in {
users.primaryUser = workUserInfo; # controls which flake inputs are updated by `nix run .#update`
networking.knownNetworkServices = [ "Wi-Fi" ]; nixos-flake.primary-inputs = [
nix.settings.cores = 2; # system inputs
nix.settings.max-jobs = 5; "nixpkgs"
"flake-parts"
homebrew.casks = [ "itsycal" ]; "nix-darwin"
home-manager.sharedModules = [{ "home-manager"
# TODO: how to remove this entirely? "nixos-flake"
home.file.".tarsnaprc" = lib.mkForce { text = ""; }; # package inputs
launchd.agents.tarsnap.enable = lib.mkForce false; "helix"
home.packages = [ pkgs.yubiswitch ]; "nil"
programs.ssh.matchBlocks.devbox = { "nixd"
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;
}];
})
]; ];
};
};
# Overlays --------------------------------------------------------------- {{{ # pre-commit hook configuration
pre-commit.settings.hooks = {
overlays = { deadnix.enable = true;
# nixpkgs overlays nil.enable = true;
pkgs-stable = _: prev: { nixfmt.enable = true;
pkgs-stable = import inputs.nixpkgs-stable { statix.enable = true;
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;
};
}; };
homebrew-enabled = _: prev: packages.default = self'.packages.activate;
optionalAttrs prev.stdenv.isDarwin { devShells.default = pkgs.mkShell {
lib = prev.lib // { shellHook = ''
homebrew-enabled = inputs.homebrew-enabled.value; ${config.pre-commit.installationScript}
}; echo 1>&2 "\(^^)/ welcome to the flake \(^^)/"
'';
buildInputs = [ formatter ];
}; };
inherit 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;
}; };
}; };
devShells = let pkgs = self.legacyPackages.${system};
in {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit) shellHook;
};
# TODO: add utility devShells here
};
});
} }

30
home/default.nix Normal file
View File

@ -0,0 +1,30 @@
{ self, ... }: {
flake.homeModules = {
common = {
home.enableNixpkgsReleaseCheck = true;
home.stateVersion = "22.05";
imports = [
# misc file configuration
./files.nix
# misc program configuration
./programs.nix
# per-program configurations
./fish.nix
./ghostty.nix
./git.nix
./helix.nix
./kitty.nix
./pijul.nix
./ssh.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,32 +1,29 @@
{ config, lib, pkgs, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.programs.helix; cfg = config.programs.helix;
inherit (cfg) extras;
tomlFormat = pkgs.formats.toml { }; tomlFormat = pkgs.formats.toml { };
inherit (lib) mkIf mkEnableOption mkOption types;
in { in {
options.programs.helix.extras = { options.programs.helix = {
autoTheme.enable = autoTheme.enable =
mkEnableOption "Automatically switch helix theme with night mode"; lib.mkEnableOption "Automatically switch helix theme with night mode";
autoTheme.light = mkOption { autoTheme.light = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Light mode theme"; description = "Light mode theme";
}; };
autoTheme.dark = mkOption { autoTheme.dark = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Dark mode theme"; description = "Dark mode theme";
}; };
}; };
config = mkIf (cfg.enable && extras.autoTheme.enable) { config = lib.mkIf (cfg.enable && cfg.autoTheme.enable) {
xdg.configFile = { xdg.configFile = {
"helix/light.toml".source = tomlFormat.generate "helix-autotheme" "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" "helix/dark.toml".source = tomlFormat.generate "helix-autotheme"
(cfg.settings // { theme = extras.autoTheme.dark; }); (cfg.settings // { theme = cfg.autoTheme.dark; });
}; };
programs.fish.functions = { programs.fish.functions = {

View File

@ -0,0 +1,77 @@
{ 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.colors-path}/"$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 = {
colors = {
enable = lib.mkOption {
type = lib.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.)
'';
};
colors-path = lib.mkOption {
type = lib.types.path;
default = "${pkgs.terminal-colors}/kitty";
description = "Path from which to load kitty colors.";
};
color-pkg-path = lib.mkOption {
type = lib.types.optional lib.types.path;
default = null;
description = ''
Path to kitty colors within <literal>color-pkgs</literal>.
'';
};
light-name = lib.mkOption {
type = lib.types.str;
default = "light";
description = "The name to use for the light colorscheme.";
};
dark-name = lib.mkOption {
type = lib.types.str;
default = "dark";
description = "The name to use for the dark colorscheme.";
};
};
};
config = lib.mkIf (cfg.enable && cfg.colors.enable) {
home.packages = [ term-light term-dark term-background ];
programs.kitty.settings = {
allow_remote_control = "yes";
listen_on = "unix:/tmp/mykitty";
};
xdg.configFile."kitty/macos-launch-services-cmdline".text =
lib.mkIf pkgs.stdenv.isDarwin "--listen-on unix:/tmp/mykitty";
};
}

View File

@ -0,0 +1,26 @@
{ config, lib, ... }:
let cfg = config.programs.kitty;
in {
options.programs.kitty = {
useSymbolsFromNerdFont = lib.mkOption {
type = lib.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 = lib.mkIf (cfg.enable && cfg.useSymbolsFromNerdFont != "") {
programs.kitty.settings = {
# 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,23 +1 @@
{ config, ... }: { { xdg.enable = true; }
# Misc configuration files --------------------------------------------------------------------{{{
xdg = { enable = true; };
home.file = {
".pijulconfig".text = ''
[author]
name = "${config.home.primaryUser.username}"
full_name = "${config.home.primaryUser.fullName}"
email = "${config.home.primaryUser.email}"
'';
".tarsnaprc".text = ''
cachedir ${config.xdg.cacheHome}
keyfile ${config.xdg.configHome}/tarsnap/read-write-delete.key
nodump
print-stats
checkpoint-bytes 1G
humanize-numbers
'';
};
# }}}
}

View File

@ -1,203 +1,179 @@
{ config, pkgs, lib, ... }: { pkgs, lib, ... }:
let nixConfigDirectory = "~/dotfiles.nix";
in {
programs.fish = {
enable = true;
{ # see flake.nix and pkgs/default.nix
# Fish Shell plugins = pkgs.fishPlugins.flakePlugins;
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.fish.enable
programs.fish.enable = true;
# Add Fish plugins functions = {
home.packages = builtins.attrValues { # user functions
inherit (pkgs.fishPlugins) autopair-fish colored-man-pages done; mkdcd = {
}; argumentNames = [ "target" ];
programs.fish.plugins = [ pkgs.fishPlugins.fisher ]; body = ''
if test -z "$target"
echo "mkdcd requires an argument" 1>&2
return 1
end
mkdir -p $target
cd $target
'';
};
xdg.configFile."fish/fish_plugins".text = '' from-dir = {
jorgebucaran/replay.fish argumentNames = [ "dir" ];
americanhanko/fish-spin body = ''
joseluisq/gitnow pushd $dir
fishpkg/fish-humanize-duration set -e argv[1]
oh-my-fish/plugin-bang-bang $argv
matthewess/fish-autovenv popd
Gazorby/fish-abbreviation-tips '';
''; };
# Fish functions ----------------------------------------------------------------------------- {{{ darwin-rebuild-edit-with = {
argumentNames = [ "editor" "file" ];
body = ''
if test -z "$file"
set file flake.nix
end
from-nix $editor $file
'';
};
programs.fish.functions = { # TODO: use these to implement !! and .. abbreviations
# User functions # blocked on additional support for abbr in home-manager
mkdcd = { # https://github.com/nix-community/home-manager/issues/3706
argumentNames = [ "target" ]; #
body = '' # taken from
if test -z "$target" # https://fishshell.com/docs/current/relnotes.html#fish-3-6-0-released-january-7-2023
echo "mkdcd requires an argument" 1>&2 # last-history-item.body = ''
return 1 # echo $history[1]
end # '';
mkdir -p $target # multi-cd.body = ''
cd $target # echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)
# '';
} // 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
''; '';
};
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
# 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
# variable changes. We use a universal variable so that all instances of Fish have the same # value for the variable.
# value for the variable. toggle-background.body = ''
toggle-background.body = '' if test "$term_background" = light
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 set -U term_background dark
case 0 else
echo "Setting light mode"
set -U term_background light set -U term_background light
end end
''; '';
};
# Sets Fish Shell to light or dark colorscheme based on `$term_background`. # set `$term_background` based on whether macOS is light or dark mode
set-shell-colors = { set-background-to-macOS.body = ''
body = '' if is-dark-mode
# Use correct theme for `btm` and `bat` set -U term_background dark
if test "$term_background" = light
alias btm "btm --color nord-light"
set -xg BAT_THEME OneHalfLight
else else
alias btm "btm --color nord" set -U term_background light
set -xg BAT_THEME OneHalfDark
end end
# Set LS_COLORS
set -xg LS_COLORS (${pkgs.vivid}/bin/vivid generate one-$term_background)
''; '';
onVariable = "term_background";
# 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 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";
};
}; };
from-dir = { shellAbbrs = {
argumentNames = [ "dir" ]; ".." = "cd ..";
body = ''
pushd $dir
set -e argv[1]
$argv
popd
'';
};
darwin-rebuild-edit-with = { # darwin-rebuild build
argumentNames = [ "editor" "file" ];
body = ''
if test -z "$file"
set file flake.nix
end
from-nix $editor $file
'';
};
nix-unfree = {
argumentNames = [ "cmd" ];
body = ''
env NIX_ALLOW_UNFREE=1 nix $cmd --impure
'';
};
};
# }}}
# 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 ."; drb = "from-nix darwin-rebuild build --flake .";
# darwin-rebuild switch full # darwin-rebuild switch full
drsf = "from-nix darwin-rebuild switch --flake ."; drsf = "from-nix darwin-rebuild switch --flake .";
# darwin-rebuild switch (no homebrew) # darwin-rebuild switch (no homebrew)
drs = drs =
"from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false"; "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 # edit darwin-rebuild config in helix
drh = "darwin-rebuild-edit-with hx"; drh = "darwin-rebuild-edit-with hx";
flakeup = "nix flake update ${nixConfigDirectory}/"; # edit darwin-rebuild config in zed
drz = "zed ${nixConfigDirectory}";
nb = "nix build"; nb = "nix build";
nd = "nix develop"; nd = "nix develop";
nf = "nix flake"; nf = "nix flake";
nfc = "nix flake check";
nfi = "nix flake init";
nfs = "nix flake show";
nfu = "nix flake update";
nr = "nix run"; nr = "nix run";
nru = "nix-unfree run";
ns = "nix search nixpkgs"; ns = "nix search nixpkgs";
nsh = "nix shell"; nsh = "nix shell";
nshu = "nix-unfree shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'"; nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
nrpu = g = "git";
"nix repl --expr '{ pkgs = (import <nixpkgs> { config.allowUnfree = true; }); }' --impure"; stage = "git add .";
commit = "git commit";
# Other push = "git push";
".." = "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 { } // lib.optionalAttrs pkgs.stdenv.isDarwin {
tb = "toggle-background";
sb = "set-background-to-macOS"; sb = "set-background-to-macOS";
}; };
# Configuration that should be above `loginShellInit` and `interactiveShellInit`. shellAliases = {
programs.fish.shellInit = '' # nix related
set -U fish_term24bit 1 from-nix = "from-dir ${nixConfigDirectory}";
${lib.optionalString pkgs.stdenv.isDarwin "set-background-to-macOS"}
'';
programs.fish.interactiveShellInit = '' # other
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) ":q" = "exit";
fish_vi_key_bindings cat = "bat --style=plain --paging=never";
set VIRTUAL_ENV_DISABLE_PROMPT true du = "dust";
bind -M insert ! __history_previous_command http = "xh";
bind -M insert '$' __history_previous_command_arguments https = "xhs";
${pkgs.thefuck}/bin/thefuck --alias | source top = "btm";
# Run function to set colors that are dependent on `$term_background` and to register them so htop = "btm --basic";
# they are triggered when the relevent event happens or variable changes. colortest = "terminal-colors -o";
set-shell-colors };
'';
# }}} # configuration that should be above `loginShellInit` and `interactiveShellInit`.
shellInit = ''
set -U fish_term24bit 1
${lib.optionalString pkgs.stdenv.isDarwin "set-background-to-macOS"}
'';
interactiveShellInit = ''
set -g fish_greeting (set_color red)"( ³)"(set_color yellow)" hello "(set_color blue)"( ³)"(set_color normal)
fish_vi_key_bindings
${lib.optionalString pkgs.stdenv.isDarwin "set-shell-colors"}
'';
};
home.sessionVariables.VIRTUAL_ENV_DISABLE_PROMPT = "true";
} }

32
home/ghostty.nix Normal file
View File

@ -0,0 +1,32 @@
{ flake, pkgs, lib, ... }:
let font = "Rec Mono Duotone";
in {
imports = [ flake.inputs.ghostty.homeModules.default ];
programs.ghostty = {
enable = true;
# ghostty is externally managed for now
package = null;
settings = {
# TODO: auto-theme
config-file = [ "${pkgs.terminal-themes}/ghostty/rose-pine" ];
# TODO: powerline replacements
font-family = font;
font-family-bold = "${font} Bold";
font-family-italic = "${font} Italic";
font-family-bold-italic = "${font} Bold Italic";
font-size = 15;
background-opacity = 0.95;
unfocused-split-opacity = 0.8;
window-decoration = true;
window-padding-x = 10;
window-padding-y = 10;
# use system clipboard on e.g. macOS
copy-on-select = "clipboard";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
background-blur-radius = 20;
macos-non-native-fullscreen = "visible-menu";
macos-option-as-alt = true;
};
};
}

View File

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

View File

@ -1,35 +1,39 @@
{ { pkgs, lib, ... }: {
programs.helix.enable = true; imports = [ ./extras/helix/auto-theme.nix ];
programs.helix = {
enable = true;
defaultEditor = true;
programs.helix.settings = { settings.editor = {
editor.bufferline = "multiple"; bufferline = "multiple";
editor.color-modes = true; color-modes = true;
editor.cursor-shape.insert = "bar"; cursor-shape.insert = "bar";
editor.cursorline = true; cursorline = true;
editor.indent-guides.render = true; indent-guides = {
editor.indent-guides.skip-levels = 1; render = true;
editor.line-number = "relative"; skip-levels = 1;
editor.soft-wrap.enable = true; };
editor.whitespace.render = { line-number = "relative";
space = "none"; soft-wrap.enable = true;
tab = "all"; whitespace.render = {
newline = "all"; space = "none";
tab = "all";
newline = "all";
};
};
# grammars = [{
# name = "lalrpop";
# source = {
# git = "https://github.com/traxys/tree-sitter-lalrpop";
# rev = "7744b56f03ac1e5643fad23c9dd90837fe97291e";
# };
# }];
autoTheme = lib.mkIf pkgs.stdenv.isDarwin {
enable = true;
light = "rose_pine_dawn";
dark = "rose_pine";
}; };
}; };
# programs.helix.grammars = [{
# name = "lalrpop";
# source = {
# git = "https://github.com/traxys/tree-sitter-lalrpop";
# rev = "7744b56f03ac1e5643fad23c9dd90837fe97291e";
# };
# }];
programs.helix.extras.autoTheme = {
enable = true;
light = "rose_pine_dawn";
dark = "rose_pine";
};
home.sessionVariables = { EDITOR = "hx"; };
} }

View File

@ -1,40 +1,10 @@
{ pkgs, ... }: { pkgs, lib, ... }:
# Let-In --------------------------------------------------------------------------------------- {{{ let font = "Rec Mono Duotone";
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";
# }}}
in { in {
# Kitty terminal imports = [ ./extras/kitty/auto-theme.nix ./extras/kitty/nerd-font.nix ];
# https://sw.kovidgoyal.net/kitty/conf.html
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.kitty.enable
programs.kitty.enable = true; programs.kitty.enable = true;
# using kitty from homebrew
# General config ----------------------------------------------------------------------------- {{{ programs.kitty.package = pkgs.emptyDirectory;
programs.kitty.settings = { programs.kitty.settings = {
font_family = font; font_family = font;
@ -45,11 +15,9 @@ in {
adjust_line_height = "120%"; adjust_line_height = "120%";
disable_ligatures = "cursor"; # disable ligatures when cursor is on them disable_ligatures = "cursor"; # disable ligatures when cursor is on them
# Window layout
hide_window_decorations = "titlebar-only"; hide_window_decorations = "titlebar-only";
window_padding_width = "10"; window_padding_width = "10";
# Tab bar
tab_bar_edge = "top"; tab_bar_edge = "top";
tab_bar_style = "powerline"; tab_bar_style = "powerline";
tab_powerline_style = "angled"; tab_powerline_style = "angled";
@ -58,25 +26,30 @@ in {
inactive_tab_font_style = "normal"; inactive_tab_font_style = "normal";
tab_activity_symbol = "💬"; tab_activity_symbol = "💬";
# Shell integration manually enabled for fish # shell integration is manually enabled for fish
shell_integration = "disabled"; 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"; programs.kitty.useSymbolsFromNerdFont = "CaskaydiaCove Nerd Font";
# }}} programs.kitty.colors = {
# Colors config ------------------------------------------------------------------------------ {{{
programs.kitty.extras.colors = {
enable = true; enable = true;
dark = colorsToKitty pkgs.lib.colors.tokyonight.dark; dark-name = "rose-pine";
light = colorsToKitty pkgs.lib.colors.tokyonight.light; light-name = "rose-pine-dawn";
color-pkg = pkgs.kitty-themes;
dark-name = "themes/rose-pine";
light-name = "themes/rose-pine-dawn";
}; };
programs.fish.functions.set-term-colors = { programs.fish.functions.set-term-colors = {
body = '' body = ''
if test "$term_background" = light if test "$term_background" = light
@ -87,26 +60,4 @@ in {
''; '';
onVariable = "term_background"; 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 = {
enable = true;
appPath = "~/Applications/Home\\ Manager\\ Apps/kitty.app";
iconPath = "${pkgs.kitty-icon}/kitty-dark.icns";
};
} }

19
home/pijul.nix Normal file
View File

@ -0,0 +1,19 @@
{ flake, pkgs, ... }:
let
inherit (flake.config.users) me me';
tomlFormat = pkgs.formats.toml { };
in {
home = {
packages = [ pkgs.pijul ];
file = {
# hardcode .config because pijul doesn't support XDG (yet?)
".config/pijul/config.toml".source = tomlFormat.generate "pijul-config" {
author = {
name = me;
full_name = me'.name;
inherit (me') email;
};
};
};
};
}

View File

@ -1,110 +1,119 @@
{ pkgs, lib, ... }: { { 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
direnv = {
enable = true;
nix-direnv.enable = true;
};
nix-index = { enable = true; };
nushell = { enable = true; };
ssh = {
enable = true;
matchBlocks."*".extraOptions = lib.optionalAttrs pkgs.stdenv.isDarwin {
UseKeychain = "yes";
AddKeysToAgent = "yes";
};
};
vscode = {
enable = true;
# extensions = [ pijul-vscode ];
};
zoxide = { enable = true; };
};
# }}}
# Other packages ----------------------------------------------------------------------------- {{{
home.packages = builtins.attrValues ({ home.packages = builtins.attrValues ({
inherit (pkgs) inherit (pkgs)
# GUI apps # GUI apps
cinny discord-ptb lagrange obsidian slack zoom-us discord-ptb obsidian slack zoom-us
# System # system tools
curl wget curl wget
# lightweight session management # `tmux` session alternative
abduco abduco
# archive tool # archive tool
atool atool
# fancy version of `top` with ASCII graphs # `top` alternative with ASCII graphs
bottom bottom
# fancy version of `du` # `ncdu` alternative
diskonaut
# `dig` alternative. dogs _can_ look up
dogdns
# `du` alternative
du-dust du-dust
# fancy version of `ls`, fork of now-unmaintained `exa` # `find` alternative
eza
# fancy version of `find`
fd fd
# wrapper for `ssh` that better at not dropping connections # `ping` with a graph
mosh gping
# fancy version of `ps` # `ps` alternative
procs procs
# pipe progress viewer # pipe progress viewer
pv pv
# command line file encryption # command line file encryption
rage rage
# `sed` alternative for _batch file_ edits
sad
# `sed` alternative for _stream_ edits
sd
# backups for the truly paranoid
tarsnap
# terminal color support testing # terminal color support testing
terminal-colors terminal-colors
# automatic command line fixes
thefuck
# extract RAR archives # extract RAR archives
unrar unrar
# extract XZ archives # extract XZ archives
xz xz
# `tmux` multiplexing/layout alternative
zellij
# Dev stuff # dev platforms
# source code line counter
cloc
# command line tools for digitalocean
doctl
# command line tools for fly.io # command line tools for fly.io
flyctl flyctl
# command line tools for netlify
netlify-cli
# dev tools
# session recording
asciinema
# benchmarking tool # benchmarking tool
hyperfine hyperfine
# json processor
jq
# task runner # task runner
just just
# alternative to `git` # source code line counter
pijul tokei
# better version of `grep`
ripgrep
# rust implementation of `tldr`
tealdeer
# reimplementation of `httpie` in rust # reimplementation of `httpie` in rust
xh xh
# Useful nix related tools # useful nix related tools
nixfmt nix-prefetch-git nix-tree nix-prefetch-git nix-tree
# adding/managing alternative binary caches hosted by Cachix # adding/managing alternative binary caches hosted by Cachix
cachix cachix
# run software from nixpkgs without installing it # run software from nixpkgs without installing it
comma comma
# nix language server # nix language servers
nil; nil nixd;
} // lib.optionalAttrs pkgs.stdenv.isDarwin { } // lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs) inherit (pkgs)
# useful macOS CLI commands # useful macOS CLI commands
m-cli m-cli;
# see /overlays/colors.nix
is-dark-mode;
}); });
# }}}
programs = {
# `cat` with wings
bat = {
enable = true;
config = { style = "auto"; };
};
# load and unload environment variables depending on the current directory
direnv = {
enable = true;
nix-direnv.enable = true;
};
# fork of `exa`, an `ls` alternative
eza = {
enable = true;
enableAliases = true;
icons = true;
git = true;
extraOptions = [ "--group-directories-first" ];
};
jq.enable = true;
man = {
enable = true;
generateCaches = true;
};
nix-index.enable = true;
nushell.enable = true;
# `grep` alternative
ripgrep.enable = true;
# cli help, `tldr` implementation
tealdeer = {
enable = true;
settings = {
display.use_pager = true;
updates.auto_update = true;
updates.auto_update_interval_hours = 24 * 7;
};
};
# `z` alternative
zoxide.enable = true;
};
} }

View File

@ -1,6 +1,5 @@
{ config, pkgs, ... }: { { config, pkgs, lib, ... }: {
# dark-mode-notify configuration # dark-mode-notify configuration
# {{{
launchd.agents.dark-mode-notify = launchd.agents.dark-mode-notify =
let logPath = "${config.xdg.stateHome}/dark-mode-notify"; let logPath = "${config.xdg.stateHome}/dark-mode-notify";
in { in {
@ -11,12 +10,11 @@
StandardErrorPath = "${logPath}/error.log"; StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log"; StandardOutPath = "${logPath}/out.log";
ProgramArguments = [ ProgramArguments = [
"${pkgs.dark-mode-notify}/bin/dark-mode-notify" "${lib.getExe pkgs.dark-mode-notify}"
"${pkgs.fish}/bin/fish" "${lib.getExe pkgs.fish}"
"-c" "-c"
"set-background-to-env DARKMODE" "set-background-to-env DARKMODE"
]; ];
}; };
}; };
# }}}
} }

View File

@ -1,13 +1,21 @@
{ config, pkgs, ... }: { { config, pkgs, lib, ... }: {
# set configuration in ~ so tarsnap cli works interactively
home.file.".tarsnaprc".text = ''
cachedir ${config.xdg.cacheHome}
keyfile ${config.xdg.configHome}/tarsnap/read-write-delete.key
nodump
print-stats
checkpoint-bytes 1G
humanize-numbers
'';
# tarsnap periodic backup configuration # tarsnap periodic backup configuration
# {{{
launchd.agents.tarsnap = let launchd.agents.tarsnap = let
logPath = "${config.xdg.stateHome}/tarsnap"; logPath = "${config.xdg.stateHome}/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" '' tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
date=$(date -u +%Y-%m-%dT%H:%M:%SZ) date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo echo
echo "Running tarsnap backup for $date" echo "Running tarsnap backup for $date"
/opt/homebrew/bin/tarsnap -c \ ${lib.getExe pkgs.tarsnap} -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \ --configfile ${config.home.homeDirectory}/.tarsnaprc \
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \ --keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
-f $(uname -n)-$date \ -f $(uname -n)-$date \
@ -19,25 +27,14 @@
Label = "com.tarsnap.tarsnap"; Label = "com.tarsnap.tarsnap";
StandardErrorPath = "${logPath}/error.log"; StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log"; StandardOutPath = "${logPath}/out.log";
StartCalendarInterval = [ StartCalendarInterval = [{
{ # every sunday
# every sunday Weekday = 0;
Weekday = 0; # at midnight
# at midnight Hour = 0;
Hour = 0; Minute = 0;
Minute = 0; }];
} Program = lib.getExe tarsnapBackup;
{
# every wednesday
Weekday = 3;
# at noon
Hour = 12;
Minute = 0;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
}; };
}; };
# }}}
} }

23
home/ssh.nix Normal file
View File

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
socket =
"${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
in {
home.sessionVariables.SSH_AUTH_SOCK = socket;
programs.ssh = {
enable = true;
matchBlocks = {
# use the keychain on macOS
"*".extraOptions = lib.mkIf pkgs.stdenv.isDarwin {
UseKeychain = "yes";
AddKeysToAgent = "yes";
IdentityAgent = socket;
};
# entry for easy access to reMarkable tablet
remarkable = {
hostname = "10.11.99.1";
user = "root";
};
};
};
}

View File

@ -1,22 +1,29 @@
{ {
# Starship Prompt programs.starship = {
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.starship.enable enable = true;
programs.starship.enable = true; settings = {
battery.display = [{
# Starship settings -------------------------------------------------------------------------- {{{ # display battery information if charge is <= 25%
threshold = 25;
programs.starship.settings = { }];
# See docs here: https://starship.rs/config/ # turn on fish directory truncation
# Symbols config configured in Flake. directory.fish_style_pwd_dir_length = 1;
# number of directories not to truncate
battery.display = [{ directory.truncation_length = 2;
threshold = 25; # because it includes cached memory it's reported as full a lot
} # display battery information if charge is <= 25% memory_usage.disabled = true;
]; };
directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation
directory.truncation_length = 2; # number of directories not to truncate
memory_usage.disabled =
true; # because it includes cached memory it's reported as full a lot
}; };
# }}} # TODO: investigate how to get cmd_duration to show up in transient prompt
# transient prompt
# programs.starship.enableTransience = true;
# programs.fish.functions = {
# starship_transient_prompt_func.body = ''
# starship module directory
# starship module cmd_duration
# starship module line_break
# starship module character
# starship module line_break
# '';
# };
} }

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 ];
home = let inherit (config.users) 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.home
self.nixosModules.common
./ssh-access.nix
];
};
}

40
nixos/nix.nix Normal file
View File

@ -0,0 +1,40 @@
{ 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}";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin = "${flake.inputs.nix-darwin}";
};
registry = {
nixpkgs.flake = flake.inputs.nixpkgs;
self.flake = flake.inputs.self;
};
settings = {
# TODO: automatic optimizing and gc
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.users.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.users) me me';
myKeys = me'.sshKeys;
in {
root.openssh.authorizedKeys.keys = myKeys;
${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";
};
}

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

View File

@ -1,19 +1,22 @@
{ inputs }: inputs: self: super: {
_: prev: inherit (inputs) terminal-themes;
{ dark-mode-notify = self.callPackage ./dark-mode-notify.nix {
inherit (inputs) kitty-icon kitty-themes; inherit (inputs) dark-mode-notify-src;
fishPlugins = prev.fishPlugins // {
fisher = {
name = "fisher";
src = inputs.fisher-src;
};
}; };
helix = inputs.helix.packages.${prev.stdenv.system}.default; # get flake inputs prefixed with fish-plugin- and inject them into fishPlugins as a single list
} // builtins.mapAttrs (name: extras: fishPlugins = super.fishPlugins // {
prev.callPackage (./. + "/${name}.nix") flakePlugins = let
({ "${name}-src" = inputs."${name}-src"; } // extras)) { srcs =
cinny = { }; self.lib.filterAttrs (input: _: self.lib.hasPrefix "fish-plugin-" input)
dark-mode-notify = { sdkVersion = "*.*"; }; inputs;
ia-writer-family = { }; in self.lib.mapAttrsToList (input: src: {
yubiswitch = { }; name = self.lib.removePrefix "fish-plugin-" input;
} inherit src;
}) srcs;
};
ia-writer-family = self.callPackage ./ia-writer-family.nix {
inherit (inputs) ia-writer-family-src;
};
recursive-patched = self.callPackage ./recursive-patched.nix { };
yubiswitch = self.callPackage ./yubiswitch.nix { };
}

View File

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

View File

@ -0,0 +1,10 @@
{ nerd-font-patcher, stdenv, recursive }:
stdenv.mkDerivation {
name = "recursive-nerd-font-patched";
src = recursive;
nativeBuildInputs = [ nerd-font-patcher ];
buildPhase = ''
find -name RecMono\*.ttf -execdir nerd-font-patcher -c {} \;
'';
installPhase = "cp -a . $out";
}

View File

@ -1,8 +1,9 @@
{ stdenv, fetchurl, undmg, unzip, version ? "0.12", ... }: { lib, stdenv, fetchurl, undmg, unzip }:
let version = "0.16";
stdenv.mkDerivation { in stdenv.mkDerivation {
inherit version;
pname = "yubiswitch"; pname = "yubiswitch";
inherit version;
nativeBuildInputs = [ undmg unzip ]; nativeBuildInputs = [ undmg unzip ];
src = fetchurl { src = fetchurl {
url = url =
@ -20,4 +21,6 @@ stdenv.mkDerivation {
runHook postInstall runHook postInstall
''; '';
meta.platforms = lib.platforms.darwin;
} }

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

@ -0,0 +1,20 @@
{ pkgs, ... }: {
environment.systemPackages = [ pkgs.terminal-notifier ];
# networking settings
# TODO: do we need to add Tailscale, ProtonVPN, RNDIS (reMarkable), etc?
networking.knownNetworkServices =
[ "USB 10/100/1000 LAN" "Wi-Fi" "Thunderbolt Bridge" ];
# TODO: where / how to configure hostname etc?
# 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;
}

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

@ -0,0 +1,15 @@
{ pkgs, lib, ... }: {
homebrew.casks = [ "itsycal" ];
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"
'';
}];
}

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

@ -0,0 +1,9 @@
{ flake, ... }: {
imports = [ flake.inputs.disko.nixosModules.disko ];
disko.devices.disk = { };
# read why this matters:
# https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion
system.stateVersion = "23.11";
}

View File

@ -1,13 +1,13 @@
let {
mkTemplates = flake.templates = {
builtins.mapAttrs (name: attrs: attrs // { path = ./. + "/${name}"; }); rust = {
in mkTemplates { path = ./rust;
rust = { description = "A rust flake template based on flake.parts and crane";
description = "A rust flake template based on flake.parts"; welcomeText = ''
welcomeText = '' welcome to a new rust project ()
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. 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. 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

20
users/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
];
};
};
}

50
users/default.nix Normal file
View File

@ -0,0 +1,50 @@
{ config, 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
'';
};
};
};
usersSubmodule = 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.
'';
};
me' = lib.mkOption {
type = userSubmodule;
description = ''
The rest of the user data for `me`.
'';
readOnly = true;
};
};
};
in {
# TODO: can we hack in an assertion that `me` is a key in `users`?
options = { users = lib.mkOption { type = usersSubmodule; }; };
config = {
users = (import ./config.nix) // {
me' = lib.mkDefault config.users.users.${config.users.me};
};
};
}