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, ... }: {
imports = [ ./nix.nix ./system.nix ./services.nix ];
{ pkgs, inputs, ... }:
{
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
system = "x86_64-darwin";
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
config = {
allowUnfree = true;
};
};
pkgs-stable = import nixpkgs-stable {
inherit system;
config = { allowUnfree = true; };
config = {
allowUnfree = true;
};
};
in {
in
{
darwinConfigurations."Abhinavs-MacBook-Pro" = nix-darwin.lib.darwinSystem {
inherit system;
specialArgs = { inherit inputs pkgs-stable; };
specialArgs = {
inherit inputs pkgs-stable;
};
modules = [
./configuration.nix
./homebrew.nix
@ -63,12 +79,17 @@
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
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 {
buildInputs = with pkgs; [ (import home-manager { inherit pkgs; }).home-manager just ];
buildInputs = with pkgs; [
(import home-manager { inherit pkgs; }).home-manager
just
];
shellHook = ''
export NIXPKGS_PATH=${pkgs.path};
'';

View File

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

View File

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

View File

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

52
nix.nix
View File

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

View File

@ -1,6 +1,12 @@
{ dm-mono-src, lib, pkgs }:
{
dm-mono-src,
lib,
pkgs,
}:
pkgs.linkFarm "dm-mono" [{
name = "share/fonts/truetype";
path = "${dm-mono-src}/exports";
}]
pkgs.linkFarm "dm-mono" [
{
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" [{
name = "share/fonts/truetype";
path = "${monaspace-src}/fonts/variable";
}]
pkgs.linkFarm "monaspace" [
{
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
leanHaskellBinary = pkgs.haskell.lib.compose.overrideCabal (old: {
@ -8,7 +14,7 @@ let
enableSharedLibraries = false;
enableSeparateBinOutput = true;
});
opaComplete = name: pkgs.haskellPackages.generateOptparseApplicativeCompletions [name];
opaComplete = name: pkgs.haskellPackages.generateOptparseApplicativeCompletions [ name ];
nixPackages = with pkgs; [
config.nix.package
niv
@ -22,8 +28,26 @@ let
cachix
nix-output-monitor
];
networkingPackages = with pkgs; [ curl dig httpie openssh ] ++ [ pkgs-stable.mosh ];
cmdLineUtilPackages = with pkgs; [ bash broot coreutils-full fd gnugrep less ranger tree unixtools.watch ];
networkingPackages =
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; [
as-tree
binutils
@ -56,10 +80,24 @@ let
source-code-pro
(pkgs.callPackage ../packages/dm-mono.nix { dm-mono-src = "${inputs.dm-mono-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;
@ -85,7 +123,9 @@ in {
direnv = {
enable = true;
nix-direnv = { enable = true; };
nix-direnv = {
enable = true;
};
};
nix-index = {
@ -107,7 +147,11 @@ in {
enable = true;
enableFishIntegration = true;
fileWidgetCommand = "fd --type f --no-ignore";
historyWidgetOptions = [ "--reverse" "--sort" "--exact" ];
historyWidgetOptions = [
"--reverse"
"--sort"
"--exact"
];
};
micro = {

View File

@ -1,4 +1,10 @@
{ inputs, config, osConfig, pkgs, ... }:
{
inputs,
config,
osConfig,
pkgs,
...
}:
let
username = config.home.username;
@ -10,7 +16,8 @@ let
gruvbox
];
in {
in
{
programs.fish = {
enable = true;
@ -21,8 +28,7 @@ in {
functions = {
where = "readlink -f (which $argv)";
ghe =
"set -l dir (mktemp -d); git clone --depth 1 https://github.com/$argv $dir; cd $dir; ranger;";
ghe = "set -l dir (mktemp -d); git clone --depth 1 https://github.com/$argv $dir; cd $dir; ranger;";
nix-roots = ''
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";
cm = "commit -m";
pf = "push --force-with-lease";
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)'";
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)'";
uc = "reset --soft HEAD~1";
};
@ -40,7 +39,9 @@
hunk-header-line-number-style = "#067a00";
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;
core = {
editor = "micro";
};
};
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" ];
in {
let
langs = [
"c"
"golang"
"haskell"
"java"
"kotlin"
"nodejs"
"python"
"perl"
"ruby"
"rust"
"zig"
];
in
{
programs.starship = {
enable = true;
enableFishIntegration = true;
@ -58,16 +77,17 @@ in {
sudo.symbol = "sudo ";
zig.symbol = "zig ";
}
(lib.attrsets.foldAttrs (i: _: i) [ ] (builtins.map (s: {
"${s}" = {
"version_format" = "\${raw}";
"format" = "\\[[$symbol($version)]($style)\\]";
};
}) langs))
(lib.attrsets.foldAttrs (i: _: i) [ ] (
builtins.map (s: {
"${s}" = {
"version_format" = "\${raw}";
"format" = "\\[[$symbol($version)]($style)\\]";
};
}) langs
))
{
c.format = "\\[[$symbol($version(-$name))]($style)\\]";
python.format =
"\\[[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style)\\]";
python.format = "\\[[\${symbol}\${pyenv_prefix}(\${version})(\\($virtualenv\\))]($style)\\]";
}
];
};

View File

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

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 = {
jankyborders = {

View File

@ -1,6 +1,9 @@
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
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
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
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;
system = {
checks.verifyNixChannels = true;