Formats files

This commit is contained in:
Abhinav Sarkar 2024-10-22 18:53:09 +05:30
parent 1285ab1d85
commit 1ec4716f88
17 changed files with 303 additions and 111 deletions

View File

@ -1,3 +1,8 @@
{ pkgs, inputs, ... }: { { pkgs, inputs, ... }:
imports = [ ./nix.nix ./system.nix ./services.nix ]; {
imports = [
./nix.nix
./system.nix
./services.nix
];
} }

View File

@ -38,21 +38,37 @@
}; };
}; };
outputs = inputs@{ self, nixpkgs, nixpkgs-stable, nix-darwin, home-manager, lix-module, ... }: outputs =
inputs@{
self,
nixpkgs,
nixpkgs-stable,
nix-darwin,
home-manager,
lix-module,
...
}:
let let
system = "x86_64-darwin"; system = "x86_64-darwin";
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config = { allowUnfree = true; }; config = {
allowUnfree = true;
};
}; };
pkgs-stable = import nixpkgs-stable { pkgs-stable = import nixpkgs-stable {
inherit system; inherit system;
config = { allowUnfree = true; }; config = {
allowUnfree = true;
};
}; };
in { in
{
darwinConfigurations."Abhinavs-MacBook-Pro" = nix-darwin.lib.darwinSystem { darwinConfigurations."Abhinavs-MacBook-Pro" = nix-darwin.lib.darwinSystem {
inherit system; inherit system;
specialArgs = { inherit inputs pkgs-stable; }; specialArgs = {
inherit inputs pkgs-stable;
};
modules = [ modules = [
./configuration.nix ./configuration.nix
./homebrew.nix ./homebrew.nix
@ -63,12 +79,17 @@
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup"; home-manager.backupFileExtension = "backup";
home-manager.users.abhinav = import ./home.nix; home-manager.users.abhinav = import ./home.nix;
home-manager.extraSpecialArgs = { inherit inputs pkgs-stable; }; home-manager.extraSpecialArgs = {
inherit inputs pkgs-stable;
};
} }
]; ];
}; };
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [ (import home-manager { inherit pkgs; }).home-manager just ]; buildInputs = with pkgs; [
(import home-manager { inherit pkgs; }).home-manager
just
];
shellHook = '' shellHook = ''
export NIXPKGS_PATH=${pkgs.path}; export NIXPKGS_PATH=${pkgs.path};
''; '';

View File

@ -1,8 +1,19 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let username = config.home.username; let
in { username = config.home.username;
imports = [ ./programs ./scripts ./launchd.nix ]; in
{
imports = [
./programs
./scripts
./launchd.nix
];
home = { home = {
username = "abhinav"; username = "abhinav";
@ -22,12 +33,14 @@ in {
cat = "${pkgs.bat}/bin/bat"; cat = "${pkgs.bat}/bin/bat";
}; };
file."Applications/Home Manager Apps".source = let file."Applications/Home Manager Apps".source =
apps = pkgs.buildEnv { let
name = "home-manager-applications"; apps = pkgs.buildEnv {
paths = config.home.packages; name = "home-manager-applications";
pathsToLink = "/Applications"; paths = config.home.packages;
}; pathsToLink = "/Applications";
in "${apps}/Applications"; };
in
"${apps}/Applications";
}; };
} }

View File

