1
mirror of https://github.com/wlcx/home.git synced 2026-02-15 14:23:45 +00:00

nix: use nixfmt-rfc-style

This commit is contained in:
Sam W 2025-12-05 15:48:11 +00:00
parent ef681a3ba8
commit 7c56f42779
17 changed files with 299 additions and 177 deletions

View File

@ -2,8 +2,12 @@
description = "Samw's home environment, as managed by nix/home-manager."; description = "Samw's home environment, as managed by nix/home-manager.";
inputs = { inputs = {
# Nixpkgs # Nixpkgs
nixpkgs = {url = "github:nixos/nixpkgs/release-25.05";}; nixpkgs = {
nixpkgs-unstable = {url = "github:nixos/nixpkgs";}; url = "github:nixos/nixpkgs/release-25.05";
};
nixpkgs-unstable = {
url = "github:nixos/nixpkgs";
};
# Other modules # Other modules
home-manager = { home-manager = {
url = "github:nix-community/home-manager/release-25.05"; url = "github:nix-community/home-manager/release-25.05";
@ -16,7 +20,9 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = inputs: let outputs =
inputs:
let
overlays = [ overlays = [
# Add our own local packages # Add our own local packages
(final: prev: { (final: prev: {
@ -28,31 +34,44 @@
ssh-tpm-agent = (import inputs.nixpkgs-unstable { system = prev.system; }).ssh-tpm-agent; ssh-tpm-agent = (import inputs.nixpkgs-unstable { system = prev.system; }).ssh-tpm-agent;
}) })
]; ];
in (rec { in
(
rec {
profiles = import ./home/profiles.nix; profiles = import ./home/profiles.nix;
lib = { lib = {
mkHome = { mkHome =
{
profiles, profiles,
system, system,
username ? "samw", username ? "samw",
}: }:
inputs.home-manager.lib.homeManagerConfiguration { inputs.home-manager.lib.homeManagerConfiguration {
pkgs = (import inputs.nixpkgs { pkgs = (
import inputs.nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; # Yes I know it's bad for me config.allowUnfree = true; # Yes I know it's bad for me
}); }
);
modules = [ modules = [
{ home = { {
home = {
inherit username; inherit username;
homeDirectory = homeDirectory =
if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin then
then "/Users/${username}" "/Users/${username}"
else "/home/${username}"; else
"/home/${username}";
stateVersion = "21.11"; stateVersion = "21.11";
};}] ++ profiles ++ [ };
}
]
++ profiles
++ [
{ nixpkgs.overlays = overlays; } { nixpkgs.overlays = overlays; }
# See comment in home/default.nix. # See comment in home/default.nix.
({ pkgs, ... }: { (
{ pkgs, ... }:
{
nix = { nix = {
enable = true; enable = true;
package = pkgs.nix; package = pkgs.nix;
@ -64,7 +83,8 @@
# every time you run nix shell. # every time you run nix shell.
registry.nixpkgs.flake = inputs.nixpkgs; registry.nixpkgs.flake = inputs.nixpkgs;
}; };
}) }
)
]; ];
extraSpecialArgs = { inherit system; }; extraSpecialArgs = { inherit system; };
}; };
@ -74,38 +94,59 @@
homeConfigurations = { homeConfigurations = {
zinc = lib.mkHome { zinc = lib.mkHome {
system = "aarch64-darwin"; system = "aarch64-darwin";
profiles = with profiles; [default dev dev-gui sensitive mac]; profiles = with profiles; [
default
dev
dev-gui
sensitive
mac
];
}; };
luroy = lib.mkHome { luroy = lib.mkHome {
system = "x86_64-linux"; system = "x86_64-linux";
profiles = with profiles; [default dev]; profiles = with profiles; [
default
dev
];
}; };
phosphorus = lib.mkHome { phosphorus = lib.mkHome {
system = "aarch64-darwin"; system = "aarch64-darwin";
profiles = with profiles; [default dev sensitive mac]; profiles = with profiles; [
default
dev
sensitive
mac
];
}; };
}; };
} }
# Per-system things # Per-system things
// (inputs.flake-utils.lib.eachDefaultSystem (system: let // (inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
overlays = overlays ++ [ inputs.devshell.overlays.default ]; overlays = overlays ++ [ inputs.devshell.overlays.default ];
}; };
platform = pkgs.lib.systems.elaborate system; platform = pkgs.lib.systems.elaborate system;
in { in
{
# Flake interface to my local packages. # Flake interface to my local packages.
# - `callPackage` puts some junk in mypkgs (`override` and # - `callPackage` puts some junk in mypkgs (`override` and
# `overrideDerivation`) so we filter out anything that isn't a derivation # `overrideDerivation`) so we filter out anything that isn't a derivation
# - We also filter out any packages that aren't supported on the current # - We also filter out any packages that aren't supported on the current
# platform. # platform.
packages = with pkgs.lib; (filterAttrs (_: v: (isDerivation v && meta.availableOn platform v)) pkgs.mypkgs); packages =
formatter = pkgs.alejandra; with pkgs.lib;
(filterAttrs (_: v: (isDerivation v && meta.availableOn platform v)) pkgs.mypkgs);
formatter = pkgs.nixfmt-tree;
# A devshell with useful utils # A devshell with useful utils
devShells.default = pkgs.devshell.mkShell { devShells.default = pkgs.devshell.mkShell {
packages = [ packages = [
inputs.home-manager.packages.${system}.default inputs.home-manager.packages.${system}.default
]; ];
}; };
}))); }
))
);
} }

