From 2abcd5465375fb78acfb21e8699a2dc643294818 Mon Sep 17 00:00:00 2001 From: mat ess Date: Wed, 25 Oct 2023 22:37:42 -0400 Subject: [PATCH] WOW now that's what i call a refactor --- README.md | 8 - darwin/bootstrap.nix | 63 ---- darwin/default.nix | 22 ++ darwin/fish.nix | 16 + darwin/fonts.nix | 17 + darwin/games.nix | 10 + darwin/general.nix | 27 -- darwin/homebrew.nix | 123 +++---- darwin/{defaults.nix => system-defaults.nix} | 0 default.nix | 7 - flake.lock | 311 ++++++++++++++--- flake.nix | 322 ++++++------------ home/default.nix | 28 ++ .../extras/helix/auto-theme.nix | 11 +- home/extras/kitty/auto-theme.nix | 73 ++++ home/extras/kitty/fix-icon.nix | 40 +++ home/extras/kitty/nerd-font.nix | 28 ++ home/files.nix | 14 +- home/fish.nix | 256 ++++++-------- home/git.nix | 16 +- home/helix.nix | 6 +- home/kitty.nix | 85 ++--- home/programs.nix | 42 ++- home/services/dark-mode-notify.nix | 2 - home/services/tarsnap.nix | 9 +- lib/mkDarwinSystem.nix | 54 --- modules/home/programs/kakoune/extras.nix | 80 ----- modules/home/programs/kitty/extras.nix | 165 --------- modules/mk-primary-user-module.nix | 24 -- nixos/caches/default.nix | 16 + nixos/default.nix | 22 ++ nixos/nix.nix | 39 +++ nixos/ssh-access.nix | 10 + overlays/colors.nix | 8 - overlays/colors/tokyonight.nix | 48 --- people/config.nix | 20 ++ people/default.nix | 39 +++ pkgs/cinny.nix | 23 -- pkgs/dark-mode-notify.nix | 12 +- pkgs/default.nix | 24 +- pkgs/fileicon.nix | 11 + pkgs/ia-writer-family.nix | 15 +- pkgs/yubiswitch.nix | 9 +- systems/darwin/m1.nix | 14 + systems/darwin/work.nix | 14 + systems/nixos/pihole.nix | 1 + templates/default.nix | 20 +- templates/rust/LICENSE.txt | 15 - 48 files changed, 1052 insertions(+), 1167 deletions(-) delete mode 100644 darwin/bootstrap.nix create mode 100644 darwin/default.nix create mode 100644 darwin/fish.nix create mode 100644 darwin/fonts.nix create mode 100644 darwin/games.nix delete mode 100644 darwin/general.nix rename darwin/{defaults.nix => system-defaults.nix} (100%) delete mode 100644 default.nix create mode 100644 home/default.nix rename modules/home/programs/helix/extras.nix => home/extras/helix/auto-theme.nix (79%) create mode 100644 home/extras/kitty/auto-theme.nix create mode 100644 home/extras/kitty/fix-icon.nix create mode 100644 home/extras/kitty/nerd-font.nix delete mode 100644 lib/mkDarwinSystem.nix delete mode 100644 modules/home/programs/kakoune/extras.nix delete mode 100644 modules/home/programs/kitty/extras.nix delete mode 100644 modules/mk-primary-user-module.nix create mode 100644 nixos/caches/default.nix create mode 100644 nixos/default.nix create mode 100644 nixos/nix.nix create mode 100644 nixos/ssh-access.nix delete mode 100644 overlays/colors.nix delete mode 100644 overlays/colors/tokyonight.nix create mode 100644 people/config.nix create mode 100644 people/default.nix delete mode 100644 pkgs/cinny.nix create mode 100644 pkgs/fileicon.nix create mode 100644 systems/darwin/m1.nix create mode 100644 systems/darwin/work.nix create mode 100644 systems/nixos/pihole.nix diff --git a/README.md b/README.md index a6e196f..b27213a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/darwin/bootstrap.nix b/darwin/bootstrap.nix deleted file mode 100644 index 627a143..0000000 --- a/darwin/bootstrap.nix +++ /dev/null @@ -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; - -} diff --git a/darwin/default.nix b/darwin/default.nix new file mode 100644 index 0000000..28e70de --- /dev/null +++ b/darwin/default.nix @@ -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 + ]; + }; +} diff --git a/darwin/fish.nix b/darwin/fish.nix new file mode 100644 index 0000000..435307b --- /dev/null +++ b/darwin/fish.nix @@ -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 + ''; +} diff --git a/darwin/fonts.nix b/darwin/fonts.nix new file mode 100644 index 0000000..13dd1cf --- /dev/null +++ b/darwin/fonts.nix @@ -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^ + ; + }; +} diff --git a/darwin/games.nix b/darwin/games.nix new file mode 100644 index 0000000..9c89788 --- /dev/null +++ b/darwin/games.nix @@ -0,0 +1,10 @@ +{ + homebrew.casks = [ + # games + "crossover" + "gog-galaxy" + "origin" + "sony-ps-remote-play" + "steam" + ]; +} diff --git a/darwin/general.nix b/darwin/general.nix deleted file mode 100644 index 7abfca8..0000000 --- a/darwin/general.nix +++ /dev/null @@ -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; - -} diff --git a/darwin/homebrew.nix b/darwin/homebrew.nix index d7a7c90..b8c5e31 100644 --- a/darwin/homebrew.nix +++ b/darwin/homebrew.nix @@ -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; }; + }; + }); } diff --git a/darwin/defaults.nix b/darwin/system-defaults.nix similarity index 100% rename from darwin/defaults.nix rename to darwin/system-defaults.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 1ec8604..0000000 --- a/default.nix +++ /dev/null @@ -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 diff --git a/flake.lock b/flake.lock index 727c2cf..579b408 100644 --- a/flake.lock +++ b/flake.lock @@ -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", diff --git a/flake.nix b/flake.nix index 66ebc1b..f1141a9 100644 --- a/flake.nix +++ b/flake.nix @@ -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 - }; - }); + }; } diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..ab998c4 --- /dev/null +++ b/home/default.nix @@ -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 + ]; + }; +} diff --git a/modules/home/programs/helix/extras.nix b/home/extras/helix/auto-theme.nix similarity index 79% rename from modules/home/programs/helix/extras.nix rename to home/extras/helix/auto-theme.nix index 9641018..b9c6885 100644 --- a/modules/home/programs/helix/extras.nix +++ b/home/extras/helix/auto-theme.nix @@ -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 = { diff --git a/home/extras/kitty/auto-theme.nix b/home/extras/kitty/auto-theme.nix new file mode 100644 index 0000000..5579bb0 --- /dev/null +++ b/home/extras/kitty/auto-theme.nix @@ -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 term-dark and term-light + will toggle between your dark and a light colors. + + There is also term-background which accepts one argument, the name + of the theme. + + (Note that the Kitty setting allow_remote_control = true 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"; + }; + }; +} diff --git a/home/extras/kitty/fix-icon.nix b/home/extras/kitty/fix-icon.nix new file mode 100644 index 0000000..347eed7 --- /dev/null +++ b/home/extras/kitty/fix-icon.nix @@ -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} + ''; + }; + }; +} diff --git a/home/extras/kitty/nerd-font.nix b/home/extras/kitty/nerd-font.nix new file mode 100644 index 0000000..eb9c3f5 --- /dev/null +++ b/home/extras/kitty/nerd-font.nix @@ -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 symbol_map 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 + font_family 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}"; + }; + }; +} diff --git a/home/files.nix b/home/files.nix index 6952a36..326aca8 100644 --- a/home/files.nix +++ b/home/files.nix @@ -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 ''; }; - # }}} } diff --git a/home/fish.nix b/home/fish.nix index 5af4a22..b13172e 100644 --- a/home/fish.nix +++ b/home/fish.nix @@ -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 { }); }'"; - nrpu = - "nix repl --expr '{ pkgs = (import { 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 { }); }'"; + + # 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"} ''; - # }}} } diff --git a/home/git.nix b/home/git.nix index 482d074..3754893 100644 --- a/home/git.nix +++ b/home/git.nix @@ -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; diff --git a/home/helix.nix b/home/helix.nix index 992de1c..3d87c63 100644 --- a/home/helix.nix +++ b/home/helix.nix @@ -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"; } diff --git a/home/kitty.nix b/home/kitty.nix index 69a99e7..d764250 100644 --- a/home/kitty.nix +++ b/home/kitty.nix @@ -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"; }; diff --git a/home/programs.nix b/home/programs.nix index 1c08895..957748d 100644 --- a/home/programs.nix +++ b/home/programs.nix @@ -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; }); - # }}} } diff --git a/home/services/dark-mode-notify.nix b/home/services/dark-mode-notify.nix index dba322d..4a6453a 100644 --- a/home/services/dark-mode-notify.nix +++ b/home/services/dark-mode-notify.nix @@ -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 @@ ]; }; }; - # }}} } diff --git a/home/services/tarsnap.nix b/home/services/tarsnap.nix index a7ca27b..f095840 100644 --- a/home/services/tarsnap.nix +++ b/home/services/tarsnap.nix @@ -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; }; }; - # }}} } - diff --git a/lib/mkDarwinSystem.nix b/lib/mkDarwinSystem.nix deleted file mode 100644 index a124224..0000000 --- a/lib/mkDarwinSystem.nix +++ /dev/null @@ -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 `` 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; - }) - ]; -} diff --git a/modules/home/programs/kakoune/extras.nix b/modules/home/programs/kakoune/extras.nix deleted file mode 100644 index cfcf145..0000000 --- a/modules/home/programs/kakoune/extras.nix +++ /dev/null @@ -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 - } - ''; - }; -} diff --git a/modules/home/programs/kitty/extras.nix b/modules/home/programs/kitty/extras.nix deleted file mode 100644 index 2d1e376..0000000 --- a/modules/home/programs/kitty/extras.nix +++ /dev/null @@ -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 term-dark and term-light will - toggle between your dark and a light colors. - term-background which accepts one argument (the value of which should - be dark or light) is also available. - (Note that the Kitty setting allow_remote_control = true 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 symbol_map 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 - font_family 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"; - }; - - }; - -} diff --git a/modules/mk-primary-user-module.nix b/modules/mk-primary-user-module.nix deleted file mode 100644 index 4172481..0000000 --- a/modules/mk-primary-user-module.nix +++ /dev/null @@ -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"; - }; - }; -} diff --git a/nixos/caches/default.nix b/nixos/caches/default.nix new file mode 100644 index 0000000..2c36f2f --- /dev/null +++ b/nixos/caches/default.nix @@ -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=" + ]; + }; +} diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..d64d4a7 --- /dev/null +++ b/nixos/default.nix @@ -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 + ]; + }; +} diff --git a/nixos/nix.nix b/nixos/nix.nix new file mode 100644 index 0000000..620a960 --- /dev/null +++ b/nixos/nix.nix @@ -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" ]; + }; + }; +} diff --git a/nixos/ssh-access.nix b/nixos/ssh-access.nix new file mode 100644 index 0000000..58dc654 --- /dev/null +++ b/nixos/ssh-access.nix @@ -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; + }; +} diff --git a/overlays/colors.nix b/overlays/colors.nix deleted file mode 100644 index 3387fbe..0000000 --- a/overlays/colors.nix +++ /dev/null @@ -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 - ''; -} diff --git a/overlays/colors/tokyonight.nix b/overlays/colors/tokyonight.nix deleted file mode 100644 index 7d8a9c0..0000000 --- a/overlays/colors/tokyonight.nix +++ /dev/null @@ -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"; - }; -} diff --git a/people/config.nix b/people/config.nix new file mode 100644 index 0000000..795735f --- /dev/null +++ b/people/config.nix @@ -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 + ]; + }; + }; +} diff --git a/people/default.nix b/people/default.nix new file mode 100644 index 0000000..c2c8ff1 --- /dev/null +++ b/people/default.nix @@ -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; }; +} diff --git a/pkgs/cinny.nix b/pkgs/cinny.nix deleted file mode 100644 index c33eb6c..0000000 --- a/pkgs/cinny.nix +++ /dev/null @@ -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 - ''; -} diff --git a/pkgs/dark-mode-notify.nix b/pkgs/dark-mode-notify.nix index e5a29c6..43143a1 100644 --- a/pkgs/dark-mode-notify.nix +++ b/pkgs/dark-mode-notify.nix @@ -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; } - diff --git a/pkgs/default.nix b/pkgs/default.nix index cceae9c..ed17f48 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -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 { }; +} diff --git a/pkgs/fileicon.nix b/pkgs/fileicon.nix new file mode 100644 index 0000000..8e3ff09 --- /dev/null +++ b/pkgs/fileicon.nix @@ -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 = { }; +} diff --git a/pkgs/ia-writer-family.nix b/pkgs/ia-writer-family.nix index c0d66f2..31f3725 100644 --- a/pkgs/ia-writer-family.nix +++ b/pkgs/ia-writer-family.nix @@ -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; }; } diff --git a/pkgs/yubiswitch.nix b/pkgs/yubiswitch.nix index ea62a94..508a2bc 100644 --- a/pkgs/yubiswitch.nix +++ b/pkgs/yubiswitch.nix @@ -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 = diff --git a/systems/darwin/m1.nix b/systems/darwin/m1.nix new file mode 100644 index 0000000..6185ccf --- /dev/null +++ b/systems/darwin/m1.nix @@ -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; +} diff --git a/systems/darwin/work.nix b/systems/darwin/work.nix new file mode 100644 index 0000000..466a649 --- /dev/null +++ b/systems/darwin/work.nix @@ -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" + ''; + }]; +} diff --git a/systems/nixos/pihole.nix b/systems/nixos/pihole.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/systems/nixos/pihole.nix @@ -0,0 +1 @@ +{ } diff --git a/templates/default.nix b/templates/default.nix index 079b674..4acaf10 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -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 + ''; + }; }; } diff --git a/templates/rust/LICENSE.txt b/templates/rust/LICENSE.txt index 4eb551d..62be38d 100644 --- a/templates/rust/LICENSE.txt +++ b/templates/rust/LICENSE.txt @@ -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