diff options
author | Franck Cuny <franck@fcuny.net> | 2024-03-04 15:02:31 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2024-03-04 15:02:31 -0800 |
commit | e2f467882f9fd67805b69e5dff6c1652d4c47629 (patch) | |
tree | 500206b90fe6d81b44a8a9cbe78d2fe5becafd1b /nix | |
parent | create profiles for home-manager (diff) | |
download | world-e2f467882f9fd67805b69e5dff6c1652d4c47629.tar.gz |
move all home-manager settings under the profiles
Diffstat (limited to 'nix')
-rw-r--r-- | nix/profiles/home-manager/dev.nix | 167 | ||||
-rw-r--r-- | nix/profiles/home-manager/firefox.nix | 95 | ||||
-rw-r--r-- | nix/profiles/home-manager/git.nix | 80 | ||||
-rw-r--r-- | nix/profiles/home-manager/personal.nix | 10 | ||||
-rw-r--r-- | nix/profiles/home-manager/ssh.nix | 21 | ||||
-rw-r--r-- | nix/profiles/home-manager/zsh.nix | 46 |
6 files changed, 414 insertions, 5 deletions
diff --git a/nix/profiles/home-manager/dev.nix b/nix/profiles/home-manager/dev.nix new file mode 100644 index 0000000..e0ca68b --- /dev/null +++ b/nix/profiles/home-manager/dev.nix @@ -0,0 +1,167 @@ +{ pkgs +, config +, ... +}: +let + pythonEnv = pkgs.python3.withPackages (p: + with p; [ + black + click + isort + pylsp-mypy + requests + types-requests + pip + ipython + virtualenv + ]); +in +{ + programs.go = { + enable = true; + goPath = ".local/share/pkg.go"; + goBin = ".local/bin.go"; + package = pkgs.go_1_21; + }; + + home.packages = with pkgs; [ + go-tools + golangci-lint + gopls + + dive # explore layers in docker images + + pythonEnv + + kubectl + + google-cloud-sdk + + rnix-lsp + alejandra + nil + ]; + + home.sessionPath = [ + config.home.sessionVariables.GOBIN + ]; + + programs.zsh.shellAliases = { + kc = "kubectl"; + }; + + programs.vscode = { + enable = true; + + # Workaround https://github.com/nix-community/home-manager/issues/3507 + mutableExtensionsDir = false; + + extensions = with pkgs.vscode-extensions; [ + #go + golang.go + + # nix + arrterian.nix-env-selector + bbenoist.nix + jnoortheen.nix-ide + + # python + ms-python.python + ms-python.vscode-pylance + ms-python.black-formatter + + # shell + mads-hartmann.bash-ide-vscode + + # utils + ms-vscode.makefile-tools # Makefile support + mkhl.direnv # direnv + editorconfig.editorconfig # editor config for vscode + tamasfe.even-better-toml # better TOML mode + streetsidesoftware.code-spell-checker # code spell checker + github.vscode-github-actions # GHA + ]; + userSettings = { + # editor + editor.fontSize = 15; + "editor.formatOnSave" = true; + "editor.minimap.enabled" = false; + "editor.fontFamily" = "Monaspace Neon"; + "editor.fontLigatures" = true; + "editor.rulers" = [ 80 120 ]; + "editor.folding" = false; + "editor.foldingHighlight" = false; + + # explorer + "explorer.sortOrder" = "default"; + "explorer.autoRevealExcludes" = { + "**/result" = true; + }; + + # extensions + "extensions.ignoreRecommendations" = true; + "extensions.autoCheckUpdates" = false; + "extensions.autoUpdate" = false; + + # files + "files.trimFinalNewLines" = true; + "files.insertFinalNewLine" = true; + "files.autoSave" = "afterDelay"; + "files.autoSaveDelay" = 100; # in milliseconds + "files.exclude" = { + "**/.direnv" = true; + "**/result" = true; + }; + + # formatter + formatter = { + "[python]"."editor.defaultFormatter" = "ms-python.black-formatter"; + }; + + # workbench + workbench.colorTheme = "Default Light Modern"; + workbench.sideBar.location = "right"; + + # telemetry + "telemetry.telemetryLevel" = "off"; + + # terminal + "terminal.integrated.fontFamily" = "Monaspace Xenon"; + "terminal.integrated.fontSize" = 13; + + # go + "go.lintTool" = "golangci-lint"; + "go.toolsManagemenent.checkForUpdates" = "off"; + "go.toolsManagemenent.autoUpdate" = false; + "gopls" = { + "format.gofumpt" = true; + "ui.semanticTokens" = true; + }; + + # shell + bash = { + "bashIde.shellcheckPath" = "${pkgs.shellcheck}/bin/shellcheck"; + "shfmt.executablePath" = "${pkgs.shfmt}/bin/shfmt"; + }; + + # nix + "nix.serverPath" = "nil"; + "nix.serverSettings" = { + "nil" = { + "formatting" = { + "command" = [ "nixpkgs-fmt" ]; + }; + }; + }; + "nix.enableLanguageServer" = true; + }; + }; + + home.sessionVariables = with config.xdg; { + IPYTHONDIR = "${cacheHome}/ipython"; + PIP_LOG = "${cacheHome}/pip/pip.log"; + PYLINTHOME = "${cacheHome}/pylint"; + PYTHON_EGG_CACHE = "${cacheHome}/python-eggs"; + MYPY_CACHE_DIR = "${cacheHome}/mypy"; + }; +} diff --git a/nix/profiles/home-manager/firefox.nix b/nix/profiles/home-manager/firefox.nix new file mode 100644 index 0000000..a982a2e --- /dev/null +++ b/nix/profiles/home-manager/firefox.nix @@ -0,0 +1,95 @@ +{ pkgs, ... }: { + programs.firefox = { + enable = true; + package = pkgs.firefox-bin; + profiles.default = { + isDefault = true; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + ublock-origin + onepassword-password-manager + ]; + bookmarks = [ + { + name = "GitHub Notifications"; + keyword = "n"; + url = "https://github.com/notifications?query=is%3Aunread"; + } + { + name = "GitHub Pull Requests"; + keyword = "p"; + url = "https://github.com/pulls"; + } + ]; + search = { + default = "DuckDuckGo"; + engines = { + "Nix Packages" = { + urls = [ + { + template = "https://search.nixos.org/packages"; + params = [ + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } + ]; + } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "np" ]; + }; + "Google".metaData.hidden = true; + "Amazon.com".metaData.hidden = true; + "Bing".metaData.hidden = true; + "eBay".metaData.hidden = true; + "Wikipedia (en)".metaData.alias = "w"; + }; + force = true; + }; + settings = { + "app.update.auto" = false; + "app.shield.optoutstudies.enabled" = false; + + "browser.bookmarks.restore_default_bookmarks" = false; + "browser.bookmarks.showMobileBookmarks" = false; + "browser.compactmode.show" = true; + "browser.urlbar.placeholderName" = "search"; + "browser.shell.checkDefaultBrowser" = false; + "browser.contentblocking.category" = "strict"; + "browser.startup.page" = 3; # Restore previous windows and tabs on startup. + "browser.warnOnQuit" = false; + "browser.formfill.enable" = false; + "browser.newtabpage.enabled" = false; # Make new tabs blank + "browser.newtabpage.activity-stream.feeds.section.topstories" = false; + "browser.newtabpage.activity-stream.feeds.telemetry" = false; + "browser.newtabpage.activity-stream.feeds.topsites" = false; + "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts.havePinned" = "duckduckgo"; + "browser.newtabpage.activity-stream.showSponsored" = false; + "browser.newtabpage.activity-stream.telemetry" = false; + "browser.urlbar.suggest.quicksuggest.nonsponsored" = false; + "browser.urlbar.suggest.quicksuggest.sponsored" = false; + + "dom.forms.autocomplete.formautofill" = false; # Disable autofill + + "extensions.formautofill.addresses.enabled" = false; + "extensions.formautofill.creditCards.enabled" = false; # Disable credit cards + "extensions.htmlaboutaddons.inline-options.enabled" = false; + "extensions.htmlaboutaddons.recommendations.enabled" = false; + "extensions.pocket.enabled" = false; + "extensions.pocket.showHome" = false; + + # Disable Sponsored Top Sites + "services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsoredTopSite" = false; + + "network.http.referer.spoofSource" = true; + + "privacy.donottrackheader.value" = 1; + "privacy.donottrackheader.enabled" = true; + }; + }; + }; +} diff --git a/nix/profiles/home-manager/git.nix b/nix/profiles/home-manager/git.nix new file mode 100644 index 0000000..ce9c0a9 --- /dev/null +++ b/nix/profiles/home-manager/git.nix @@ -0,0 +1,80 @@ +{ lib, pkgs, config, ... }: +let + sshPub = builtins.fromTOML ( + builtins.readFile ../../../configs/ssh-pubkeys.toml + ); +in +{ + home.file.".ssh/allowed_signers".text = lib.concatMapStrings (x: "franck@fcuny.net ${x}\n") (with sshPub; [ aptos work git ykey-laptop op ]); + + programs.git = { + enable = true; + userName = "Franck Cuny"; + userEmail = "franck@fcuny.net"; + + signing = { + key = "key::${sshPub.op}"; + signByDefault = true; + }; + + aliases = { + amend = "commit --amend"; + ll = "log --pretty=\"format:%h %G? %aN %s\""; + }; + + extraConfig = { + core.whitespace = "trailing-space,space-before-tab"; + color.ui = "true"; + + gpg.format = "ssh"; + gpg.ssh.allowedSignersFile = "~/.ssh/allowed_signers"; + gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; + + # 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"; + + commit.template = "${config.xdg.dataHome}/git/commit.template"; + }; + + ignores = [ + "*~" + ".direnv" + "__pycache__" + ]; + }; + + xdg.dataFile."git/commit.template".source = pkgs.writeText "commit.template" '' + + # (If applied, this commit will...) <subject> + + # Explain why this change is being made + + # --- COMMIT END --- + # Remember to + # Use the imperative mood, present tense: `change' not `changed' nor `changes' + # Do not end the subject line with a period + # Use the body to explain what and why vs. how + # Can use multiple lines with "-" for bullet points in body +''; + + home.packages = with pkgs; [ + gitAndTools.pre-commit + ]; +} diff --git a/nix/profiles/home-manager/personal.nix b/nix/profiles/home-manager/personal.nix index 9072d63..5beb11e 100644 --- a/nix/profiles/home-manager/personal.nix +++ b/nix/profiles/home-manager/personal.nix @@ -3,11 +3,11 @@ home.stateVersion = "23.05"; imports = [ - ../../../home/dev.nix - ../../../home/firefox.nix - ../../../home/git.nix - ../../../home/ssh.nix - ../../../home/zsh.nix + ./dev.nix + ./firefox.nix + ./git.nix + ./ssh.nix + ./zsh.nix ]; home.packages = with pkgs; [ diff --git a/nix/profiles/home-manager/ssh.nix b/nix/profiles/home-manager/ssh.nix new file mode 100644 index 0000000..47aee8a --- /dev/null +++ b/nix/profiles/home-manager/ssh.nix @@ -0,0 +1,21 @@ +{ ... }: +{ + programs.ssh = { + enable = true; + forwardAgent = true; + serverAliveInterval = 60; + controlMaster = "auto"; + controlPersist = "30m"; + extraConfig = '' + IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + ''; + matchBlocks = { + "github.com" = { + hostname = "github.com"; + user = "git"; + forwardAgent = false; + extraOptions = { preferredAuthentications = "publickey"; }; + }; + }; + }; +} diff --git a/nix/profiles/home-manager/zsh.nix b/nix/profiles/home-manager/zsh.nix new file mode 100644 index 0000000..e704870 --- /dev/null +++ b/nix/profiles/home-manager/zsh.nix @@ -0,0 +1,46 @@ +{ config, pkgs, ... }: +{ + home.packages = with pkgs; [ zsh-completions ]; + + programs.zsh = { + enable = true; + dotDir = ".config/zsh"; + + defaultKeymap = "emacs"; + enableCompletion = true; + enableAutosuggestions = true; + + history = { + size = 500000; + save = 500000; + extended = true; + ignoreSpace = true; + ignoreDups = true; + share = true; + # see + # https://github.com/nix-community/home-manager/blob/32a7da69dc53c9eb5ad0675eb7fdc58f7fe35272/modules/programs/zsh.nix#L537 + path = "${config.xdg.dataHome}/zsh/zsh_history"; + }; + + localVariables = { + # Print timing statistics for everything which takes longer than + # 5 seconds of user + system time. + REPORTTIME = 5; + }; + + shellAliases = { + ll = "ls -l --color=auto"; + lt = "ls -ltrh --color=auto"; + la = "ls -ltrha --color=auto"; + pkgsearch = "nix search nixpkgs"; + flup = "nix flake update --commit-lock-file"; + emacsrescue = "pkill -SIGUSR2 -i emacs"; # then `M-x toggle-debug-on-quit` + }; + + oh-my-zsh = { + enable = true; + plugins = [ "git" ]; + theme = "robbyrussell"; + }; + }; +} |