@ -1,4 +1,5 @@
{ ... }: { { ... }:
{
homebrew = { homebrew = {
enable = true; enable = true;
onActivation = { onActivation = {

View File

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
binPath = "${pkgs.coreutils-full}/bin"; binPath = "${pkgs.coreutils-full}/bin";
@ -8,7 +13,8 @@ let
${binPath}/echo && ${binPath}/date ${binPath}/echo && ${binPath}/date
${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns --debug home.abhinavsarkar.net ${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns --debug home.abhinavsarkar.net
''; '';
in { in
{
launchd.agents.dyndns-updater = lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin { launchd.agents.dyndns-updater = lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
enable = true; enable = true;
config = { config = {

52
nix.nix
View File

@ -1,18 +1,27 @@
{ config, pkgs, inputs, ... }: {
config,
pkgs,
inputs,
...
}:
let let
nixSettings = { nixSettings = {
auto-optimise-store = true; auto-optimise-store = true;
connect-timeout = 60; connect-timeout = 60;
download-attempts = 10; download-attempts = 10;
cores = 4; cores = 4;
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
fallback = true; fallback = true;
keep-outputs = true; keep-outputs = true;
keep-going = true; keep-going = true;
log-lines = 25; log-lines = 25;
max-jobs = 3; max-jobs = 3;
}; };
in { in
{
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
@ -33,8 +42,10 @@ in {
min-free = 128000000; min-free = 128000000;
warn-dirty = false; warn-dirty = false;
trusted-users = [ "@admin" ]; trusted-users = [ "@admin" ];
trusted-substituters = trusted-substituters = [
[ "https://cache.nixos.org" "https://nix-community.cachix.org" ]; "https://cache.nixos.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [ trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
@ -45,20 +56,25 @@ in {
linux-builder = { linux-builder = {
enable = true; enable = true;
maxJobs = 3; maxJobs = 3;
config = ({ pkgs, ... }: { config = (
users.extraGroups.docker.members = { pkgs, ... }:
builtins.map (i: "nixbld" + builtins.toString i) {
(pkgs.lib.genList (i: i + 1) 32); users.extraGroups.docker.members = builtins.map (i: "nixbld" + builtins.toString i) (
virtualisation = { pkgs.lib.genList (i: i + 1) 32
docker.enable = true; );
darwin-builder = { virtualisation = {
diskSize = 50 * 1024; docker.enable = true;
memorySize = 8 * 1024; darwin-builder = {
diskSize = 50 * 1024;
memorySize = 8 * 1024;
};
cores = 8;
}; };
cores = 8; nix.settings = nixSettings // {
}; sandbox = false;
nix.settings = nixSettings // { sandbox = false; }; };
}); }
);
}; };
}; };
nixpkgs = { nixpkgs = {

View File

@ -1,6 +1,12 @@
{ dm-mono-src, lib, pkgs }: {
dm-mono-src,
lib,
pkgs,
}:
pkgs.linkFarm "dm-mono" [{ pkgs.linkFarm "dm-mono" [
name = "share/fonts/truetype"; {
path = "${dm-mono-src}/exports"; name = "share/fonts/truetype";
}] path = "${dm-mono-src}/exports";
}
]

View File

@ -1,6 +1,12 @@
{ monaspace-src, lib, pkgs }: {
monaspace-src,
lib,
pkgs,
}:
pkgs.linkFarm "monaspace" [{ pkgs.linkFarm "monaspace" [
name = "share/fonts/truetype"; {
path = "${monaspace-src}/fonts/variable"; name = "share/fonts/truetype";
}] path = "${monaspace-src}/fonts/variable";
}
]

View File

@ -1,4 +1,10 @@
{ inputs, config, pkgs, pkgs-stable, ... }: {
inputs,
config,
pkgs,
pkgs-stable,
...
}:
let let
leanHaskellBinary = pkgs.haskell.lib.compose.overrideCabal (old: { leanHaskellBinary = pkgs.haskell.lib.compose.overrideCabal (old: {
@ -8,7 +14,7 @@ let
enableSharedLibraries = false; enableSharedLibraries = false;
enableSeparateBinOutput = true; enableSeparateBinOutput = true;
}); });
opaComplete = name: pkgs.haskellPackages.generateOptparseApplicativeCompletions [name]; opaComplete = name: pkgs.haskellPackages.generateOptparseApplicativeCompletions [ name ];
nixPackages = with pkgs; [ nixPackages = with pkgs; [
config.nix.package config.nix.package
niv niv
@ -22,8 +28,26 @@ let
cachix cachix
nix-output-monitor nix-output-monitor
]; ];
networkingPackages = with pkgs; [ curl dig httpie openssh ] ++ [ pkgs-stable.mosh ]; networkingPackages =
cmdLineUtilPackages = with pkgs; [ bash broot coreutils-full fd gnugrep less ranger tree unixtools.watch ]; with pkgs;
[
curl
dig
httpie
openssh
]
++ [ pkgs-stable.mosh ];
cmdLineUtilPackages = with pkgs; [
bash
broot
coreutils-full
fd
gnugrep
less
ranger
tree
unixtools.watch
];
miscPackages = with pkgs; [ miscPackages = with pkgs; [
as-tree as-tree
binutils binutils
@ -56,10 +80,24 @@ let
source-code-pro source-code-pro
(pkgs.callPackage ../packages/dm-mono.nix { dm-mono-src = "${inputs.dm-mono-font}"; }) (pkgs.callPackage ../packages/dm-mono.nix { dm-mono-src = "${inputs.dm-mono-font}"; })
(pkgs.callPackage ../packages/monaspace.nix { monaspace-src = "${inputs.monaspace-font}"; }) (pkgs.callPackage ../packages/monaspace.nix { monaspace-src = "${inputs.monaspace-font}"; })
(nerdfonts.override { fonts = [ "Monoid" "Agave" "Iosevka" "Lekton" "VictorMono" ]; }) (nerdfonts.override {
fonts = [
"Monoid"
"Agave"
"Iosevka"
"Lekton"
"VictorMono"
];
})
];
in
{
imports = [
./fish.nix
./git.nix
./starship.nix
./vscode.nix
]; ];
in {
imports = [ ./fish.nix ./git.nix ./starship.nix ./vscode.nix ];
home.packages = nixPackages ++ networkingPackages ++ cmdLineUtilPackages ++ miscPackages ++ fonts; home.packages = nixPackages ++ networkingPackages ++ cmdLineUtilPackages ++ miscPackages ++ fonts;
@ -85,7 +123,9 @@ in {
direnv = { direnv = {
enable = true; enable = true;
nix-direnv = { enable = true; }; nix-direnv = {
enable = true;
};
}; };
nix-index = { nix-index = {
@ -107,7 +147,11 @@ in {
enable = true; enable = true;
enableFishIntegration = true; enableFishIntegration = true;
fileWidgetCommand = "fd --type f --no-ignore"; fileWidgetCommand = "fd --type f --no-ignore";
historyWidgetOptions = [ "--reverse" "--sort" "--exact" ]; historyWidgetOptions = [
"--reverse"
"--sort"
"--exact"
];
}; };
micro = { micro = {

View File

@ -1,4 +1,10 @@
{ inputs, config, osConfig, pkgs, ... }: {
inputs,
config,
osConfig,
pkgs,
...
}:
let let
username = config.home.username; username = config.home.username;
@ -10,7 +16,8 @@ let
gruvbox gruvbox
]; ];
in { in
{
programs.fish = { programs.fish = {
enable = true; enable = true;
@ -21,8 +28,7 @@ in {
functions = { functions = {
where = "readlink -f (which $argv)"; where = "readlink -f (which $argv)";
ghe = ghe = "set -l dir (mktemp -d); git clone --depth 1 https://github.com/$argv $dir; cd $dir; ranger;";
"set -l dir (mktemp -d); git clone --depth 1 https://github.com/$argv $dir; cd $dir; ranger;";
nix-roots = '' nix-roots = ''
nix-store --gc --print-roots | grep -v lsof | grep -v libproc | grep -v "{temp:" nix-store --gc --print-roots | grep -v lsof | grep -v libproc | grep -v "{temp:"
''; '';

View File

@ -18,8 +18,7 @@
ca = "commit --amend --no-edit"; ca = "commit --amend --no-edit";
cm = "commit -m"; cm = "commit -m";
pf = "push --force-with-lease"; pf = "push --force-with-lease";
lg = lg = "log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'";
"log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'";
uc = "reset --soft HEAD~1"; uc = "reset --soft HEAD~1";
}; };
@ -40,7 +39,9 @@
hunk-header-line-number-style = "#067a00"; hunk-header-line-number-style = "#067a00";
hunk-header-style = "file line-number syntax"; hunk-header-style = "file line-number syntax";
}; };
interactive = { keep-plus-minus-markers = false; }; interactive = {
keep-plus-minus-markers = false;
};
}; };
}; };
@ -53,10 +54,17 @@
rebase.autoStash = true; rebase.autoStash = true;
core = { core = {
editor = "micro"; editor = "micro";
}; };
merge.conflictstyle = "diff3"; merge.conflictstyle = "diff3";
}; };
ignores = [ "*.swp" "*~" "#*" ".DS_Store" ".direnv/" ".vscode/" ]; ignores = [
"*.swp"
"*~"
"#*"
".DS_Store"
".direnv/"
".vscode/"
];
}; };
} }

View File

@ -1,7 +1,26 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let langs = [ "c" "golang" "haskell" "java" "kotlin" "nodejs" "python" "perl" "ruby" "rust" "zig" ]; let
in { langs = [
"c"
"golang"
"haskell"
"java"
"kotlin"
"nodejs"
"python"
"perl"
"ruby"
"rust"
"zig"
];
in
{
programs.starship = { programs.starship = {
enable = true; enable = true;
enableFishIntegration = true; enableFishIntegration = true;
@ -58,16 +77,17 @@ in {
sudo.symbol = "sudo "; sudo.symbol = "sudo ";
zig.symbol = "zig "; zig.symbol = "zig ";
} }
(lib.attrsets.foldAttrs (i: _: i) [ ] (builtins.map (s: { (lib.attrsets.foldAttrs (i: _: i) [ ] (
"${s}" = { builtins.map (s: {
"version_format" = "\${raw}"; "${s}" = {
"format" = "\\[[$symbol($version)]($style)\\]"; "version_format" = "\${raw}";
}; "format" = "\\[[$symbol($version)]($style)\\]";
}) langs)) };
}) langs
))
{ {
c.format = "\\[[$symbol($version(-$name))]($style)\\]"; c.format = "\\[[$symbol($version(-$name))]($style)\\]";
python.format = python.format = "\\[[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style)\\]";
"\\[[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style)\\]";
} }
]; ];
}; };

View File

@ -1,19 +1,28 @@
{ inputs, config, pkgs, ... }: {
inputs,
config,
pkgs,
...
}:
let let
lib = pkgs.lib; lib = pkgs.lib;
extension = extension = (
(inputs.nix-vscode-extensions.extensions.${pkgs.system}.forVSCodeVersion inputs.nix-vscode-extensions.extensions.${pkgs.system}.forVSCodeVersion pkgs.vscode.version
pkgs.vscode.version); );
marketplace-prerelease = extension.vscode-marketplace; marketplace-prerelease = extension.vscode-marketplace;
marketplace-release = extension.vscode-marketplace-release; marketplace-release = extension.vscode-marketplace-release;
resolveExtension = ex: resolveExtension =
let exParts = lib.strings.splitString "." ex; ex:
in if lib.attrsets.hasAttrByPath exParts marketplace-release then let
exParts = lib.strings.splitString "." ex;
in
if lib.attrsets.hasAttrByPath exParts marketplace-release then
lib.attrsets.getAttrFromPath exParts marketplace-release lib.attrsets.getAttrFromPath exParts marketplace-release
else else
lib.attrsets.getAttrFromPath exParts marketplace-prerelease; lib.attrsets.getAttrFromPath exParts marketplace-prerelease;
in { in
{
programs.vscode = { programs.vscode = {
enable = true; enable = true;
mutableExtensionsDir = false; mutableExtensionsDir = false;
@ -66,8 +75,7 @@ in {
accessibilitySupport = "off"; accessibilitySupport = "off";
bracketPairColorization.enabled = true; bracketPairColorization.enabled = true;
folding = false; folding = false;
fontFamily = fontFamily = "'DM Mono', NanumGothicCoding, Menlo, Monaco, 'Courier New', monospace";
"'DM Mono', NanumGothicCoding, Menlo, Monaco, 'Courier New', monospace";
fontLigatures = true; fontLigatures = true;
fontSize = 13; fontSize = 13;
guides = { guides = {
@ -115,14 +123,17 @@ in {
plugin.tactics.config.timeout_duration = 5; plugin.tactics.config.timeout_duration = 5;
}; };
roc-lang.language-server.exe = roc-lang.language-server.exe = "/nix/store/1m7xfjx1b79s39cxl52aq77z22yffs4a-roc-0.0.1/bin/roc_language_server";
"/nix/store/1m7xfjx1b79s39cxl52aq77z22yffs4a-roc-0.0.1/bin/roc_language_server";
nix = { nix = {
formatterPath = "${pkgs.nixfmt}/bin/nixfmt"; formatterPath = "${pkgs.nixfmt}/bin/nixfmt";
enableLanguageServer = true; enableLanguageServer = true;
serverPath = "nixd"; serverPath = "nixd";
serverSettings = { nixd = { formatting.command = [ "nixfmt" ]; }; }; serverSettings = {
nixd = {
formatting.command = [ "nixfmt" ];
};
};
}; };
oneDarkPro = { oneDarkPro = {
@ -131,7 +142,10 @@ in {
}; };
spellright = { spellright = {
documentTypes = [ "markdown" "latex" ]; documentTypes = [
"markdown"
"latex"
];
language = [ "en" ]; language = [ "en" ];
}; };
@ -142,8 +156,7 @@ in {
terminal.integrated = { terminal.integrated = {
copyOnSelection = true; copyOnSelection = true;
fontFamily = fontFamily = "'DM Mono', NanumGothicCoding, Menlo, Monaco, 'Courier New', monospace";
"'DM Mono', NanumGothicCoding, Menlo, Monaco, 'Courier New', monospace";
scrollback = 10000; scrollback = 10000;
shell.osx = "${pkgs.fish}/bin/fish"; shell.osx = "${pkgs.fish}/bin/fish";
shellIntegration.enabled = true; shellIntegration.enabled = true;
@ -164,12 +177,23 @@ in {
update.mode = "none"; update.mode = "none";
"[haskell]" = { editor.defaultFormatter = "haskell.haskell"; }; "[haskell]" = {
"[javascript]" = { editor.defaultFormatter = "esbenp.prettier-vscode"; }; editor.defaultFormatter = "haskell.haskell";
"[json]" = { editor.defaultFormatter = "esbenp.prettier-vscode"; }; };
"[python]" = { editor.defaultFormatter = "ms-python.black-formatter"; }; "[javascript]" = {
editor.defaultFormatter = "esbenp.prettier-vscode";
};
"[json]" = {
editor.defaultFormatter = "esbenp.prettier-vscode";
};
"[python]" = {
editor.defaultFormatter = "ms-python.black-formatter";
};
black-formatter.args = [ "--line-length" "100" ]; black-formatter.args = [
"--line-length"
"100"
];
}; };
keybindings = [ keybindings = [

View File

@ -1,3 +1,10 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ home.packages = []; } {
home.packages = [ ];
}

View File

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
services = { services = {
jankyborders = { jankyborders = {

View File

@ -1,6 +1,9 @@
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock); (import (
in fetchTarball { let
url = lock = builtins.fromJSON (builtins.readFile ./flake.lock);
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; in
sha256 = lock.nodes.flake-compat.locked.narHash; fetchTarball {
}) { src = ./.; }).shellNix url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).shellNix

View File

@ -1,4 +1,5 @@
{ pkgs, inputs, ... }: { { pkgs, inputs, ... }:
{
security.pam.enableSudoTouchIdAuth = true; security.pam.enableSudoTouchIdAuth = true;
system = { system = {
checks.verifyNixChannels = true; checks.verifyNixChannels = true;