diff options
author | Franck Cuny <franck@fcuny.net> | 2024-12-08 13:58:02 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2024-12-08 15:35:17 -0800 |
commit | 52ac07299f2342afe0c309f3b8be3ea05c7549ff (patch) | |
tree | bad76e67ba8a1f9301eb87a8c5e66c8a5a260e76 /nix/users/fcuny | |
parent | add targets to create virtual machines (diff) | |
download | world-52ac07299f2342afe0c309f3b8be3ea05c7549ff.tar.gz |
refactor overall configuration
The configuration of the various hosts and home-manager was becoming a bit complex for no valid reasons. Try to simplify this a bit.
Diffstat (limited to 'nix/users/fcuny')
-rw-r--r-- | nix/users/fcuny/darwin.nix | 8 | ||||
-rw-r--r-- | nix/users/fcuny/home-manager.nix | 256 | ||||
-rw-r--r-- | nix/users/fcuny/nixos.nix | 20 |
3 files changed, 284 insertions, 0 deletions
diff --git a/nix/users/fcuny/darwin.nix b/nix/users/fcuny/darwin.nix new file mode 100644 index 0000000..b56a67d --- /dev/null +++ b/nix/users/fcuny/darwin.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + # The user should already exist, but we need to set this up so Nix knows + # what our home directory is (https://github.com/LnL7/nix-darwin/issues/423). + users.users.fcuny = { + home = "/Users/fcuny"; + shell = pkgs.fish; + }; +} diff --git a/nix/users/fcuny/home-manager.nix b/nix/users/fcuny/home-manager.nix new file mode 100644 index 0000000..6c3342b --- /dev/null +++ b/nix/users/fcuny/home-manager.nix @@ -0,0 +1,256 @@ +{ ... }: + +{ config, lib, pkgs, ... }: { + home.stateVersion = "23.05"; + + xdg.enable = true; + + home.packages = with pkgs; [ + # go + go-tools + golangci-lint + gopls + delve + + # docker + dive # explore layers in docker images + + # shell + shellcheck + + # git + gitAndTools.pre-commit + git-credential-manager + gh + + # shell utils + coreutils + direnv + dust + procs + ripgrep + tree + wget + + # network + bandwhich + + # data manipulation + jless + jq + yq + + # encryption + age + + # media + mpv + ffmpeg + + # dicts + aspell + aspellDicts.en + aspellDicts.en-computers + aspellDicts.en-science + + # nix + nil + nix-direnv + nixd + nixfmt-classic + nixpkgs-fmt + nil # nix lsp + + # k8s + kind # k8s in docker + kubebuilder # generate controller + kubectl + kubernetes-helm # deploy applications + kubie # kubeconfig browser https://github.com/sbstp/kubie + kubelogin-oidc # OIDC plugin + k9s # object explorer + + # hashicorp + boundary + nomad-pack + tfswitch + ]; + + programs.go = { + enable = true; + goPath = ".local/share/pkg.go"; + goBin = ".local/bin.go"; + goPrivate = [ "github.rbx.com/*" "github.com/fcuny/*" "git.fcuny.net/*" ]; + }; + + # an alternative to ls + programs.eza = { + enable = true; + icons = "never"; + enableFishIntegration = false; + extraOptions = [ + "--group-directories-first" + "--no-quotes" + "--git-ignore" + "--icons=never" + ]; + }; + + # an alternative to find + programs.fd = { + enable = true; + hidden = true; + ignores = [ ".git/" ".direnv/" ]; + }; + + programs.direnv = { + enable = true; + nix-direnv.enable = true; + enableZshIntegration = true; + config = { + global.disable_stdin = true; + global.strict_env = true; + }; + }; + + programs.fish = { + enable = true; + interactiveShellInit = '' + set fish_greeting "" + ''; + + shellAbbrs = { ncg = "nix-collect-garbage -d"; }; + shellAliases = { + c = "clear"; + ls = "eza -l -L=1 --git --color=always --group-directories-first"; + la = "eza -la --git --color=always --group-directories-first"; + ll = "eza -la -L=1 --git --color=always --group-directories-first"; + lt = "eza -aT -L=2 --git --color=always --group-directories-first"; + }; + }; + + programs.git = { + enable = true; + userName = "Franck Cuny"; + userEmail = "franck@fcuny.net"; + + aliases = { amend = "commit --amend"; }; + + includes = [ + { + condition = "hasconfig:remote.*.url:git@github.rbx.com:**"; + path = pkgs.writeText "finsitGitConfig" + (lib.generators.toGitINI { user.email = "fcuny@roblox.com"; }); + } + { + condition = "hasconfig:remote.*.url:git@github.com:Roblox/**"; + path = pkgs.writeText "finsitGitConfig" + (lib.generators.toGitINI { user.email = "fcuny@roblox.com"; }); + } + ]; + + extraConfig = { + core.whitespace = "trailing-space,space-before-tab"; + color.ui = "true"; + + # abort if the remote branch does not match the local one + push.default = "simple"; + + # https://adamj.eu/tech/2024/01/18/git-improve-diff-histogram/ + diff.algorithm = "histogram"; + + init.defaultBranch = "main"; + + pull.rebase = true; + rebase = { + # Automatically create a temporary stash entry before the + # operation begins, and apply it after the operation ends. + autoStash = true; + # Print a warning if some commits are removed + missingCommitsCheck = "warn"; + }; + + branch.autosetuprebase = "remote"; + branch.sort = "authordate"; + + url = { + "ssh://git@github.rbx.com/" = { + insteadOf = "https://github.rbx.com/"; + }; + }; + }; + }; + + programs.ssh = { + enable = true; + forwardAgent = true; + serverAliveInterval = 60; + controlMaster = "auto"; + controlPersist = "30m"; + extraConfig = '' + IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + ''; + matchBlocks = { + "personal" = { + hostname = "github.com"; + user = "git"; + forwardAgent = false; + extraOptions = { preferredAuthentications = "publickey"; }; + }; + "github.com" = { + hostname = "github.com"; + user = "git"; + forwardAgent = false; + extraOptions = { preferredAuthentications = "publickey"; }; + }; + "github.rbx.com" = { + hostname = "github.rbx.com"; + user = "git"; + forwardAgent = false; + extraOptions = { preferredAuthentications = "publickey"; }; + }; + }; + }; + + home.sessionPath = [ config.home.sessionVariables.GOBIN ]; + + home.sessionVariables = with config.xdg; { + ASPELL_CONF = "conf ${config.xdg.configHome}/aspell/config;"; + EDITOR = "emacsclient -a="; + HOMEBREW_NO_AUTO_UPDATE = 1; + IPYTHONDIR = "${cacheHome}/ipython"; + LESS = "-FRSXM"; + LESSCHARSET = "utf-8"; + MYPY_CACHE_DIR = "${cacheHome}/mypy"; + PAGER = "less"; + PIP_LOG = "${cacheHome}/pip/pip.log"; + PYLINTHOME = "${cacheHome}/pylint"; + PYTHON_EGG_CACHE = "${cacheHome}/python-eggs"; + SHELL = "${pkgs.fish}/bin/fish"; + VISUAL = "emacsclient -a="; + }; + + # Generate ssh agent config for 1Password + # I want both my personal and work keys + home.file.".config/1Password/ssh/agent.toml".text = '' + [[ssh-keys]] + account = "my.1password.com" + + [[ssh-keys]] + account = "roblox.1password.com" + item = "GitHub ssh key" + vault = "Private" + ''; + + home.file.kubie = { + target = ".kube/kubie.yaml"; + text = '' + shell: fish + configs: + include: + - ~/.kube/rksconfig + prompt: + fish_use_rprompt: true + ''; + }; +} diff --git a/nix/users/fcuny/nixos.nix b/nix/users/fcuny/nixos.nix new file mode 100644 index 0000000..662c0b1 --- /dev/null +++ b/nix/users/fcuny/nixos.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: { + # https://github.com/nix-community/home-manager/pull/2408 + environment.pathsToLink = [ "/share/fish" ]; + + # Add ~/.local/bin to PATH + environment.localBinInPath = true; + + # we're using fish as our shell + programs.fish.enable = true; + + users.users.fcuny = { + isNormalUser = true; + home = "/home/fcuny"; + extraGroups = [ "docker" "wheel" ]; + shell = pkgs.fish; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINBkozy+X96u5ciX766bJ/AyQ3xm1tXZTIr5+4PVFZFi" + ]; + }; +} |