View File

@ -1 +1,4 @@
{pkgs, ...}: {home.packages = with pkgs; [awscli2];} { pkgs, ... }:
{
home.packages = with pkgs; [ awscli2 ];
}

View File

@ -1,9 +1,11 @@
{ {
pkgs, pkgs,
... ...
}: let }:
let
packages = pkgs.callPackage ./packages.nix { }; packages = pkgs.callPackage ./packages.nix { };
in { in
{
home.packages = packages.all; home.packages = packages.all;
home.sessionVariables = { home.sessionVariables = {
EDITOR = "vim"; # is overriden to nvim in vim.nix if needed EDITOR = "vim"; # is overriden to nvim in vim.nix if needed
@ -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"; 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) "; username.format = "[$user]($style) ";
hostname.format = "[$hostname]($style) "; hostname.format = "[$hostname]($style) ";
directory = {truncation_length = -1;}; directory = {
truncation_length = -1;
};
git_branch.format = "[$symbol$branch]($style) "; git_branch.format = "[$symbol$branch]($style) ";
python.format = "[py \${pyenv_prefix}(\${version} )(\\($virtualenv\\) )]($style)"; python.format = "[py \${pyenv_prefix}(\${version} )(\\($virtualenv\\) )]($style)";
nodejs.format = "[js ($version )]($style)"; nodejs.format = "[js ($version )]($style)";

View File

@ -1 +1,7 @@
{pkgs, ...}: {home.packages = with pkgs; [docker colima];} { pkgs, ... }:
{
home.packages = with pkgs; [
docker
colima
];
}

View File

@ -1,5 +1,9 @@
{pkgs, ...}: { { pkgs, ... }:
home.packages = with pkgs; [ git-open tea ]; {
home.packages = with pkgs; [
git-open
tea
];
programs.git = { programs.git = {
enable = true; enable = true;
lfs.enable = true; lfs.enable = true;
@ -9,7 +13,9 @@
delta = { delta = {
# Better diffs # Better diffs
enable = true; enable = true;
options = {line-numbers = true;}; options = {
line-numbers = true;
};
}; };
aliases = { aliases = {
@ -36,8 +42,7 @@
sw = "switch"; sw = "switch";
swc = "switch --create"; swc = "switch --create";
gone = '' gone = ''! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D'';
! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D'';
}; };
extraConfig = { extraConfig = {
branch.sort = "-committerdate"; branch.sort = "-committerdate";

View File

@ -1,4 +1,5 @@
{pkgs, lib, ...}: { { pkgs, lib, ... }:
{
programs.gpg = { programs.gpg = {
enable = true; enable = true;
mutableKeys = false; mutableKeys = false;

View File

@ -1,4 +1,5 @@
{ ... }: { { ... }:
{
programs.helix = { programs.helix = {
enable = true; enable = true;
settings = { settings = {
@ -10,7 +11,8 @@
command = "basedpyright-langserver"; command = "basedpyright-langserver";
args = [ "--stdio" ]; args = [ "--stdio" ];
}; };
language = [{ language = [
{
name = "python"; name = "python";
roots = [ roots = [
"pyproject.toml" "pyproject.toml"
@ -18,10 +20,13 @@
"poetry.lock" "poetry.lock"
".git" ".git"
]; ];
language-servers = [{ language-servers = [
{
name = "basedpyright"; name = "basedpyright";
}]; }
}]; ];
}
];
}; };
}; };
} }

View File

@ -2,14 +2,19 @@
pkgs, pkgs,
lib, lib,
... ...
}: { }:
{
# Mac specific packages. # Mac specific packages.
# TODO: have this in a central packages place rather than here # 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 # Use secretive for SSH agent
programs.ssh.matchBlocks.all = lib.mkIf pkgs.stdenv.isDarwin { programs.ssh.matchBlocks.all = lib.mkIf pkgs.stdenv.isDarwin {
host = "*"; 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)"; programs.zsh.initContent = "eval $(/opt/homebrew/bin/brew shellenv)";
} }

View File

@ -1,5 +1,6 @@
{ pkgs }: { pkgs }:
with pkgs; rec { with pkgs;
rec {
# The stuff you want installed everywhere. The necessities. # The stuff you want installed everywhere. The necessities.
base = [ base = [
bat # cat replacement, aliased to cat in home-manager bat # cat replacement, aliased to cat in home-manager
@ -15,10 +16,23 @@ with pkgs; rec {
]; ];
# Networking shit # Networking shit
net = [dig iperf3 nmap socat tcpdump whois]; net = [
dig
iperf3
nmap
socat
tcpdump
whois
];
# development tools # development tools
dev = [jq nixfmt-rfc-style gh glab hexyl ]; dev = [
jq
nixfmt-rfc-style
gh
glab
hexyl
];
all = base ++ net ++ dev; all = base ++ net ++ dev;
} }

View File

@ -1,8 +1,11 @@
{pkgs, ...}: { { pkgs, ... }:
{
home.packages = with pkgs; [ yubikey-manager ]; home.packages = with pkgs; [ yubikey-manager ];
programs.password-store = { programs.password-store = {
enable = true; enable = true;
settings = {PASSWORD_STORE_DIR = "$HOME/.password-store";}; settings = {
PASSWORD_STORE_DIR = "$HOME/.password-store";
};
package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]);
}; };
programs.zsh.shellAliases = { programs.zsh.shellAliases = {

View File

@ -2,17 +2,28 @@
# The basics that you'll want everywhere # The basics that you'll want everywhere
default = ./default.nix; default = ./default.nix;
# A machine for development # A machine for development
dev = {...}: { dev =
imports = [./git.nix ./vim.nix ./vim-dev ./helix.nix]; { ... }:
{
imports = [
./git.nix
./vim.nix
./vim-dev
./helix.nix
];
}; };
# A machine for dev with a GUI # A machine for dev with a GUI
# TODO: detect this automatically somehow? # TODO: detect this automatically somehow?
dev-gui = {...}: { dev-gui =
{ ... }:
{
imports = [ ./vscode.nix ]; imports = [ ./vscode.nix ];
}; };
tpmssh = ./tpmssh.nix; tpmssh = ./tpmssh.nix;
# Sensitive stuff # Sensitive stuff
sensitive = {...}: { sensitive =
{ ... }:
{
imports = [ imports = [
./passwords.nix ./passwords.nix
./gpg.nix ./gpg.nix
@ -25,5 +36,13 @@
# A machine you want to do aws stuff on # A machine you want to do aws stuff on
aws = ./aws.nix; aws = ./aws.nix;
# A server # A server
server = {...}: {imports = [./default.nix ./git.nix ./vim.nix];}; server =
{ ... }:
{
imports = [
./default.nix
./git.nix
./vim.nix
];
};
} }

View File

@ -1,5 +1,6 @@
# Enable tpm-ssh-agent in a systemd user service # Enable tpm-ssh-agent in a systemd user service
{pkgs, config, ...}: { { pkgs, config, ... }:
{
home.packages = [ pkgs.ssh-tpm-agent ]; home.packages = [ pkgs.ssh-tpm-agent ];
home.sessionVariables = { home.sessionVariables = {
SSH_AUTH_SOCK = "$(${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent --print-socket)"; SSH_AUTH_SOCK = "$(${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent --print-socket)";
@ -22,11 +23,18 @@
Environment = '' Environment = ''
SSH_AUTH_SOCK="%t/ssh-tpm-agent.sock" SSH_AUTH_SOCK="%t/ssh-tpm-agent.sock"
''; '';
ExecStart = "${pkgs.writeShellScriptBin "start-ssh-tpm-agent" (if config.services.gpg-agent.enableSshSupport then '' 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) ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent -A $(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket)
'' else '' ''
else
''
${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent ${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent
'')}/bin/start-ssh-tpm-agent"; ''
)
}/bin/start-ssh-tpm-agent";
PassEnvironment = "SSH_AGENT_PID"; PassEnvironment = "SSH_AGENT_PID";
SuccessExitStatus = 2; SuccessExitStatus = 2;
Type = "simple"; Type = "simple";

View File

@ -3,9 +3,11 @@
lib, lib,
system, system,
... ...
}: { }:
{
home.packages = with pkgs; [ nil ]; home.packages = with pkgs; [ nil ];
programs.neovim.plugins = with pkgs.vimPlugins; programs.neovim.plugins =
with pkgs.vimPlugins;
[ [
# More fancy shit # More fancy shit
nvim-treesitter nvim-treesitter

View File

@ -4,7 +4,8 @@
pkgs, pkgs,
lib, lib,
... ...
}: { }:
{
home.sessionVariables.EDITOR = lib.mkForce "nvim"; home.sessionVariables.EDITOR = lib.mkForce "nvim";
home.packages = with pkgs; [ ripgrep ]; home.packages = with pkgs; [ ripgrep ];
programs.neovim = { programs.neovim = {
@ -26,7 +27,7 @@
vim-gitgutter vim-gitgutter
# More stuff idk # More stuff idk
emmet-vim emmet-vim
vim-sleuth # guess whitespace settings from file vim-sleuth # guess whitespace settings from file
]; ];
extraConfig = '' extraConfig = ''
lua <<EOF lua <<EOF

View File

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.vscodium; package = pkgs.vscodium;

View File

@ -1,4 +1,5 @@
# TODO: auto import everything # TODO: auto import everything
{pkgs, ...}: { { pkgs, ... }:
{
qrclip = pkgs.callPackage ./qrclip { }; qrclip = pkgs.callPackage ./qrclip { };
} }

View File

@ -2,11 +2,14 @@
pkgs, pkgs,
lib, lib,
stdenv, stdenv,
}: let }:
let
zbar = pkgs.zbar.override { enableVideo = false; }; zbar = pkgs.zbar.override { enableVideo = false; };
in in
(pkgs.writeShellScriptBin "qrclip" '' (pkgs.writeShellScriptBin "qrclip" ''
set -eo pipefail set -eo pipefail
${pkgs.pngpaste}/bin/pngpaste - | ${zbar}/bin/zbarimg --raw -q1 - ${pkgs.pngpaste}/bin/pngpaste - | ${zbar}/bin/zbarimg --raw -q1 -
'') '')
// {meta.platforms = lib.platforms.darwin;} // {
meta.platforms = lib.platforms.darwin;
}