From 7c56f427797b9ceb0140afff3dd38886cda0911e Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Fri, 5 Dec 2025 15:48:11 +0000 Subject: [PATCH] nix: use nixfmt-rfc-style --- flake.nix | 225 +++++++++++++++++++++++---------------- home/aws.nix | 5 +- home/default.nix | 32 +++--- home/docker.nix | 8 +- home/git.nix | 15 ++- home/gpg.nix | 5 +- home/helix.nix | 33 +++--- home/macs.nix | 11 +- home/packages.nix | 22 +++- home/passwords.nix | 11 +- home/profiles.nix | 45 +++++--- home/tpmssh.nix | 20 ++-- home/vim-dev/default.nix | 12 ++- home/vim.nix | 7 +- home/vscode.nix | 3 +- pkgs/default.nix | 5 +- pkgs/qrclip/default.nix | 17 +-- 17 files changed, 299 insertions(+), 177 deletions(-) diff --git a/flake.nix b/flake.nix index 593a0fd..204b108 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,12 @@ description = "Samw's home environment, as managed by nix/home-manager."; inputs = { # Nixpkgs - nixpkgs = {url = "github:nixos/nixpkgs/release-25.05";}; - nixpkgs-unstable = {url = "github:nixos/nixpkgs";}; + nixpkgs = { + url = "github:nixos/nixpkgs/release-25.05"; + }; + nixpkgs-unstable = { + url = "github:nixos/nixpkgs"; + }; # Other modules home-manager = { url = "github:nix-community/home-manager/release-25.05"; @@ -16,96 +20,133 @@ inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs: let - overlays = [ - # Add our own local packages - (final: prev: { - # Make my local packages available as pkgs.mypkgs. - mypkgs = prev.callPackage ./pkgs {}; - }) - # more up to date ssh-tpm-agent. Can probably ditch this post-24.05 - (final: prev: { - ssh-tpm-agent = (import inputs.nixpkgs-unstable { system = prev.system; }).ssh-tpm-agent; - }) - ]; - in (rec { - profiles = import ./home/profiles.nix; - lib = { - mkHome = { - profiles, - system, - username ? "samw", - }: - inputs.home-manager.lib.homeManagerConfiguration { - pkgs = (import inputs.nixpkgs { - inherit system; - config.allowUnfree = true; # Yes I know it's bad for me - }); - modules = [ - { home = { - inherit username; - homeDirectory = - if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin - then "/Users/${username}" - else "/home/${username}"; - stateVersion = "21.11"; - };}] ++ profiles ++ [ - {nixpkgs.overlays = overlays;} - # See comment in home/default.nix. - ({ pkgs, ... }: { - nix = { - enable = true; - package = pkgs.nix; - settings.experimental-features = "nix-command flakes"; - settings.max-jobs = "auto"; # Gotta go fast (build derivations in parallel) - # Pin the nixpkgs registry to our locked nixpkgs. This means that we - # get the same packages via e.g. nix shell as we have at the system - # level, so less duplication overall and no more fetching that 30MB src - # every time you run nix shell. - registry.nixpkgs.flake = inputs.nixpkgs; - }; - }) - ]; - extraSpecialArgs = {inherit system;}; - }; - }; + outputs = + inputs: + let + overlays = [ + # Add our own local packages + (final: prev: { + # Make my local packages available as pkgs.mypkgs. + mypkgs = prev.callPackage ./pkgs { }; + }) + # more up to date ssh-tpm-agent. Can probably ditch this post-24.05 + (final: prev: { + ssh-tpm-agent = (import inputs.nixpkgs-unstable { system = prev.system; }).ssh-tpm-agent; + }) + ]; + in + ( + rec { + profiles = import ./home/profiles.nix; + lib = { + mkHome = + { + profiles, + system, + username ? "samw", + }: + inputs.home-manager.lib.homeManagerConfiguration { + pkgs = ( + import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; # Yes I know it's bad for me + } + ); + modules = [ + { + home = { + inherit username; + homeDirectory = + if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin then + "/Users/${username}" + else + "/home/${username}"; + stateVersion = "21.11"; + }; + } + ] + ++ profiles + ++ [ + { nixpkgs.overlays = overlays; } + # See comment in home/default.nix. + ( + { pkgs, ... }: + { + nix = { + enable = true; + package = pkgs.nix; + settings.experimental-features = "nix-command flakes"; + settings.max-jobs = "auto"; # Gotta go fast (build derivations in parallel) + # Pin the nixpkgs registry to our locked nixpkgs. This means that we + # get the same packages via e.g. nix shell as we have at the system + # level, so less duplication overall and no more fetching that 30MB src + # every time you run nix shell. + registry.nixpkgs.flake = inputs.nixpkgs; + }; + } + ) + ]; + extraSpecialArgs = { inherit system; }; + }; + }; - # Standalone home-manager configurations - homeConfigurations = { - zinc = lib.mkHome { - system = "aarch64-darwin"; - profiles = with profiles; [default dev dev-gui sensitive mac]; + # Standalone home-manager configurations + homeConfigurations = { + zinc = lib.mkHome { + system = "aarch64-darwin"; + profiles = with profiles; [ + default + dev + dev-gui + sensitive + mac + ]; + }; + luroy = lib.mkHome { + system = "x86_64-linux"; + profiles = with profiles; [ + default + dev + ]; + }; + phosphorus = lib.mkHome { + system = "aarch64-darwin"; + profiles = with profiles; [ + default + dev + sensitive + mac + ]; + }; }; - luroy = lib.mkHome { - system = "x86_64-linux"; - profiles = with profiles; [default dev]; - }; - phosphorus = lib.mkHome { - system = "aarch64-darwin"; - profiles = with profiles; [default dev sensitive mac]; - }; - }; - } - # Per-system things - // (inputs.flake-utils.lib.eachDefaultSystem (system: let - pkgs = import inputs.nixpkgs { - inherit system; - overlays = overlays ++ [inputs.devshell.overlays.default]; - }; - platform = pkgs.lib.systems.elaborate system; - in { - # Flake interface to my local packages. - # - `callPackage` puts some junk in mypkgs (`override` and - # `overrideDerivation`) so we filter out anything that isn't a derivation - # - We also filter out any packages that aren't supported on the current - # platform. - packages = with pkgs.lib; (filterAttrs (_: v: (isDerivation v && meta.availableOn platform v)) pkgs.mypkgs); - formatter = pkgs.alejandra; - # A devshell with useful utils - devShells.default = pkgs.devshell.mkShell { - packages = [ - inputs.home-manager.packages.${system}.default - ]; - }; - }))); + } + # Per-system things + // (inputs.flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import inputs.nixpkgs { + inherit system; + overlays = overlays ++ [ inputs.devshell.overlays.default ]; + }; + platform = pkgs.lib.systems.elaborate system; + in + { + # Flake interface to my local packages. + # - `callPackage` puts some junk in mypkgs (`override` and + # `overrideDerivation`) so we filter out anything that isn't a derivation + # - We also filter out any packages that aren't supported on the current + # platform. + packages = + with pkgs.lib; + (filterAttrs (_: v: (isDerivation v && meta.availableOn platform v)) pkgs.mypkgs); + formatter = pkgs.nixfmt-tree; + # A devshell with useful utils + devShells.default = pkgs.devshell.mkShell { + packages = [ + inputs.home-manager.packages.${system}.default + ]; + }; + } + )) + ); } diff --git a/home/aws.nix b/home/aws.nix index 572bb39..9bbaf8d 100644 --- a/home/aws.nix +++ b/home/aws.nix @@ -1 +1,4 @@ -{pkgs, ...}: {home.packages = with pkgs; [awscli2];} +{ pkgs, ... }: +{ + home.packages = with pkgs; [ awscli2 ]; +} diff --git a/home/default.nix b/home/default.nix index 4f0495c..68c157d 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,23 +1,25 @@ { pkgs, ... -}: let - packages = pkgs.callPackage ./packages.nix {}; -in { +}: +let + packages = pkgs.callPackage ./packages.nix { }; +in +{ home.packages = packages.all; home.sessionVariables = { - EDITOR = "vim"; # is overriden to nvim in vim.nix if needed + EDITOR = "vim"; # is overriden to nvim in vim.nix if needed WORDCHARS = "\${WORDCHARS//[\\/.=]/}"; # ctrl-w on paths without make angery }; /* - # For some reason this doesn't play nice when using home manager config from inside - # a nixos configuration. - nix = { - enable = true; - package = pkgs.nix; - settings.experimental-features = "nix-command flakes"; - settings.max-jobs = "auto"; # Gotta go fast (build derivations in parallel) - }; + # For some reason this doesn't play nice when using home manager config from inside + # a nixos configuration. + nix = { + enable = true; + package = pkgs.nix; + settings.experimental-features = "nix-command flakes"; + settings.max-jobs = "auto"; # Gotta go fast (build derivations in parallel) + }; */ programs = { home-manager.enable = true; @@ -77,7 +79,9 @@ in { format = "$username$hostname$shlvl$directory$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch$docker_context$golang$kotlin$nodejs$python$rust$terraform$nix_shell$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$status$shell$character"; username.format = "[$user]($style) "; hostname.format = "[$hostname]($style) "; - directory = {truncation_length = -1;}; + directory = { + truncation_length = -1; + }; git_branch.format = "[$symbol$branch]($style) "; python.format = "[py \${pyenv_prefix}(\${version} )(\\($virtualenv\\) )]($style)"; nodejs.format = "[js ($version )]($style)"; @@ -98,7 +102,7 @@ in { ssh = { enable = true; - includes = ["~/.ssh/config.local"]; + includes = [ "~/.ssh/config.local" ]; matchBlocks."*" = { user = "samw"; serverAliveInterval = 30; diff --git a/home/docker.nix b/home/docker.nix index af86302..0c9e93d 100644 --- a/home/docker.nix +++ b/home/docker.nix @@ -1 +1,7 @@ -{pkgs, ...}: {home.packages = with pkgs; [docker colima];} +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + docker + colima + ]; +} diff --git a/home/git.nix b/home/git.nix index 9c95adf..4866a23 100644 --- a/home/git.nix +++ b/home/git.nix @@ -1,5 +1,9 @@ -{pkgs, ...}: { - home.packages = with pkgs; [ git-open tea ]; +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + git-open + tea + ]; programs.git = { enable = true; lfs.enable = true; @@ -9,7 +13,9 @@ delta = { # Better diffs enable = true; - options = {line-numbers = true;}; + options = { + line-numbers = true; + }; }; aliases = { @@ -36,8 +42,7 @@ sw = "switch"; swc = "switch --create"; - gone = '' - ! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' │ awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D''; + gone = ''! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' │ awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D''; }; extraConfig = { branch.sort = "-committerdate"; diff --git a/home/gpg.nix b/home/gpg.nix index 50eb095..9f91eaf 100644 --- a/home/gpg.nix +++ b/home/gpg.nix @@ -1,4 +1,5 @@ -{pkgs, lib, ...}: { +{ pkgs, lib, ... }: +{ programs.gpg = { enable = true; mutableKeys = false; @@ -19,7 +20,7 @@ ]; # make yubikey work on macos? lolgpg # https://github.com/NixOS/nixpkgs/issues/155629 - scdaemonSettings = (lib.optionalAttrs pkgs.stdenv.isDarwin {disable-ccid = true;}); + scdaemonSettings = (lib.optionalAttrs pkgs.stdenv.isDarwin { disable-ccid = true; }); }; # Shouldn't have an effect on macos, on linux we need to specify a pinentry diff --git a/home/helix.nix b/home/helix.nix index 21dc689..6050333 100644 --- a/home/helix.nix +++ b/home/helix.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ programs.helix = { enable = true; settings = { @@ -8,20 +9,24 @@ languages = { language-server.basedpyright = { command = "basedpyright-langserver"; - args = ["--stdio"]; + args = [ "--stdio" ]; }; - language = [{ - name = "python"; - roots = [ - "pyproject.toml" - "setup.py" - "poetry.lock" - ".git" - ]; - language-servers = [{ - name = "basedpyright"; - }]; - }]; + language = [ + { + name = "python"; + roots = [ + "pyproject.toml" + "setup.py" + "poetry.lock" + ".git" + ]; + language-servers = [ + { + name = "basedpyright"; + } + ]; + } + ]; }; }; } diff --git a/home/macs.nix b/home/macs.nix index e5bcd10..eb756d1 100644 --- a/home/macs.nix +++ b/home/macs.nix @@ -2,14 +2,19 @@ pkgs, lib, ... -}: { +}: +{ # Mac specific packages. # TODO: have this in a central packages place rather than here - home.packages = with pkgs; [pngpaste mypkgs.qrclip]; + home.packages = with pkgs; [ + pngpaste + mypkgs.qrclip + ]; # Use secretive for SSH agent programs.ssh.matchBlocks.all = lib.mkIf pkgs.stdenv.isDarwin { host = "*"; - extraOptions."IdentityAgent" = "~/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"; + extraOptions."IdentityAgent" = + "~/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh"; }; programs.zsh.initContent = "eval $(/opt/homebrew/bin/brew shellenv)"; } diff --git a/home/packages.nix b/home/packages.nix index ce6f9b3..377b318 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -1,5 +1,6 @@ -{pkgs}: -with pkgs; rec { +{ pkgs }: +with pkgs; +rec { # The stuff you want installed everywhere. The necessities. base = [ bat # cat replacement, aliased to cat in home-manager @@ -15,10 +16,23 @@ with pkgs; rec { ]; # Networking shit - net = [dig iperf3 nmap socat tcpdump whois]; + net = [ + dig + iperf3 + nmap + socat + tcpdump + whois + ]; # development tools - dev = [jq nixfmt-rfc-style gh glab hexyl ]; + dev = [ + jq + nixfmt-rfc-style + gh + glab + hexyl + ]; all = base ++ net ++ dev; } diff --git a/home/passwords.nix b/home/passwords.nix index f649099..97dfbbe 100644 --- a/home/passwords.nix +++ b/home/passwords.nix @@ -1,9 +1,12 @@ -{pkgs, ...}: { - home.packages = with pkgs; [yubikey-manager]; +{ pkgs, ... }: +{ + home.packages = with pkgs; [ yubikey-manager ]; programs.password-store = { enable = true; - settings = {PASSWORD_STORE_DIR = "$HOME/.password-store";}; - package = pkgs.pass.withExtensions (exts: [exts.pass-otp]); + settings = { + PASSWORD_STORE_DIR = "$HOME/.password-store"; + }; + package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); }; programs.zsh.shellAliases = { p = "pass"; diff --git a/home/profiles.nix b/home/profiles.nix index 7a1e8d1..705e7f2 100644 --- a/home/profiles.nix +++ b/home/profiles.nix @@ -2,22 +2,33 @@ # The basics that you'll want everywhere default = ./default.nix; # A machine for development - dev = {...}: { - imports = [./git.nix ./vim.nix ./vim-dev ./helix.nix]; - }; + dev = + { ... }: + { + imports = [ + ./git.nix + ./vim.nix + ./vim-dev + ./helix.nix + ]; + }; # A machine for dev with a GUI # TODO: detect this automatically somehow? - dev-gui = {...}: { - imports = [./vscode.nix]; - }; + dev-gui = + { ... }: + { + imports = [ ./vscode.nix ]; + }; tpmssh = ./tpmssh.nix; # Sensitive stuff - sensitive = {...}: { - imports = [ - ./passwords.nix - ./gpg.nix - ]; - }; + sensitive = + { ... }: + { + imports = [ + ./passwords.nix + ./gpg.nix + ]; + }; # A MacOS machine mac = ./macs.nix; # A machine you want to do docker stuff on @@ -25,5 +36,13 @@ # A machine you want to do aws stuff on aws = ./aws.nix; # A server - server = {...}: {imports = [./default.nix ./git.nix ./vim.nix];}; + server = + { ... }: + { + imports = [ + ./default.nix + ./git.nix + ./vim.nix + ]; + }; } diff --git a/home/tpmssh.nix b/home/tpmssh.nix index d3b2e0f..df2ab16 100644 --- a/home/tpmssh.nix +++ b/home/tpmssh.nix @@ -1,5 +1,6 @@ # Enable tpm-ssh-agent in a systemd user service -{pkgs, config, ...}: { +{ pkgs, config, ... }: +{ home.packages = [ pkgs.ssh-tpm-agent ]; home.sessionVariables = { SSH_AUTH_SOCK = "$(${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent --print-socket)"; @@ -22,11 +23,18 @@ Environment = '' SSH_AUTH_SOCK="%t/ssh-tpm-agent.sock" ''; - ExecStart = "${pkgs.writeShellScriptBin "start-ssh-tpm-agent" (if config.services.gpg-agent.enableSshSupport then '' - ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent -A $(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket) - '' else '' - ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent - '')}/bin/start-ssh-tpm-agent"; + ExecStart = "${ + pkgs.writeShellScriptBin "start-ssh-tpm-agent" ( + if config.services.gpg-agent.enableSshSupport then + '' + ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent -A $(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket) + '' + else + '' + ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent + '' + ) + }/bin/start-ssh-tpm-agent"; PassEnvironment = "SSH_AGENT_PID"; SuccessExitStatus = 2; Type = "simple"; diff --git a/home/vim-dev/default.nix b/home/vim-dev/default.nix index c6624a4..7b0875c 100644 --- a/home/vim-dev/default.nix +++ b/home/vim-dev/default.nix @@ -3,14 +3,16 @@ lib, system, ... -}: { - home.packages = with pkgs; [nil]; - programs.neovim.plugins = with pkgs.vimPlugins; +}: +{ + home.packages = with pkgs; [ nil ]; + programs.neovim.plugins = + with pkgs.vimPlugins; [ # More fancy shit nvim-treesitter trouble-nvim - # Language server/completions + # Language server/completions nvim-lspconfig nvim-cmp cmp-nvim-lsp @@ -32,7 +34,7 @@ ] # delve is unsupported on aarch64-linux and golangci-lint is broken on darwin # (see https://github.com/NixOS/nixpkgs/issues/168984). - ++ lib.optionals (system != "aarch64-linux" && !pkgs.stdenv.isDarwin) [vim-go]; + ++ lib.optionals (system != "aarch64-linux" && !pkgs.stdenv.isDarwin) [ vim-go ]; programs.neovim.extraConfig = '' lua <