diff --git a/.envrc b/.envrc index 9834d0e..2b67239 100644 --- a/.envrc +++ b/.envrc @@ -1,6 +1,16 @@ -# If nix-shell available, then nix is installed. We're going to use nix-direnv. -if command -v nix-shell &> /dev/null -then - use flake -fi +#! /bin/sh + +source "$( + nix eval \ + --no-update-lock-file \ + --no-write-lock-file \ + --no-warn-dirty \ + --accept-flake-config \ + .#__std.direnv_lib 2>/dev/null \ + || nix eval .#__std.direnv_lib # show the errors +)" +# FIXME: This should check if $USER is in userShells, if not, +# fall back to `use nix` +use std nix "//repo/userShells:${USER}" + diff --git a/.gitignore b/.gitignore index e69de29..726d2d6 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.direnv diff --git a/.sops.yaml b/.sops.yaml new file mode 100644 index 0000000..8d30b9a --- /dev/null +++ b/.sops.yaml @@ -0,0 +1,16 @@ +keys: + - &htran-mbp age1jpm9mtxz6n8vncrk6pk7dppj3r7qxfj5hsgvcdulmp3lxvxez94qvxlgay + - &htran age1jw958shpwu7st8sc4z0fufuswmfpxfc9wl3df9g3f3y57m45j92syr0mng + - &bao age1umzkd4k0xt6uv5de85fpc4uztrph86nsd79h5f8cpuvtpy8n6adss7q2fv + - &root_bao age1vx7e6vz9zptwqd0cakjj8erqv58cstddama8zcrppc36rqqmlvjs53x9u0 + - &htran1 age1vkd39dmrft3uk5wnfqppharn38dhrh78ev6pl85u005jhcge5e9qz4lt79 +creation_rules: + - path_regex: .* + key_groups: + - age: + - *htran + - *htran-mbp + - *bao + - *root_bao + - *htran1 + diff --git a/README.md b/README.md index 8b8dc70..f11cddb 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ Contains my configurations for the software I use. I'm looking to move forward to configuration with NixOS, but until I get a bit more experiment on NixOS, I'll keep this repository as simple as possible. +- As of 2023-06-07, I have little interest in keeping configurations +([`init.lua`](./native_configs/neovim/init.lua), [`sshconfig`](./native_configs/ssh/config),...) +to be idempotent for Nix and non-Nix targets. + ## Nix Monorepo that contains my commonly used personal environments. @@ -13,8 +17,7 @@ onto this repo for quick env setup (especially devel) on new machines. ## How do I apply these config -- I will always first clone this repository, preferably from local source before -going from the github. `git clone https://github.com/pegasust/dotfiles` +- Clone and nixify ### neovim @@ -26,7 +29,6 @@ My main text editor. It's based on `vim`, but stays loyal to `lua` ecosystem #### Notes - Ensure that neovim is installed and invocable by `nvim`. -- My config based on rather experimental version of`nvim` (>=0.7.2) - For information on installing neovim, visit their [github page](https://github.com/neovim/neovim/wiki/Installing-Neovim) ### tmux @@ -40,7 +42,7 @@ from one terminal. #### Notes -- Unsure if the minimum version of tmux. I have had an ancient HPC server +- Unsure of the minimum version of tmux. I have had an ancient HPC server that does not respond well to one of the config lines. ### zk @@ -57,4 +59,23 @@ text-editor agnostically. - Templates: `zk/templates/` - Command: `ln -s $PWD/zk/templates ~/.config/zk/templates` +Note (2023-06-07): I'm now using a mix of nvim-zk with Notion. I'm still figuring out +a centralize place to put my notes and use it to do some knowledge graph magic + +## Troubleshoots + +### My MacOS just updated, `nix` is no-longer here + +- An easy fix is to add the following to the **bottom** of `/etc/zshrc` + +```sh +# Nix {{{ +if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then + . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' +fi +# }}} +``` + +- Otherwise, consult [`gh-gist:meeech/a_help-osx-borked-my-nix.md`](https://gist.github.com/meeech/0b97a86f235d10bc4e2a1116eec38e7e) + diff --git a/c_.nix b/c_.nix deleted file mode 100644 index 8e787e9..0000000 --- a/c_.nix +++ /dev/null @@ -1,100 +0,0 @@ -# a small helper that only builds on top of builtins functions -{src}@inputs: -builtins // (let -formatSecondsSinceEpoch = t: -let -rem = x: y: x - x / y * y; -days = t / 86400; -secondsInDay = rem t 86400; -hours = secondsInDay / 3600; -minutes = (rem secondsInDay 3600) / 60; -seconds = rem t 60; - -# Courtesy of https://stackoverflow.com/a/32158604. -z = days + 719468; -era = (if z >= 0 then z else z - 146096) / 146097; -doe = z - era * 146097; -yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; -y = yoe + era * 400; -doy = doe - (365 * yoe + yoe / 4 - yoe / 100); -mp = (5 * doy + 2) / 153; -d = doy - (153 * mp + 2) / 5 + 1; -m = mp + (if mp < 10 then 3 else -9); -y' = y + (if m <= 2 then 1 else 0); - -pad = s: if builtins.stringLength s < 2 then "0" + s else s; -in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}" -+ "${pad (toString minutes)}${pad (toString seconds)}"; - -fetchTree = -# this is the value of flake.lock#lock.nodes.${input_name}.locked -{type -, host? "" -, owner? "" -, repo? "" -, rev? "" -, submodules? "" -, path? "" -, narHash? null -, lastModified? 0 -}@info: -if info.type == "github" then -{ outPath = - fetchTarball - ({ url = "https://api.${info.host or "github.com"}/repos/" - + "${info.owner}/${info.repo}/tarball/${info.rev}"; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); - rev = info.rev; - shortRev = builtins.substring 0 7 info.rev; - lastModified = info.lastModified; - lastModifiedDate = formatSecondsSinceEpoch info.lastModified; - narHash = info.narHash; -} -else if info.type == "git" then -{ outPath = - builtins.fetchGit - ({ url = info.url; } - // (if info ? rev then { inherit (info) rev; } else {}) - // (if info ? ref then { inherit (info) ref; } else {}) - // (if info ? submodules then { inherit (info) submodules; } else {}) - ); - lastModified = info.lastModified; - lastModifiedDate = formatSecondsSinceEpoch info.lastModified; - narHash = info.narHash; -} // (if info ? rev then { -rev = info.rev; -shortRev = builtins.substring 0 7 info.rev; -} else { -}) -else if info.type == "path" then -{ outPath = builtins.path { - path = if builtins.substring 0 1 info.path != "/" - then src + ("/" + info.path) # make this absolute path by prepending ./ - else info.path; # it's already an absolute path - }; -narHash = info.narHash; -} -else if info.type == "tarball" then -{ outPath = - fetchTarball - ({ inherit (info) url; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); -} -else if info.type == "gitlab" then -{ inherit (info) rev narHash lastModified; - outPath = - fetchTarball - ({ url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); - shortRev = builtins.substring 0 7 info.rev; -} -else -# FIXME: add Mercurial, tarball inputs. -throw "flake input has unsupported input type '${info.type}'"; -in { - inherit fetchTree; -}) - diff --git a/credentials.yml b/credentials.yml new file mode 100644 index 0000000..0194ef6 --- /dev/null +++ b/credentials.yml @@ -0,0 +1,97 @@ +credentials: + - kind: + name_unencrypted: kv + name_unencrypted: ci@dev1.htran.egihosting.com + user_unencrypted: ci + password: ENC[AES256_GCM,data:4AIDKxX9dQncyhHe,iv:+YbvHz6GLD9unbTwE/KwcdpU/yMygFurxelOjkrFJRU=,tag:VHnzt66W2pWwcxjTH9LreQ==,type:str] + - kind: + name_unencrypted: kv + name_unencrypted: Gitea credentials + user_unencrypted: pegasust + password: ENC[AES256_GCM,data:l472gCfek08/Z1cWL0EVtqWYYhE=,iv:TDUX4piGeHSkFSApeaGIPiXPzYAHZWxoMIuQ8G6cunw=,tag:WhCDoCNIUxe5gdxUuuYhZA==,type:str] + - kind: + name_unencrypted: kv + name_unencrypted: Nix SSH password for hungtr + user_unencrypted: hungtr + password: ENC[AES256_GCM,data:cJpfi8l1mx/86R1Oxd8=,iv:AwYBs4/P4ICNo4B6MxIz3HrGB+hdohIRtVflGBSS/P0=,tag:SC6MO5Zn0xwDRH4TGBR2LQ==,type:str] + - kind: + name_unencrypted: ssh + name_unencrypted: egi-htran + pubkey_unencrypted: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPNKyGKsVG/jVXwAmZvH8rLQPdGj8VgITMSN+/nbXTEY htran@Hung-Tran-MBP.local + privkey: ENC[AES256_GCM,data:OrurRGlutN1N1YFQvD1XbiF3thV8qO2y1ufRHi3ut1RVA/lxmqg1kYdWnYE7tOCCCITs20ZpcPFAwAjjAXZH6NaS8FgEJiPDUnJ+hg5v0VC7c4GNc+G3B8+9Taz7mggg70EL/s5QwofpuqJspr4EHrildX6eUeE6s9KwSFnw6KTBgO4r0JqBaicbbObhzxPYIYHjhxRxsbYMX4i8ADPeYryhEtL168dHEGENuz/mbw2I/5Qp3R/SwroNpYlTpq6ukGeobW4+j2KD7ZV9Nvcs/FL6/lPdaUKPxNW/bDeRhAaw9Mw3oDxHdTNisvCHJ53GHChdWcoXSMjYNH+zbgXp9YTeCLBMf9/lLnnEwtSEuD2kexcF+WR7gcbu6mdxJ1k3HBU+Xkrl6shGFuQv3hH8eSmfLhIdy+zcY/jb6tokQklrdKsrusFjuHhAuKfNl5uA93Pc0NxTZ4plxEEdbeyzz54cWwBf0HXR6ztSrjqfUtud3bQY667MNB2LHO91QBoQE7U2gUQ2CmI3VG9KVm2eh7LsXUjLoLzccYfg+kkTrQJnAfs=,iv:+4wsk7mUsIOWNe9IoV0TgrBKIsQdiJyzwVb2+hlPVTc=,tag:B9P2bHPh78JuwusZnAsC5A==,type:str] + agepub_unencrypted: age1jpm9mtxz6n8vncrk6pk7dppj3r7qxfj5hsgvcdulmp3lxvxez94qvxlgay + agepriv: ENC[AES256_GCM,data:tE6WLw8/dHsC6rfJpek7czvySW0+S2luc470l9X6UFX+zCOwlwoQpTWpIGPIqmkOFNSaaA0cyZ4BmWnlVz1iWxizh8DYqcE5los=,iv:4jnpibK+0cE1isWu6Zl1CsajMWN9Zgw8LGX5WpkRyy8=,tag:vdi85c3Q29olLGsCwrvmcA==,type:str] + - kind: + name_unencrypted: ssh + name_unencrypted: dev1-ssh + pubkey_unencrypted: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH1IiP+d2S152uiD2JjUJfADFv7AS0l3LX2NRgfMTYLe htran@htrandevbox + privkey: ENC[AES256_GCM,data:5lf+Oy0VhsxDLANpBFxtguD5unsZK9yKW/boTlxAOIzlcD1Xf4Nr0iC6YW/4nBB/eJ8xPlUiU5vhRQSLZPqnfc6nQJReqPPafzfugYb3slYBl59EeimBCqTi0qVIUHNFvRpp2agZW0wIQv4hlB3ks+WBVjKixLOdbUBQREZB22DWk6eoKawmekCr7ItDsxGWG7DtHx9A511LyPrT1n/VhAYHTuq6ycbWjDya++bJ/AkYlcqW0jEyQ/Mudo/TYkRt4TpWWDjGPDYVNrjBiwYOSpoM6IwzfRQvimCZnfqyXHrT2gzv9Vqqu9C2Vp2R0FLzbdA8dYoiXwss7opzsI5um6D4AdQv8c16TiVLFF0q0VP2xyRf3j7iqmuwQHIRlkBh2BhnsXT/s35K6cb1dUhIw0aQpFGzL/VuqMKrQW3j3S9pSiiupBuSwdLJ9s8+rkGYTO0Iw+T646L1NFW7oFMP8Fe5ZMC9UuTV/srWNtXHAQaY+L9TwMIQY36P4V0lqaVfCWAiIrBTgLhHQetnzb/Y44Ll/qTdRXHSW6D4,iv:30sivScr8WmFmZx8M/sqTEuGRg72VzJ+bc6AW847xz8=,tag:dJsH+/dhRWQoKwsGAUzqAQ==,type:str] + - kind: + name_unencrypted: age + agepub_unencrypted: age1jw958shpwu7st8sc4z0fufuswmfpxfc9wl3df9g3f3y57m45j92syr0mng + agepriv: ENC[AES256_GCM,data:f66nwYr1WLTejGI2SpHNrf8BYRJJuxpufYLSYVix1uLdBj2TfVJVjN3bLsnHrB1DoeVyaF0nUxrdcL64LhbI38zZC/fNORfXx4E=,iv:J/noycrJlL2+r1ojmUYC/6GUVMGqRFM2ondBm2C7fSE=,tag:pT5z5NQQdS30bucdbPPBng==,type:str] + - kind: + name_unencrypted: ssh + name_unencrypted: gl-egi-htran-ed25519 + privkey: ENC[AES256_GCM,data:vM5G2o/syq9YUwqpUONJk5ebwha+UQI0wUCkwkmZTTtx+nB/HTnc4kqxX/eeF9ybSE8vq7YIWuKB8aSjpizOYZjjWIV3qpWBiDmdrWkWfUIl7kDdy75azZjHNRXuXUUExbPYGVjmL7KdDMHY2u1WceDSdEvgB2sNOPw4dNiZ9lcbJ5iDpQzmxaF6zdvZ/rVoXYM2NgSMdM4oTdRtYivcOPuxwRGi39R5XgyPJYwltawSAPFPmNYofszUzYLnD7jPEJqyEQORpcI2oM2qAPab22kDrDLyd51X1F6XT/5chKuPSsidZAVjB6+v2s/yN0quqz3qcP2RTYtaZcFyeEquk6eWA/MWVwCJK8XopNoPVVo0PRppOtq3M9Fss3Z587nQAis8doCbvv9XdUunOFHFWon7k8fGu9cDDMmSOE3KGWCO7Vw0V6dYnBT+OVJnJAxlf7AsUZdXVBo3PK9Zw6+d2XF2N9Jhr0bqA1tpmGqwCygHy41FGbWtuhZBX8JimTPFE1MyT5YvptzwbayONcvps8hZED8zwKbR/64DSF7wn1DAaW0=,iv:JjO6O+FB+W1Gi216bjkVXiIFvxLmIZ4rKLCXcepOIQc=,tag:TxiwbrCZ4vFgw6WMmKrVOg==,type:str] + pubkey_unencrypted: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINOqM08nqvcFhcF6E//dlphXctfck83N0tjKIfil8npY htran@Hung-Tran-MBP.local + agepriv: ENC[AES256_GCM,data:Z4qRvam25nvkNr4DuZhhKtN83NIfNcBW5Wq7SGm0Nb31kAjCS25VfkTrXUtrxWIunMCZEYoIdDLiENjRQPAh/NwffGbZn94/ZKY=,iv:t3YtQvRQPdbDcXgEC/A13W1K9/IIlt6rPceR1lAl0BM=,tag:QmiriOk19fGSPOWj98doUQ==,type:str] + agepub_unencrypted: age1jz7ajxer3fs02uygr8a374jfk7vuklpnnyugrlq4equ285t7nyfqwqdreq + - kind: + name_unencrypted: win-rdp + name_unencrypted: EGNGoat + ip: ENC[AES256_GCM,data:9/FPJM8l4hLvzDc5pg==,iv:ny1LKtgznhzMd3Bhogwu6b6bOk3/uCNarKTmlWRZAes=,tag:PsleUu2ZE4leEMEcEuJdLQ==,type:str] + user_unencrypted: EGN NOC + password: ENC[AES256_GCM,data:YOL5Sw6zaA==,iv:Cs8gySfGIQUBPivkM5N6kflZsRhp2w9xmPwtl7RrEZE=,tag:LXYKdsX++IP+jQyjL6JBrg==,type:str] + - kind: + name_unencrypted: kv + name_unencrypted: gl-deploy-token + user_unencrypted: gitlab+deploy-token-2 + pass_unencrpyted: ENC[AES256_GCM,data:GcPu8JFy8JuPb3xrHKBpP196h0k=,iv:2N69xdTtnpjDLvRAbSpDWGh6+IFWpIZgHo6yVf2kE/4=,tag:L7UA7Oj/ZtekO3Cmvp2lvA==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1jw958shpwu7st8sc4z0fufuswmfpxfc9wl3df9g3f3y57m45j92syr0mng + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAwdGdsRlFqU3A5S3JERDFo + RjBhaHdhSVdXbThwNkR3aWNWc2pMY2owQ0JNCjZpTFBBRWlOTTRvYUJmVzU1QjN6 + ZzkwcGNjNkVmVzhuMlhLN1ZpWEJiSjgKLS0tIGNmbHF5T3dFeWd1dDFCajIvUmJX + TkpXSCtrU1V5NjRWbTBKMWhhMi9JNGsK+UCiGQtJNU0QDTG2kIqxUO9boLPj583M + ZwQXwhqBljQojqs1NwvXHCWgyrqhPqIobwYO8xhq1/3S/jMkyfzbAQ== + -----END AGE ENCRYPTED FILE----- + - recipient: age1jpm9mtxz6n8vncrk6pk7dppj3r7qxfj5hsgvcdulmp3lxvxez94qvxlgay + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAxSnN3V2hXZ25mU1gxait3 + TDVDQ1RqbVZYOWI2Q1BCZnlDaFVHb2NuRXdrCm8yQ0FWRytReCt0TU11byt5THM1 + VWh1MjhFWVlRQ29rQXlJS2FHTUFaQlkKLS0tIExJMndaY2g3ZmlnbyswWW9Fc0RM + MFFVNGs2RHVTcUdYZWljckt0RnRFN28K4O6nmQfMaJYzaA2n4PzLAqoslyxScplr + y6b6wTL3171sA2w6DgP+8BQjJ9/oCoGOtwpyxWzs2zld0dglmP9PGA== + -----END AGE ENCRYPTED FILE----- + - recipient: age1umzkd4k0xt6uv5de85fpc4uztrph86nsd79h5f8cpuvtpy8n6adss7q2fv + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBmOFVCTS9HS2dITFVqV2s5 + VGV5WUZlaW9JMWdNM1NUeVNmTFV3eWVzS0hFCnNVTGRlbG1aU2dsaXhFMmZFekt5 + cU4wWkNpYktFcEtwYTByUDlpOW5WY1EKLS0tIENyMndiL0gxUGdlK1BtelNKd295 + QThYZGM0Y1FoTmVud2MxZ2lxK1RENFUKbRkax7DamL8m8qnN0FBHjJm7iDEjI4On + +xWVpKRSZviklQTybJqCS3PS3hCAW2zVlD8kZ5ZgTF9/p3towOAJGw== + -----END AGE ENCRYPTED FILE----- + - recipient: age1vx7e6vz9zptwqd0cakjj8erqv58cstddama8zcrppc36rqqmlvjs53x9u0 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA3eFI3YUtGbUFQbnQ5YXZ4 + VE1uNHhNdUNPeEVOY3VuaFR5UEQ3ejJqaFJRClpETnFhQ09udk5XTWRBdmxnRW5q + T0xGbFYwOVlZWWFNb2c4d0ZBNzZnREEKLS0tIGlLK1RRMllKMG9vTmxOSHZXb3dT + cWxIRyszNmlpN2twMElIL3JCcHdOcHMKMT7Xq+XsSAdkJ1CAWRqdQTrr1NhPeTUc + UT0Fa8zUCBTUZEhcmVAnZ4Crr6N2GQbtNOU2S9Jt++od1dxQ+9TjHA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2023-02-28T17:54:36Z" + mac: ENC[AES256_GCM,data:uI84H7eyWsauw2RMysa8w/OHP4QXN+FvO/GW+orj86cTlfL521MdPgZZamtSxOeyb4+893jn09GSFUBmOdQHUOX3kGNdWNwpu7eXM1ext/cpZwCsaIDBWDyCCE6LcF69LQEKsbRlC1nDAeMW3Wn510teS/TFxgbRucNdGTnrRE0=,iv:PbjX7VTDkAi0O/pipgV70KbJD/LLJAmD/U7d2kn58DM=,tag:dMsU71CPnO8JHyXoWPcFaQ==,type:str] + pgp: [] + unencrypted_suffix: _unencrypted + version: 3.7.3 diff --git a/default.nix b/default.nix index 9004ce7..72e93e4 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,13 @@ # We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix -(import +( + import ( - let + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - c_ = import ./c_.nix {src = ./.;}; + c_ = import ./c_.nix; in - c_.fetchTree lock.nodes.flake-compat.locked + c_.fetchTree lock.nodes.flake-compat.locked ) - { src = ./.; } -).defaultNix + {src = ./.;} +) +.defaultNix diff --git a/dev-shell.nix b/dev-shell.nix index 69b54a4..399143e 100644 --- a/dev-shell.nix +++ b/dev-shell.nix @@ -1,24 +1,30 @@ -# Ideally, this should contain the barebone necessary for building/interacting +# Ideally, this should contain the barebone necessary for building/interacting # with tech used in this project # # Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead # # It should not contain PDE -{ pkgs ? import { } -, lib -, ... -}: pkgs.mkShell { +{ + pkgs ? import {}, + lib, + ... +}: +pkgs.mkShell { # mkShell doesn't care about the differences across nativeBuildInputs, # buildInputs, or packages buildInputs = [ # shell scripts - (lib.shellAsDrv { script = ''echo "hello world"''; pname = "hello"; }) - # TODO: decompose hm-switch.sh with a base version (where HOME_MANAGER_BIN is injected) - # (lib.shellAsDrv {script = builtins.readFile ./scripts/hm-switch.sh; pname = "hm-switch";}) pkgs.rust4cargo + pkgs.sops + pkgs.ssh-to-age + pkgs.go + pkgs.gopls ]; + shellHook = '' + # Since we need late dispatch of ~, we have to put this in shellHook. + export SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt + ''; # env vars lol = "hello world"; } - diff --git a/docs/DEV.md b/docs/DEV.md index f5f7c68..2d78e62 100644 --- a/docs/DEV.md +++ b/docs/DEV.md @@ -28,7 +28,7 @@ documentations and defaults - `nativeBuildInputs` is supposed to be built by a deployment machine (not target) -- `buildInputs` gives you access during runtime +- `buildInputs` gives you access during runtime (if the package goes path build filter) - `nativeBulidInputs` gives you access to packages during build time diff --git a/docs/manual-test/tailwind-color-cmp.md b/docs/manual-test/tailwind-color-cmp.md new file mode 100644 index 0000000..2a6247b --- /dev/null +++ b/docs/manual-test/tailwind-color-cmp.md @@ -0,0 +1,12 @@ +# Neovim: Testing cmp for color with Tailwind + +- [ ] It should detect a project uses tailwind, maybe via some kind of config file +(`tailwind.config.{cjs,mjs,js,ts,json,tsx,toml,yaml}`), or just based on the +string content or via tree-stiter. Check this by `:LspInfo` and `tailwindcss-lsp` +should attach to the current buffer that has tailwind-css string +- [ ] Type in a classname `text-red-500`, just stop at somewhere and start +browsing the cmp-lsp window. It should show a color in place of `lspkind`. +This validates `tailwindcss-colorizer-cmp.nvim` is good +- [ ] Hit that autocomplete, the string should show the color red. This validates +`nvim-colorizer.lua` is properly setup. + diff --git a/docs/vim-plugins.md b/docs/vim-plugins.md new file mode 100644 index 0000000..15ccabc --- /dev/null +++ b/docs/vim-plugins.md @@ -0,0 +1,169 @@ +# Offset Vim Plugins onto nix packer + +The current [`scripts/vim.dsl`](../scripts/vim.dsl) grabs the upstream supported vim plugins +onto a sqlite database to be stored in memory. We could perform some data exploration via this database + +## Explore which plugins should be added to `neovim.nix` + +Gather list of plugins need to be added. This can be done simply by adding +a print statement on `WPlug` in `../native_configs/neovim/init.lua` then run neovim +to collect it. + +```lua +-- as of git://./dotfiles.git#a6c979c6 +local function WPlug(plugin_path, ...) + local plugin_name = string.lower(plugin_path:match("/([^/]+)$")) + if not installed_plugins[plugin_name] then + -- NOTE: Add print statement to get which plugin is still being + -- plugged at runtime + print("Plugging "..plugin_path) + Plug(plugin_path, ...) + end +end +``` + +We can then use `vim_dsl.py` + +```py + vp = VimPlugins(UPSTREAM_CSV) + need_install_plugins = """ +tjdevries/nlua.nvim +yioneko/nvim-yati +nathanalderson/yang.vim +numToStr/Comment.nvim +lewis6991/gitsigns.nvim +tpope/vim-fugitive +williamboman/mason.nvim +williamboman/mason-lspconfig.nvim +TimUntersberger/neogit +folke/trouble.nvim +tpope/vim-dispatch +clojure-vim/vim-jack-in +radenling/vim-dispatch-neovim +gennaro-tedesco/nvim-jqx +kylechui/nvim-surround +simrat39/inlay-hints.nvim +gruvbox-community/gruvbox +nvim-lualine/lualine.nvim +lukas-reineke/indent-blankline.nvim +kyazdani42/nvim-web-devicons +m-demare/hlargs.nvim +folke/todo-comments.nvim +nvim-treesitter/playground +saadparwaiz1/cmp_luasnip +L3MON4D3/LuaSnip +arthurxavierx/vim-caser +~/local_repos/ts-ql + """.split() + need_install_plugins = [plugin.strip() for plugin in plugins_raw if plugin.strip()] + + # Create the GitHub URL list + need_install_plugins_gh = [ + f"https://github.com/{plugin}/".lower() for plugin in need_install_plugins if not plugin.startswith(("~", "."))] + + # Get the values from the database + values = vp.query(f"SELECT LOWER(repo), alias from {vp.table_name()}") + + # Check if the repo is in the list of plugins + need_install = [ + vim_plugin_slug(alias) if alias else name_from_repo(repo) for repo, alias in values if repo in need_install_plugins_gh] + + print("need_install", "\n".join(need_install)) + + # Check if the repo is not in the list + repos = [repo for repo, _ in values] + not_in_repo = [name_from_repo(gh) for gh in need_install_plugins_gh if gh not in repos] + print("not in repo", not_in_repo) # nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community +``` + +This should print out +``` +need_install +cmp_luasnip +comment-nvim +gitsigns-nvim +gruvbox-community +indent-blankline-nvim +lualine-nvim +luasnip +mason-lspconfig-nvim +mason-nvim +neogit +nlua-nvim +nvim-jqx +nvim-surround +nvim-web-devicons +playground +todo-comments-nvim +trouble-nvim +vim-dispatch +vim-dispatch-neovim +vim-fugitive +vim-jack-in +not in repo ['nvim-yati', 'yang-vim', 'inlay-hints-nvim', 'hlargs-nvim', 'vim-caser'] +``` + +Given this list, we could safely add to `neovim.nix` + +```nix +programs.neovim.plugins = + let inherit (pkgs.vimPlugins) + need_install + cmp_luasnip + comment-nvim + gitsigns-nvim + gruvbox-community + indent-blankline-nvim + lualine-nvim + luasnip + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + ;in [ + need_install + cmp_luasnip + comment-nvim + gitsigns-nvim + gruvbox-community + indent-blankline-nvim + lualine-nvim + luasnip + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + + ]; +``` + + +TODO: +- [ ] Source the plugins directly +- [ ] Add 'frozen' to each of these plugin +- [ ] Pin plugins separately from `neovim.nix` +- [ ] Find a better way to `inherit` with list comprehension +- [ ] Create alert & notification channel for this, ideally via Discord channel +- [ ] Even better, just put it in email with some labels +- [ ] Better end-to-end design that take even deeper account to gruvbox-community and such + diff --git a/flake.lock b/flake.lock index 4a4f39e..cb85208 100644 --- a/flake.lock +++ b/flake.lock @@ -1,39 +1,292 @@ { "nodes": { - "agenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, + "blank": { "locked": { - "lastModified": 1673301561, - "narHash": "sha256-gRUWHbBAtMuPDJQXotoI8u6+3DGBIUZHkyQWpIv7WpM=", - "owner": "ryantm", - "repo": "agenix", - "rev": "42d371d861a227149dc9a7e03350c9ab8b8ddd68", + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", "type": "github" }, "original": { - "owner": "ryantm", - "repo": "agenix", + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "blank_2": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "cargo-leptos": { + "flake": false, + "locked": { + "lastModified": 1686759547, + "narHash": "sha256-hZevu2lwyYFenABu1uV7/mZc7SXfLzR6Pdmc3zHJ2vw=", + "owner": "leptos-rs", + "repo": "cargo-leptos", + "rev": "75d3905cad6feb68be14659a802f75f48034a4ac", + "type": "github" + }, + "original": { + "owner": "leptos-rs", + "repo": "cargo-leptos", + "type": "github" + } + }, + "crane": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1686621798, + "narHash": "sha256-FUwWszmSiDzUdTk8f69xwMoYlhdPaLvDaIYOE/y6VXc=", + "owner": "ipetkov", + "repo": "crane", + "rev": "75f7d715f8088f741be9981405f6444e2d49efdd", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { + "inputs": { + "flake-compat": "flake-compat_6", + "flake-utils": "flake-utils_7", + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_3" + }, + "locked": { + "lastModified": 1676162383, + "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_3": { + "inputs": { + "flake-compat": "flake-compat_7", + "flake-utils": "flake-utils_9", + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_4" + }, + "locked": { + "lastModified": 1676162383, + "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1686747123, + "narHash": "sha256-XUQK9kwHpTeilHoad7L4LjMCCyY13Oq383CoFADecRE=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "724463b5a94daa810abfc64a4f87faef4e00f984", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "devshell": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ], + "systems": "systems_4" + }, + "locked": { + "lastModified": 1686680692, + "narHash": "sha256-SsLZz3TDleraAiJq4EkmdyewSyiv5g0LZYc6vaLZOMQ=", + "owner": "numtide", + "repo": "devshell", + "rev": "fd6223370774dd9c33354e87a007004b5fd36442", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "devshell_2": { + "inputs": { + "nixpkgs": [ + "std", + "nixpkgs" + ], + "systems": "systems_5" + }, + "locked": { + "lastModified": 1686680692, + "narHash": "sha256-SsLZz3TDleraAiJq4EkmdyewSyiv5g0LZYc6vaLZOMQ=", + "owner": "numtide", + "repo": "devshell", + "rev": "fd6223370774dd9c33354e87a007004b5fd36442", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "haumea": [ + "nix-boost", + "std", + "haumea" + ], + "nixlib": [ + "nix-boost", + "std", + "haumea", + "nixpkgs" + ], + "yants": [ + "nix-boost", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862774, + "narHash": "sha256-ojGtRQ9pIOUrxsQEuEPerUkqIJEuod9hIflfNkY+9CE=", + "owner": "divnix", + "repo": "dmerge", + "rev": "9f7f7a8349d33d7bd02e0f2b484b1f076e503a96", + "type": "github" + }, + "original": { + "owner": "divnix", + "ref": "0.2.1", + "repo": "dmerge", + "type": "github" + } + }, + "dmerge_2": { + "inputs": { + "haumea": [ + "std", + "haumea" + ], + "nixlib": [ + "std", + "haumea", + "nixpkgs" + ], + "yants": [ + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862774, + "narHash": "sha256-ojGtRQ9pIOUrxsQEuEPerUkqIJEuod9hIflfNkY+9CE=", + "owner": "divnix", + "repo": "dmerge", + "rev": "9f7f7a8349d33d7bd02e0f2b484b1f076e503a96", + "type": "github" + }, + "original": { + "owner": "divnix", + "ref": "0.2.1", + "repo": "dmerge", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs_9", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1677306201, + "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0923f0c162f65ae40261ec940406049726cfeab4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_2": { + "inputs": { + "nixpkgs": "nixpkgs_13", + "rust-analyzer-src": "rust-analyzer-src_2" + }, + "locked": { + "lastModified": 1677306201, + "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0923f0c162f65ae40261ec940406049726cfeab4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", "type": "github" } }, "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1, - "narHash": "sha256-d6CilJXP+UPv3nF00zBBRhMgRklTCjSCMrjbYtYDuOI=", - "path": "out-of-tree/flake-compat", - "type": "path" - }, - "original": { - "path": "out-of-tree/flake-compat", - "type": "path" - } - }, - "flake-compat_2": { "flake": false, "locked": { "lastModified": 1668681692, @@ -49,6 +302,163 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_6": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_7": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1680392223, + "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -80,12 +490,15 @@ } }, "flake-utils_3": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -95,6 +508,42 @@ } }, "flake-utils_4": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_6": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -109,19 +558,220 @@ "type": "github" } }, + "flake-utils_7": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_8": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_9": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "pre-commit-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gnmic": { + "flake": false, + "locked": { + "lastModified": 1686895285, + "narHash": "sha256-97QB49OAqt0zamA+SRZKkgj0GE/u0MTzHHjEEFuGb5s=", + "owner": "openconfig", + "repo": "gnmic", + "rev": "6413a00addb79e9762d5ad3e77866b1da0a532fb", + "type": "github" + }, + "original": { + "owner": "openconfig", + "repo": "gnmic", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "nixpkgs": "nixpkgs_4", + "utils": "utils_2" + }, + "locked": { + "lastModified": 1677459247, + "narHash": "sha256-JbakfAiPYmCCV224yAMq/XO0udN5coWv/oazblMKdoY=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "3cbf3a51fe32e2f57af4c52744e7228bab22983d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1678138103, + "narHash": "sha256-D0lao82bV3t2gEFjHiU6RN233t+1MnkQV+bq8MEu2ic=", + "owner": "hercules-ci", + "repo": "haskell-flake", + "rev": "1e1660e6dd00838ba73bc7952e6e73be67da18d1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "ref": "0.1-extraLibraries", + "repo": "haskell-flake", + "type": "github" + } + }, + "haumea": { + "inputs": { + "nixpkgs": "nixpkgs_7" + }, + "locked": { + "lastModified": 1685133229, + "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=", + "owner": "nix-community", + "repo": "haumea", + "rev": "34dd58385092a23018748b50f9b23de6266dffc2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.2.2", + "repo": "haumea", + "type": "github" + } + }, + "haumea_2": { + "inputs": { + "nixpkgs": "nixpkgs_11" + }, + "locked": { + "lastModified": 1685133229, + "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=", + "owner": "nix-community", + "repo": "haumea", + "rev": "34dd58385092a23018748b50f9b23de6266dffc2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.2.2", + "repo": "haumea", + "type": "github" + } + }, + "hercules-ci-agent": { + "inputs": { + "flake-parts": "flake-parts_3", + "haskell-flake": "haskell-flake", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks-nix": "pre-commit-hooks-nix" + }, + "locked": { + "lastModified": 1678446614, + "narHash": "sha256-Z6Gsba5ahn/N0QlF0vJfIEfnZgCs4qr1IZtXAqjbE7s=", + "owner": "hercules-ci", + "repo": "hercules-ci-agent", + "rev": "0b90d1a87c117a5861785cb85833dd1c9df0b6ef", + "type": "github" + }, + "original": { + "id": "hercules-ci-agent", + "type": "indirect" + } + }, + "hercules-ci-effects": { + "inputs": { + "flake-parts": "flake-parts_2", + "hercules-ci-agent": "hercules-ci-agent", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1681898675, + "narHash": "sha256-nIJ7CAdiHv4i1no/VgDoeTJLzbLYwu5+/Ycoyzn0S78=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "15ff4f63e5f28070391a5b09a82f6d5c6cc5c9d0", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ "nixpkgs" - ], - "utils": "utils" + ] }, "locked": { - "lastModified": 1673948101, - "narHash": "sha256-cD0OzFfnLFeeaz4jVszH9QiMTn+PBxmcYzrp+xujpwM=", + "lastModified": 1687041769, + "narHash": "sha256-lPDVNMrDF/hOVy+P8pEtKzvSN/Akk9RbDcyNuvW1T+M=", "owner": "nix-community", "repo": "home-manager", - "rev": "bd3efacb82c721edad1ce9eda583df5fb62ab00a", + "rev": "edf9cf65238609db16680be74fe28d4d4858476e", "type": "github" }, "original": { @@ -130,14 +780,59 @@ "type": "github" } }, + "incl": { + "inputs": { + "nixlib": [ + "nix-boost", + "std", + "haumea", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "incl_2": { + "inputs": { + "nixlib": [ + "std", + "haumea", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, "kpcli-py": { "flake": false, "locked": { - "lastModified": 1619087457, - "narHash": "sha256-iRNLq5s2WJJHwB4beP5xQDKrBPWS/42s/ozLoSa5gAE=", + "lastModified": 1679142558, + "narHash": "sha256-l18PBzf/P7d3BPcFb5gSDX863MsC7S747qooyg0u2lA=", "owner": "rebkwok", "repo": "kpcli", - "rev": "e4d699e3b3d28887f74185f8fa69d0aade111d84", + "rev": "1c64e7274345d28ebc2607e22211a4ee9f6dbe7f", "type": "github" }, "original": { @@ -146,6 +841,58 @@ "type": "github" } }, + "n2c": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685771919, + "narHash": "sha256-3lVKWrhNXjHJB6QkZ2SJaOs4X/mmYXtY6ovPVpDMOHc=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "95e2220911874064b5d809f8d35f7835184c4ddf", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "n2c_2": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685771919, + "narHash": "sha256-3lVKWrhNXjHJB6QkZ2SJaOs4X/mmYXtY6ovPVpDMOHc=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "95e2220911874064b5d809f8d35f7835184c4ddf", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, "neovim-flake": { "inputs": { "flake-utils": "flake-utils_2", @@ -156,11 +903,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1673937267, - "narHash": "sha256-zixnItZtMZRKK0bEh8UOBeh8JT4jeMzPR2TtacfXmyE=", + "lastModified": 1682581904, + "narHash": "sha256-9P4T2erXXrPxXTTLgD29U/IdKCOYqP4xbwdYswtVBA8=", "owner": "neovim", "repo": "neovim", - "rev": "2093e574c6c934a718f96d0a173aa965d3958a8b", + "rev": "d321deb4a9b05e9d81b79ac166274f4a6e7981bf", "type": "github" }, "original": { @@ -173,81 +920,262 @@ "neovim-nightly-overlay": { "inputs": { "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts", + "hercules-ci-effects": "hercules-ci-effects", "neovim-flake": "neovim-flake", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1673943288, - "narHash": "sha256-TDo9wDfZH+MJ/tTeCtZ67jdHqtVvIxetLpFN9+vqZ7g=", + "lastModified": 1684067841, + "narHash": "sha256-UzOHzcx5KrysKdLZuyU2k5RipVa6wP8EbVeqF/C7OLM=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "3c0bb335936754a2683a84ddf081594ddb567a89", + "rev": "88a6c749a7d126c49f3374f9f28ca452ea9419b8", "type": "github" }, "original": { "owner": "nix-community", "repo": "neovim-nightly-overlay", + "rev": "88a6c749a7d126c49f3374f9f28ca452ea9419b8", + "type": "github" + } + }, + "nix-boost": { + "inputs": { + "cargo-leptos": "cargo-leptos", + "crane": "crane", + "flake-compat": "flake-compat_5", + "gnmic": "gnmic", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_5", + "poetry2nix": "poetry2nix", + "rust-overlay": "rust-overlay_2", + "std": "std" + }, + "locked": { + "lastModified": 1687069436, + "narHash": "sha256-GdtAbw1o5lF6kad/INP/UMhq+LtK80BI+StwdNKJQlo=", + "ref": "bleed", + "rev": "5812ec3cbb89f0e954db3ee66644e7c7f6e70444", + "revCount": 88, + "type": "git", + "url": "https://git.pegasust.com/pegasust/nix-boost" + }, + "original": { + "ref": "bleed", + "type": "git", + "url": "https://git.pegasust.com/pegasust/nix-boost" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673295039, + "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", "type": "github" } }, "nix-index-database": { "inputs": { "nixpkgs": [ + "nixpkgs-latest" + ] + }, + "locked": { + "lastModified": 1686740472, + "narHash": "sha256-b668DY2qGdBCUwIkk6Z32bcpCsUISQJrEEvhtn1gGgY=", + "owner": "mic92", + "repo": "nix-index-database", + "rev": "e11c61073b777e025993c5ef63ddbf776a9cca15", + "type": "github" + }, + "original": { + "owner": "mic92", + "repo": "nix-index-database", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "flake-utils" + ], + "nixago-exts": [ + "nix-boost", + "std", + "blank" + ], + "nixpkgs": [ + "nix-boost", + "std", "nixpkgs" ] }, "locked": { - "lastModified": 1673752441, - "narHash": "sha256-/g4ImZWV05CrXRWTSJsda6ztIp7LAPxs2L6RCrbQ66U=", - "owner": "mic92", - "repo": "nix-index-database", - "rev": "391180f77505c1c8cdd45fe1a59dc89d3e40300a", + "lastModified": 1683210100, + "narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=", + "owner": "nix-community", + "repo": "nixago", + "rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630", "type": "github" }, "original": { - "owner": "mic92", - "repo": "nix-index-database", + "owner": "nix-community", + "repo": "nixago", "type": "github" } }, - "nixgl": { + "nixago_2": { "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_2" + "flake-utils": [ + "std", + "flake-utils" + ], + "nixago-exts": [ + "std", + "blank" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] }, "locked": { - "lastModified": 1, - "narHash": "sha256-RkO+8E7MahERHw1C5DNObDjq4xeI+FqaWH9+M7Fv2UE=", - "path": "out-of-tree/nixGL", - "type": "path" - }, - "original": { - "path": "out-of-tree/nixGL", - "type": "path" - } - }, - "nixlib": { - "locked": { - "lastModified": 1673743903, - "narHash": "sha256-sloY6KYyVOozJ1CkbgJPpZ99TKIjIvM+04V48C04sMQ=", + "lastModified": 1683210100, + "narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=", "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "7555e2dfcbac1533f047021f1744ac8871150f9f", + "repo": "nixago", + "rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630", "type": "github" }, "original": { "owner": "nix-community", - "repo": "nixpkgs.lib", + "repo": "nixago", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1671983799, - "narHash": "sha256-Z2Ro6hFPZHkBqkVXY5/aBUzxi5xizQGvuHQ9+T5B/ks=", + "lastModified": 1671417167, + "narHash": "sha256-JkHam6WQOwZN1t2C2sbp1TqMv3TVRjzrdoejqfefwrM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bb31220cca6d044baa6dc2715b07497a2a7c4bc7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-latest": { + "locked": { + "lastModified": 1687069865, + "narHash": "sha256-+JcVIxijVccnSnbGl8INEKkRo3GzHZ7iBm4EZ2MC1O8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "fad51abd42ca17a60fc1d4cb9382e2d79ae31836", + "rev": "5630d719e9e90f66f9eaa4a2d00b303dbee9f4c3", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1673800717, + "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_10": { + "locked": { + "lastModified": 1686960236, + "narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { + "locked": { + "lastModified": 1681001314, + "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "367c0e1086a4eb4502b24d872cea2c7acdd557f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_12": { + "locked": { + "lastModified": 1675940568, + "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", "type": "github" }, "original": { @@ -257,43 +1185,45 @@ "type": "github" } }, + "nixpkgs_13": { + "locked": { + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { - "lastModified": 1660551188, - "narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=", - "owner": "nixos", + "lastModified": 1678293141, + "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65", + "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_3": { "locked": { - "lastModified": 1673631141, - "narHash": "sha256-AprpYQ5JvLS4wQG/ghm2UriZ9QZXvAwh1HlgA/6ZEVQ=", + "lastModified": 1685714850, + "narHash": "sha256-OcvbIJq4CGwwFr9m7M/SQcDPZ64hhR4t77oZgEeh7ZY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "befc83905c965adfd33e5cae49acb0351f6e0404", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-unstable", - "type": "indirect" - } - }, - "nixpkgs_4": { - "locked": { - "lastModified": 1665296151, - "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "rev": "c6ffce3d5df7b4c588ce80a0c6e2d2348a611707", "type": "github" }, "original": { @@ -303,32 +1233,455 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1658285632, + "narHash": "sha256-zRS5S/hoeDGUbO+L95wXG9vJNwsSYcl93XiD0HQBXLk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5342fc6fb59d0595d26883c3cadff16ce58e44f3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1686960236, + "narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1681001314, + "narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "367c0e1086a4eb4502b24d872cea2c7acdd557f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_8": { + "locked": { + "lastModified": 1675940568, + "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_9": { + "locked": { + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nosys": { + "locked": { + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "nosys_2": { + "locked": { + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "paisano": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ], + "nosys": "nosys", + "yants": [ + "nix-boost", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862844, + "narHash": "sha256-m8l/HpRBJnZ3c0F1u0IyQ3nYGWE0R9V5kfORuqZPzgk=", + "owner": "paisano-nix", + "repo": "core", + "rev": "6674b3d3577212c1eeecd30d62d52edbd000e726", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "core", + "type": "github" + } + }, + "paisano-actions": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677306424, + "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=", + "owner": "paisano-nix", + "repo": "actions", + "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "actions", + "type": "github" + } + }, + "paisano-actions_2": { + "inputs": { + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677306424, + "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=", + "owner": "paisano-nix", + "repo": "actions", + "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "actions", + "type": "github" + } + }, + "paisano-mdbook-preprocessor": { + "inputs": { + "crane": "crane_2", + "fenix": "fenix", + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ], + "paisano-actions": "paisano-actions", + "std": [ + "nix-boost", + "std" + ] + }, + "locked": { + "lastModified": 1680654400, + "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=", + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "type": "github" + } + }, + "paisano-mdbook-preprocessor_2": { + "inputs": { + "crane": "crane_3", + "fenix": "fenix_2", + "nixpkgs": [ + "std", + "nixpkgs" + ], + "paisano-actions": "paisano-actions_2", + "std": [ + "std" + ] + }, + "locked": { + "lastModified": 1680654400, + "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=", + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "type": "github" + } + }, + "paisano-tui": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "blank" + ], + "std": [ + "nix-boost", + "std" + ] + }, + "locked": { + "lastModified": 1681847764, + "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=", + "owner": "paisano-nix", + "repo": "tui", + "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "tui", + "type": "github" + } + }, + "paisano-tui_2": { + "inputs": { + "nixpkgs": [ + "std", + "blank" + ], + "std": [ + "std" + ] + }, + "locked": { + "lastModified": 1681847764, + "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=", + "owner": "paisano-nix", + "repo": "tui", + "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "tui", + "type": "github" + } + }, + "paisano_2": { + "inputs": { + "nixpkgs": [ + "std", + "nixpkgs" + ], + "nosys": "nosys_2", + "yants": [ + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1686862844, + "narHash": "sha256-m8l/HpRBJnZ3c0F1u0IyQ3nYGWE0R9V5kfORuqZPzgk=", + "owner": "paisano-nix", + "repo": "core", + "rev": "6674b3d3577212c1eeecd30d62d52edbd000e726", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "core", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "nix-boost", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1686970505, + "narHash": "sha256-s3gtsusfeIoMYy0BTXXfoDq1IeDj8rPl4JMcR97H9XU=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "95d3cbc56d21917abace0cc1de10997469eb80b4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1678376203, + "narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "1a20b9708962096ec2481eeb2ddca29ed747770a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { - "agenix": "agenix", - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", + "deploy-rs": "deploy-rs", "home-manager": "home-manager", "kpcli-py": "kpcli-py", "neovim-nightly-overlay": "neovim-nightly-overlay", + "nix-boost": "nix-boost", "nix-index-database": "nix-index-database", - "nixgl": "nixgl", - "nixlib": "nixlib", - "nixpkgs": "nixpkgs_3", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs_10", + "nixpkgs-latest": "nixpkgs-latest", + "std": "std_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1677221702, + "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_2": { + "flake": false, + "locked": { + "lastModified": 1677221702, + "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_4" + "flake-utils": [ + "nix-boost", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "crane", + "nixpkgs" + ] }, "locked": { - "lastModified": 1673922364, - "narHash": "sha256-U0XIY/Y/x4fFtlCZKMtWlqOYUnLiXj4F42GQHxWuPow=", + "lastModified": 1685759304, + "narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "4e0f9b8a5102387f8d19901bced16a256a6ccdc7", + "rev": "c535b4f3327910c96dcf21851bbdd074d0760290", "type": "github" }, "original": { @@ -337,6 +1690,247 @@ "type": "github" } }, + "rust-overlay_2": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1687055571, + "narHash": "sha256-UvLoO6u5n9TzY80BpM4DaacxvyJl7u9mm9CA72d309g=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "2de557c780dcb127128ae987fca9d6c2b0d7dc0f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_4": { + "inputs": { + "flake-utils": [ + "std", + "paisano-mdbook-preprocessor", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "std", + "paisano-mdbook-preprocessor", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "std": { + "inputs": { + "arion": [ + "nix-boost", + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils_6", + "haumea": "haumea", + "incl": "incl", + "makes": [ + "nix-boost", + "std", + "blank" + ], + "microvm": [ + "nix-boost", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": "nixpkgs_8", + "paisano": "paisano", + "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor", + "paisano-tui": "paisano-tui", + "yants": "yants" + }, + "locked": { + "lastModified": 1686890041, + "narHash": "sha256-yLucgr7q8o63yJHLd5b5rF/h27ktYTQrn9rYxVxrs3E=", + "owner": "divnix", + "repo": "std", + "rev": "8671b6892e45d795d7409940750832d68c929dcf", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "std_2": { + "inputs": { + "arion": [ + "std", + "blank" + ], + "blank": "blank_2", + "devshell": "devshell_2", + "dmerge": "dmerge_2", + "flake-utils": "flake-utils_8", + "haumea": "haumea_2", + "incl": "incl_2", + "makes": [ + "std", + "blank" + ], + "microvm": [ + "std", + "blank" + ], + "n2c": "n2c_2", + "nixago": "nixago_2", + "nixpkgs": "nixpkgs_12", + "paisano": "paisano_2", + "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor_2", + "paisano-tui": "paisano-tui_2", + "yants": "yants_2" + }, + "locked": { + "lastModified": 1686890041, + "narHash": "sha256-yLucgr7q8o63yJHLd5b5rF/h27ktYTQrn9rYxVxrs3E=", + "owner": "divnix", + "repo": "std", + "rev": "8671b6892e45d795d7409940750832d68c929dcf", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1667395993, @@ -351,6 +1945,66 @@ "repo": "flake-utils", "type": "github" } + }, + "utils_2": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "haumea", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1686863218, + "narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=", + "owner": "divnix", + "repo": "yants", + "rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } + }, + "yants_2": { + "inputs": { + "nixpkgs": [ + "std", + "haumea", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1686863218, + "narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=", + "owner": "divnix", + "repo": "yants", + "rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 90daf2f..58b6fa1 100644 --- a/flake.nix +++ b/flake.nix @@ -2,177 +2,69 @@ nixConfig = { accept-flake-config = true; experimental-features = "nix-command flakes"; - # for darwin's browser - allowUnsupportedSystem = true; + max-jobs = 12; }; description = "My personal configuration in Nix (and some native configurations)"; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; - # continously merged & rebased lightweight .lib. Basically a huge extension to c_. - nixlib.url = "github:nix-community/nixpkgs.lib"; - agenix = { - url = "github:ryantm/agenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-latest.url = "github:nixos/nixpkgs"; + deploy-rs.url = "github:serokell/deploy-rs"; + std.url = "github:divnix/std"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - flake-utils.url = "github:numtide/flake-utils"; - nixgl.url = "path:out-of-tree/nixGL"; - rust-overlay.url = "github:oxalica/rust-overlay"; - # Allows default.nix to call onto flake.nix. Useful for nix eval and automations - flake-compat = { - url = "path:out-of-tree/flake-compat"; - flake = false; + neovim-nightly-overlay = { + # need to pin this until darwin build is successful again. + url = "github:nix-community/neovim-nightly-overlay?rev=88a6c749a7d126c49f3374f9f28ca452ea9419b8"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nix-boost = { + url = "git+https://git.pegasust.com/pegasust/nix-boost?ref=bleed"; }; kpcli-py = { url = "github:rebkwok/kpcli"; flake = false; }; - neovim-nightly-overlay = { - url = "github:nix-community/neovim-nightly-overlay"; - inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836"; - }; nix-index-database = { url = "github:mic92/nix-index-database"; - inputs.nixpkgs.follows = "nixpkgs"; + # Should show the latest nixpkgs whenever possible + inputs.nixpkgs.follows = "nixpkgs-latest"; }; }; - outputs = - { nixpkgs - , agenix - , home-manager - , flake-utils - , nixgl - , rust-overlay - , flake-compat - , neovim-nightly-overlay - , nix-index-database - , nixlib - , ... - }@_inputs: - let - # config_fn:: system -> config - # this function should take simple exports of homeConfigurations.${profile}, - # nixosConfigurations.${profile}, devShells.${profile}, packages.${profile} - # and correctly produce - cross_platform = config_fn: let - # nixosConfigurations.${profile} -> nixosConfigurations.${system}.${profile} - # pass in: path.to.exports.nixosConfigurations - # get out: nixosConfigurations.${system} = {...} - strat_sandwich = field_name: config_field: system: { - "${field_name}"."${system}" = config_field; - }; - # homeConfigurations.${profile} -> packages.${system}.homeConfigurations.${profile} - # pass in: path.to.exports.homeConfigurations - # get: packages.${system}.homeConfigurations - strat_wrap_packages = field_name: config_field: system: { - packages."${system}"."${field_name}" = config_field; - }; - strat_noop = field_name: config_field: system: {"${field_name}" = config_field;}; - strategyMap = { - nixosConfigurations = strat_sandwich; - templates = strat_noop; - devShells = strat_sandwich; - devShell = strat_sandwich; - formatter = strat_sandwich; - homeConfigurations = strat_wrap_packages; - lib = strat_noop; - proj_root = strat_noop; - unit_tests = strat_noop; - secrets = strat_noop; - debug = strat_noop; - }; - # takes in {homeConfigurations = ...; nixosConfigurations = ...} - # -> {packages.$system.homeConfigurations} - mapConfig = config: system: (builtins.foldl' - (acc: confName: (strategyMap."${confName}" confName config."${confName}" system)) - {} (builtins.attrNames config)); - in builtins.foldl' nixlib.lib.recursiveUpdate {} ( - builtins.map (system: (mapConfig (config_fn system) system)) flake-utils.lib.defaultSystems - ); - in cross_platform (system: - let - # Context/global stuffs to be passed down - # NOTE: this will only read files that are within git tree - # all secrets should go into secrets.nix and secrets/*.age - proj_root = - let - path = builtins.toString ./.; - in - { - inherit path; - configs.path = "${path}/native_configs"; - scripts.path = "${path}/scripts"; - secrets.path = "${path}/secrets"; - testdata.path = "${path}/tests"; - modules.path = "${path}/modules"; - hosts.path = "${path}/hosts"; - users.path = "${path}/users"; - }; - overlays = import ./overlays.nix (_inputs // {inherit system;}); - pkgs = import nixpkgs { - inherit system overlays; - config = { - allowUnfree = true; - }; - }; - # now, this lib is extremely powerful as it also engulfs nixpkgs.lib - # lib = nixpkgs.lib // pkgs.lib; - lib = (builtins.foldl' (lhs: rhs: (nixpkgs.lib.recursiveUpdate lhs rhs)) { } [ - nixpkgs.lib - pkgs.lib - (import ./lib { - inherit proj_root pkgs overlays system; - inherit (pkgs) lib; - }) - ]); - inputs_w_lib = (pkgs.lib.recursiveUpdate _inputs { - inherit system proj_root pkgs lib; - }); - - modules = (import ./modules inputs_w_lib); - hosts = (import ./hosts inputs_w_lib); - users = (import ./users inputs_w_lib); - - # {nixpkgs, agenix, home-manager, flake-utils, nixgl, rust-overlay, flake-compat - # ,pkgs, lib (extended), proj_root} - final_inputs = inputs_w_lib; - - # Tests: unit + integration - unit_tests = (import ./lib/test.nix final_inputs) // - { - test_example = { - expr = "names must start with 'test'"; - expected = "or won't show up"; - }; - not_show = { - expr = "this will be ignored by lib.runTests"; - expected = "for sure"; - }; - }; - secrets = import ./secrets final_inputs; - - in + outputs = {self, std, ...} @ inputs: + std.growOn { - inherit (hosts) nixosConfigurations; - inherit (users) homeConfigurations; - inherit lib proj_root; - devShells = import ./dev-shell.nix final_inputs; - templates = import ./templates final_inputs; - secrets = { - pubKeys = { - hosts = hosts.pubKeys; - users = users.pubKeys; - }; - }; + # boilerplate + inherit inputs; + # All cell blocks are under ./nix/cells// as `.nix` + # or ` -# TODO: Add to* formats from pkgs.formats.* -{ pkgs -, lib -, ... -} @ inputs: -let - yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage - ({ runCommand }: - # runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33 - runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; } - # run yq which outputs '.' (no filter) on file at yamlPath - # note that $out is passed onto the bash/sh script for execution - '' - echo "$yamlContent" | yq >$out - '') - { }; -in -{ - # Takes in a yaml string and produces a derivation with translated JSON at $outputPath - # similar to builtins.fromJSON, turns a YAML string to nix attrset - fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json")); - fromYamlPath = yamlPath: builtins.fromJSON ( - builtins.readFile ( - yamlToJsonDrv - ( - builtins.readFile yamlPath) - "any-output.json")); - # TODO: fromToml? -} diff --git a/lib/test.nix b/lib/test.nix deleted file mode 100644 index da4b506..0000000 --- a/lib/test.nix +++ /dev/null @@ -1 +0,0 @@ -{ lib, ... }: { } diff --git a/modules/amdgpu.sys.nix b/modules/amdgpu.sys.nix index d07dc1f..b4cf6be 100644 --- a/modules/amdgpu.sys.nix +++ b/modules/amdgpu.sys.nix @@ -1,6 +1,6 @@ { - imports = [ ./gpu.sys.nix ]; - boot.initrd.kernelModules = [ "amdgpu" ]; + imports = [./gpu.sys.nix]; + boot.initrd.kernelModules = ["amdgpu"]; services.xserver.enable = true; - services.xserver.videoDrivers = [ "amdgpu" ]; + services.xserver.videoDrivers = ["amdgpu"]; } diff --git a/modules/base.sys.nix b/modules/base.sys.nix index 8bc5c8a..9965573 100644 --- a/modules/base.sys.nix +++ b/modules/base.sys.nix @@ -1,7 +1,8 @@ -{ pkgs -, lib -, proj_root -, ... +{ + pkgs, + lib, + proj_root, + ... }: { imports = [ ./minimal.sys.nix @@ -9,7 +10,6 @@ ./tailscale.sys.nix ./ssh.sys.nix ]; - environment.systemPackages = [ pkgs.lm_sensors ]; + environment.systemPackages = [pkgs.lm_sensors]; time.timeZone = "America/Phoenix"; - } diff --git a/modules/default.nix b/modules/default.nix index be9a414..9fe8c60 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1 +1 @@ -inputs: { } +inputs: {} diff --git a/modules/gpu.sys.nix b/modules/gpu.sys.nix index 40a94e5..a98300b 100644 --- a/modules/gpu.sys.nix +++ b/modules/gpu.sys.nix @@ -1,8 +1,8 @@ -{ pkgs, ... }: { - environment.systemPackages = [ pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools ]; +{pkgs, ...}: { + environment.systemPackages = [pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools]; hardware.opengl = { enable = true; - extraPackages = [ pkgs.rocm-opencl-icd pkgs.rocm-opencl-runtime ]; + extraPackages = [pkgs.rocm-opencl-icd pkgs.rocm-opencl-runtime]; # Vulkan driSupport = true; driSupport32Bit = true; diff --git a/modules/kde.sys.nix b/modules/kde.sys.nix index e5b427f..8dca40a 100644 --- a/modules/kde.sys.nix +++ b/modules/kde.sys.nix @@ -1,6 +1,7 @@ -{ pkgs -, my-lib -, ... +{ + pkgs, + my-lib, + ... }: { environment.noXlibs = my-lib.mkForce false; # TODO: wireless networking @@ -11,15 +12,16 @@ services.xserver.displayManager.sddm.enable = true; services.xserver.desktopManager.plasma5 = { enable = true; - excludePackages = let plasma5 = pkgs.libsForQt5; in - [ - plasma5.elisa # audio viewer - plasma5.konsole # I use alacritty instaed - plasma5.plasma-browser-integration - plasma5.print-manager # will enable if I need - plasma5.khelpcenter # why not just write manpages instead :( - # plasma5.ksshaskpass # pls just put prompts on my dear terminal - ]; + excludePackages = let + plasma5 = pkgs.libsForQt5; + in [ + plasma5.elisa # audio viewer + plasma5.konsole # I use alacritty instaed + plasma5.plasma-browser-integration + plasma5.print-manager # will enable if I need + plasma5.khelpcenter # why not just write manpages instead :( + # plasma5.ksshaskpass # pls just put prompts on my dear terminal + ]; }; # disables KDE's setting of askpassword diff --git a/modules/minimal.sys.nix b/modules/minimal.sys.nix index da0b92c..bad84aa 100644 --- a/modules/minimal.sys.nix +++ b/modules/minimal.sys.nix @@ -1,10 +1,11 @@ -{ pkgs -, lib -, proj_root -, modulesPath -, ... +{ + pkgs, + lib, + proj_root, + modulesPath, + ... }: { - imports = [ "${modulesPath}/profiles/minimal.nix" ]; + imports = ["${modulesPath}/profiles/minimal.nix"]; # prune old builds after a while nix.settings.auto-optimise-store = true; nix.package = pkgs.nixFlakes; # nix flakes diff --git a/modules/mosh.sys.nix b/modules/mosh.sys.nix index 33571cd..89a2727 100644 --- a/modules/mosh.sys.nix +++ b/modules/mosh.sys.nix @@ -1,10 +1,11 @@ -{ pkgs -, lib -, config -, ... -}: -let cfg = config.mod.mosh; in { + pkgs, + lib, + config, + ... +}: let + cfg = config.mod.mosh; +in { options.mod.mosh = { enable = lib.mkOption { type = lib.types.bool; @@ -14,12 +15,14 @@ let cfg = config.mod.mosh; in }; }; config = lib.mkIf cfg.enable { - environment.systemPackages = [ pkgs.mosh ]; + environment.systemPackages = [pkgs.mosh]; networking.firewall = lib.mkIf config.networking.firewall.enable { allowedUDPPortRanges = [ - { from = 60000; to = 61000; } # mosh + { + from = 60000; + to = 61000; + } # mosh ]; }; }; } - diff --git a/modules/nvgpu.sys.nix b/modules/nvgpu.sys.nix index 4b6d3e7..e7f97cb 100644 --- a/modules/nvgpu.sys.nix +++ b/modules/nvgpu.sys.nix @@ -1,7 +1,7 @@ -{ config, ... }: { - imports = [ ./gpu.sys.nix ]; +{config, ...}: { + imports = [./gpu.sys.nix]; nixpkgs.config.allowUnfree = true; services.xserver.enable = true; - services.xserver.videoDrivers = [ "nvidia" ]; + services.xserver.videoDrivers = ["nvidia"]; hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; } diff --git a/modules/opengl.sys.nix b/modules/opengl.sys.nix index d7aa0c8..1a59513 100644 --- a/modules/opengl.sys.nix +++ b/modules/opengl.sys.nix @@ -1,21 +1,23 @@ -{ config, pkgs, lib }: -let - gpu_pkgs = [ pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools ]; +{ + config, + pkgs, + lib, +}: let + gpu_pkgs = [pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools]; gpu_conf = { # openCL hardware.opengl = { enable = true; - extraPackages = - let - inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime; - in - [ rocm-opencl-icd rocm-opencl-runtime ]; + extraPackages = let + inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime; + in [rocm-opencl-icd rocm-opencl-runtime]; # Vulkan driSupport = true; driSupport32Bit = true; package = pkgs.mesa.drivers; package32 = pkgs.pkgsi686Linux.mesa.drivers; }; + environment.systemPackages = gpu_pkgs; }; in - ; + gpu_conf diff --git a/modules/secrets.nix b/modules/secrets.nix index d491da3..ca3d586 100644 --- a/modules/secrets.nix +++ b/modules/secrets.nix @@ -1,6 +1,4 @@ -{ proj_root -, ... -}: { +{proj_root, ...}: { age.secrets.s3fs = { file = "${proj_root.secrets.path}/s3fs.age"; # mode = "600"; # owner + group only diff --git a/modules/storage.perso.sys.nix b/modules/storage.perso.sys.nix index ab8ac44..23096ee 100644 --- a/modules/storage.perso.sys.nix +++ b/modules/storage.perso.sys.nix @@ -1,5 +1,10 @@ # Personal configuration on storage solution -{ pkgs, config, lib, ... }: { +{ + pkgs, + config, + lib, + ... +}: { environment.systemPackages = [ pkgs.s3fs pkgs.cifs-utils @@ -9,87 +14,81 @@ # HACK: need to store secret somewhere so that root can access this # because autofs may run as root for now, we enforce putting the secret in this monorepo # TODO: make this configuration nix-less to show that it's 100% data - services.autofs = - let - # confToBackendArg {lol="what"; empty=""; name_only=null;} -> "lol=what,empty=,name_only" - # TODO: change null -> true/false. This allows overriding & better self-documentation - confToBackendArg = conf: (lib.concatStringsSep "," - (lib.mapAttrsToList (name: value: "${name}${lib.optionalString (value != null) "=${value}"}") conf)); + services.autofs = let + # confToBackendArg {lol="what"; empty=""; name_only=null;} -> "lol=what,empty=,name_only" + # TODO: change null -> true/false. This allows overriding & better self-documentation + confToBackendArg = conf: (lib.concatStringsSep "," + (lib.mapAttrsToList (name: value: "${name}${lib.optionalString (value != null) "=${value}"}") conf)); - # mount_dest: path ("wow") - # backend_args: nix attrs representing the arguments to be passed to s3fs - # ({"-fstype" = "fuse"; "use_cache" = "/tmp";}) - # bucket: bucket name (hungtr-hot) - # NOTE: s3 custom provider will be provided inside - # backend_args, so just put the bucket name here - # - #-> "${mount_dest} ${formatted_args} ${s3fs-bin}#${bucket}" - autofs-s3fs_entry = - { mount_dest - , backend_args ? { "-fstype" = "fuse"; } - , bucket - }@inputs: + # mount_dest: path ("wow") + # backend_args: nix attrs representing the arguments to be passed to s3fs + # ({"-fstype" = "fuse"; "use_cache" = "/tmp";}) + # bucket: bucket name (hungtr-hot) + # NOTE: s3 custom provider will be provided inside + # backend_args, so just put the bucket name here + # + #-> "${mount_dest} ${formatted_args} ${s3fs-bin}#${bucket}" + autofs-s3fs_entry = { + mount_dest, + backend_args ? {"-fstype" = "fuse";}, + bucket, + } @ inputs: let + s3fs-exec = "${pkgs.s3fs}/bin/s3fs"; + in "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}"; + personalStorage = [ + (autofs-s3fs_entry { + mount_dest = "garden"; + backend_args = { + "-fstype" = "fuse"; + use_cache = "/tmp"; + del_cache = null; + allow_other = null; + url = "https://v5h5.la11.idrivee2-14.com"; + passwd_file = config.age.secrets."s3fs.digital-garden".path; + dbglevel = "debug"; # enable this for better debugging info in journalctl + uid = "1000"; # default user + gid = "100"; # users + umask = "003"; # others read only, fully shared for users group + }; + bucket = "digital-garden"; + }) + ( let - s3fs-exec = "${pkgs.s3fs}/bin/s3fs"; - in - "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}"; - personalStorage = [ - (autofs-s3fs_entry { - mount_dest = "garden"; - backend_args = { - "-fstype" = "fuse"; - use_cache = "/tmp"; - del_cache = null; - allow_other = null; - url = "https://v5h5.la11.idrivee2-14.com"; - passwd_file = config.age.secrets."s3fs.digital-garden".path; - dbglevel = "debug"; # enable this for better debugging info in journalctl - uid = "1000"; # default user - gid = "100"; # users - umask = "003"; # others read only, fully shared for users group + args = { + "-fstype" = "cifs"; + credentials = config.age.secrets._nhitrl_cred.path; + user = null; + uid = "1001"; + gid = "100"; + dir_mode = "0777"; + file_mode = "0777"; }; - bucket = "digital-garden"; - }) - ( - let - args = { - "-fstype" = "cifs"; - credentials = config.age.secrets._nhitrl_cred.path; - user = null; - uid = "1001"; - gid = "100"; - dir_mode = "0777"; - file_mode = "0777"; - }; - in - "felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d" - ) - ( - let - args = { - "-fstype" = "cifs"; - credentials = config.age.secrets._nhitrl_cred.path; - user = null; - uid = "1001"; - gid = "100"; - dir_mode = "0777"; - file_mode = "0777"; - }; - in - "felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f" - ) - ]; - persoConf = pkgs.writeText "auto.personal" (builtins.concatStringsSep "\n" personalStorage); - in - { - enable = true; - # Creates /perso directory with every subdirectory declared by ${personalStorage} - # as of now (might be stale), /perso/hot is the only mount accessible - # that is also managed by s3fs - autoMaster = '' - /perso file:${persoConf} - ''; - timeout = 30; # default: 600, 600 seconds (10 mins) of inactivity => unmount - # debug = true; # writes to more to journalctl - }; + in "felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d" + ) + ( + let + args = { + "-fstype" = "cifs"; + credentials = config.age.secrets._nhitrl_cred.path; + user = null; + uid = "1001"; + gid = "100"; + dir_mode = "0777"; + file_mode = "0777"; + }; + in "felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f" + ) + ]; + persoConf = pkgs.writeText "auto.personal" (builtins.concatStringsSep "\n" personalStorage); + in { + enable = true; + # Creates /perso directory with every subdirectory declared by ${personalStorage} + # as of now (might be stale), /perso/hot is the only mount accessible + # that is also managed by s3fs + autoMaster = '' + /perso file:${persoConf} + ''; + timeout = 30; # default: 600, 600 seconds (10 mins) of inactivity => unmount + # debug = true; # writes to more to journalctl + }; } diff --git a/modules/tailscale.sys.nix b/modules/tailscale.sys.nix index 6e3e1bb..56711e6 100644 --- a/modules/tailscale.sys.nix +++ b/modules/tailscale.sys.nix @@ -1,22 +1,25 @@ -{ pkgs -, config -, lib -, ... -}: let cfg = config.mod.tailscale; in { - options.mod.tailscale = { +{ + pkgs, + config, + lib, + ... +}: let + cfg = config.mod.tailscale; +in { + options.mod.tailscale = { enable = lib.mkEnableOption "tailscale"; }; config = lib.mkIf cfg.enable { - environment.systemPackages = [ pkgs.tailscale ]; + environment.systemPackages = [pkgs.tailscale]; services.tailscale.enable = true; systemd.services.tailscale-autoconnect = { description = "Automatically connects to Tailscale"; # make sure tailscale is running before trying to connect to tailscale - after = [ "network-pre.target" "tailscale.service" ]; - wants = [ "network-pre.target" "tailscale.service" ]; - wantedBy = [ "multi-user.target" ]; + after = ["network-pre.target" "tailscale.service"]; + wants = ["network-pre.target" "tailscale.service"]; + wantedBy = ["multi-user.target"]; # set this service as a oneshot job serviceConfig.Type = "oneshot"; @@ -33,7 +36,7 @@ # ${pkgs.tailscale}/bin/tailscale up # blocks, doesn't give url # This time, configure device auth so that we authenticate from portal - # https://tailscale.com/kb/1099/device-authorization/#enable-device-authorization-for-your-network + # https://tailscale.com/kb/1099/device-authorization/#enable-device-authorization-for-your-network ${pkgs.tailscale}/bin/tailscale up -authkey tskey-auth-kJcgTG5CNTRL-PUVFkk31z1bThHpfq3FC5b1jcMmkW2EYW ''; }; diff --git a/modules/wifi.sys.nix b/modules/wifi.sys.nix index 1d615ee..2e1ea9e 100644 --- a/modules/wifi.sys.nix +++ b/modules/wifi.sys.nix @@ -1,4 +1,4 @@ -{ config, ... }: { +{config, ...}: { networking.wireless.enable = true; networking.wireless.environmentFile = config.age.secrets."wifi.env"; networking.wireless.networks = { diff --git a/native_configs/README.md b/native_configs/README.md index 63955ee..f322e6d 100644 --- a/native_configs/README.md +++ b/native_configs/README.md @@ -1,3 +1,17 @@ # Native configs -Contains all configurations that are written in their native language +Contains all configurations that are written in their native configuration language. + +## Why native language? + +- Easier portability +- Syntax highlighting and robust checking without needing to realize derivation +- Nix can read from [JSON](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fromJSON), +[TOML](https://nixos.org/manual/nix/stable/release-notes/rl-2.6.html#release-26-2022-01-24). +- We have also managed to hack together a [fromYaml](./../nix-conf/lib/serde/default.nix), +though it will not work for strictly pure builds or bootstrapping builds. + +## When to use Nix to generate config? + +- Original configuraiton language requires too much duplication that can be solved with Nix + diff --git a/native_configs/neovim/init.fnl b/native_configs/neovim/init.fnl new file mode 100644 index 0000000..20465e7 --- /dev/null +++ b/native_configs/neovim/init.fnl @@ -0,0 +1,721 @@ +(vim.cmd "let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +let plug_path = data_dir . '/autoload/plug.vim' +if empty(glob(plug_path)) + execute '!curl -fLo '.plug_path.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + execute 'so '.plug_path +endif +") +(local Plug (. vim.fn "plug#")) +(local installed-plugins {}) +(each [_ path (ipairs (vim.api.nvim_list_runtime_paths))] + (local last-folder-start (path:find "/[^/]*$")) + (when last-folder-start + (local plugin-name (path:sub (+ last-folder-start 1))) + (tset installed-plugins plugin-name true))) +(fn WPlug [plugin-path ...] + (let [plugin-name (string.lower (plugin-path:match "/([^/]+)$"))] + (when (not (. installed-plugins plugin-name)) (Plug plugin-path ...)))) +(vim.call "plug#begin") +(WPlug :tjdevries/nlua.nvim) +(WPlug :nvim-treesitter/nvim-treesitter) +(WPlug :nvim-treesitter/nvim-treesitter-textobjects) +(WPlug :nvim-telescope/telescope.nvim {:branch :0.1.x}) +(WPlug :nvim-telescope/telescope-fzf-native.nvim {:do "make >> /tmp/log 2>&1"}) +(WPlug :nvim-telescope/telescope-file-browser.nvim) +(WPlug :neovim/nvim-lspconfig) +(WPlug :hrsh7th/cmp-nvim-lsp) +(WPlug :hrsh7th/cmp-path) +(WPlug :hrsh7th/cmp-buffer) +(WPlug :hrsh7th/cmp-cmdline) +(WPlug :hrsh7th/nvim-cmp) +(WPlug :onsails/lspkind-nvim) +(WPlug :yioneko/nvim-yati {:tag "*"}) +(WPlug :nathanalderson/yang.vim) +(WPlug :windwp/nvim-autopairs) +(WPlug :windwp/nvim-ts-autotag) +(WPlug :NMAC427/guess-indent.nvim) +(WPlug :j-hui/fidget.nvim) +(WPlug :numToStr/Comment.nvim) +(WPlug :lewis6991/gitsigns.nvim) +(WPlug :tpope/vim-fugitive) +(WPlug :williamboman/mason.nvim) +(WPlug :williamboman/mason-lspconfig.nvim) +(WPlug :ThePrimeagen/harpoon) +(WPlug :TimUntersberger/neogit) +(WPlug :folke/trouble.nvim) +(WPlug :tpope/vim-dispatch) +(WPlug :clojure-vim/vim-jack-in) +(WPlug :radenling/vim-dispatch-neovim) +(WPlug :gennaro-tedesco/nvim-jqx) +(WPlug :kylechui/nvim-surround) +(WPlug :simrat39/rust-tools.nvim) +(WPlug :simrat39/inlay-hints.nvim) +(WPlug :gruvbox-community/gruvbox) +(WPlug :nvim-lualine/lualine.nvim) +(WPlug :lukas-reineke/indent-blankline.nvim) +(WPlug :kyazdani42/nvim-web-devicons) +(WPlug :m-demare/hlargs.nvim) +(WPlug :folke/todo-comments.nvim) +(WPlug :nvim-treesitter/nvim-treesitter-context) +(WPlug :nvim-treesitter/playground) +(WPlug :saadparwaiz1/cmp_luasnip) +(WPlug :L3MON4D3/LuaSnip) +(WPlug :mickael-menu/zk-nvim) +(WPlug :arthurxavierx/vim-caser) +(WPlug "~/local_repos/ts-ql") +(vim.call "plug#end") +(vim.cmd "if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + PlugInstall --sync | autocmd VimEnter * so $MYVIMRC +endif +") +(vim.api.nvim_create_autocmd [:VimEnter] + {:callback (fn [] + (fn named-term [term-idx term-name] + ((. (require :harpoon.term) + :gotoTerminal) term-idx) + (vim.cmd (.. ":exe \":file " + term-name + "\" | :bfirst"))) + + (named-term 4 "term:ctl") + (named-term 5 "term:dev") + (named-term 7 "term:repl") + (named-term 6 "term:repl2"))}) +(set vim.g.gruvbox_contrast_dark :soft) +(set vim.g.gruvbox_contrast_light :soft) +(set vim.opt.ignorecase true) +(set vim.opt.smartcase true) +(set vim.opt.incsearch true) +(set vim.opt.number true) +(set vim.opt.relativenumber true) +(set vim.opt.autoindent true) +(set vim.opt.smartindent true) +(set vim.opt.expandtab true) +(set vim.opt.exrc true) +(set vim.opt.tabstop 4) +(set vim.opt.softtabstop 4) +(set vim.opt.shiftwidth 4) +(set vim.opt.scrolloff 30) +(set vim.opt.signcolumn :yes) +(set vim.opt.colorcolumn :80) +(set vim.opt.background :dark) +(vim.api.nvim_create_user_command :Dark + (fn [opts] + (let [contrast (or (and (and opts.args + (> (string.len opts.args) + 0)) + opts.args) + vim.g.gruvbox_contrast_dark)] + (set vim.g.gruvbox_contrast_dark contrast) + (set vim.opt.background :dark))) + {:nargs "?"}) +(vim.api.nvim_create_user_command :Light + (fn [opts] + (let [contrast (or (and (and opts.args + (> (string.len opts.args) + 0)) + opts.args) + vim.g.gruvbox_contrast_light)] + (set vim.g.gruvbox_contrast_light + contrast) + (set vim.opt.background :light))) + {:nargs "?"}) +(set vim.opt.lazyredraw true) +(set vim.opt.termguicolors true) +(set vim.opt.cursorline true) +(set vim.opt.swapfile false) +(set vim.opt.backup false) +(set vim.opt.undodir (.. (vim.fn.stdpath :state) :/.vim/undodir)) +(set vim.opt.undofile true) +(set vim.opt.completeopt "menuone,noselect") +(set vim.opt.updatetime 50) +(set vim.g.mapleader " ") +(set vim.g.maplocalleader ",") +(vim.keymap.set [:n :v] : : {:silent true}) +(vim.keymap.set :t : ")") +(vim.keymap.set [:n :i :v] : :mode {:desc ""}) +(vim.keymap.set :n "[d" vim.diagnostic.goto_prev) +(vim.keymap.set :n "]d" vim.diagnostic.goto_next) +(vim.keymap.set :n :e vim.diagnostic.open_float) +(vim.keymap.set :n :q "TroubleToggle loclist") +(vim.keymap.set :n :wq "TroubleToggle workspace_diagnostics") +(vim.keymap.set :n :gg :GuessIndent) +(vim.cmd "colorscheme gruvbox\n") +((. (require :hlargs) :setup)) +((. (require :nvim-web-devicons) :setup)) +((. (require :trouble) :setup)) +((. (require :todo-comments) :setup)) +(fn remap [mode key-cmd binded-fn opts] + (set-forcibly! opts (or opts {:remap true})) + (vim.keymap.set mode key-cmd binded-fn opts)) +((. (require :Comment) :setup)) +(set vim.opt.list true) +(vim.opt.listchars:append "space:⋅") +(vim.opt.listchars:append "eol:↴") +((. (require :indent_blankline) :setup) {:show_end_of_line true + :space_char_blankline " "}) +(vim.api.nvim_create_user_command :HalfSpaces + (fn [opts] + (vim.api.nvim_command "set ts=2 sts=2 noet") + (vim.api.nvim_command :retab!) + (vim.api.nvim_command "set ts=1 sts=1 et") + (vim.api.nvim_command :retab) + (vim.api.nvim_command :GuessIndent)) + {:nargs 0}) +(vim.api.nvim_create_user_command :DoubleSpaces + (fn [opts] + (vim.api.nvim_command "set ts=2 sts=2 noet") + (vim.api.nvim_command :retab!) + (vim.api.nvim_command "set ts=4 sts=4 et") + (vim.api.nvim_command :retab) + (vim.api.nvim_command :GuessIndent)) + {:nargs 0}) +(local fb-actions (. (. (. (require :telescope) :extensions) :file_browser) + :actions)) +((. (require :telescope) :setup) {:defaults {:mappings {:i {: false + : false}}} + :extensions {:file_browser {:hiject_netrw true + :mappings {:i {} + :n {:c fb-actions.create + :d fb-actions.remove + :e fb-actions.goto_home_dir + :f fb-actions.toggle_browser + :g fb-actions.goto_parent_dir + :h fb-actions.toggle_hidden + :m fb-actions.move + :o fb-actions.open + :r fb-actions.rename + :s fb-actions.toggle_all + :t fb-actions.change_cwd + :w fb-actions.goto_cwd + :y fb-actions.copy}} + :theme (. ((. (require :telescope.themes) + :get_ivy)) + :theme)} + :fzf {:case_mode :smart_case + :fuzzy true + :override_file_sorter true + :override_generic_sorter true}}}) +(pcall (. (require :telescope) :load_extension) :fzf) +(pcall (. (require :telescope) :load_extension) :file_browser) +(remap :n : :Telescope {:desc "Open Telescope general search"}) +(remap :n :fm (fn [] + ((. (. (. (require :telescope) :extensions) + :file_browser) + :file_browser) {})) + {:desc "[F]ile [M]utation"}) +(remap :n :ff + (fn [] + ((. (require :telescope.builtin) :find_files) {:follow false + :hidden false + :no_ignore false})) + {:desc "[F]ind [F]ile"}) +(remap :n :fa + (fn [] + ((. (require :telescope.builtin) :find_files) {:follow true + :hidden true + :no_ignore true})) + {:desc "[F]ind [A]ll files"}) +(remap :n :fg + (fn [] + ((. (require :telescope.builtin) :live_grep))) + {:desc "[F]ind by [G]rep"}) +(remap :n :fug + (fn [] + ((. (require :telescope.builtin) :live_grep) {:glob_pattern "**/*"})) + {:desc "[F]ind by [u]nrestricted [G]rep"}) +(remap :n :fb + (fn [] + ((. (require :telescope.builtin) :buffers))) + {:desc "[F]ind existing [B]uffers"}) +(remap :n :fh + (fn [] + ((. (require :telescope.builtin) :help_tags))) + {:desc "[F]ind [H]elp"}) +(remap :n :fd + (fn [] + ((. (require :telescope.builtin) :diagnostics))) + {:desc "[F]ind [D]iagnostics"}) +(remap :n :zf + (fn [] + ((. (require :zk) :edit) {} {:multi_select false})) + {:desc "[Z]ettelkasten [F]iles"}) +(remap :n :zg (fn [] (vim.cmd ":ZkGrep")) + {:desc "[Z]ettelkasten [G]rep"}) +(for [i 1 9] + (vim.api.nvim_set_keymap :n (.. : i) (.. ":tabn " i :) + {:noremap true :silent true})) +(set vim.o.showtabline 1) +(set vim.o.tabline "%!v:lua.my_tabline()") +(fn _G.my_tabline [] + (var s "") + (for [i 1 (vim.fn.tabpagenr "$")] + (if (= i (vim.fn.tabpagenr)) (set s (.. s "%" i "T%#TabLineSel#")) + (set s (.. s "%" i "T%#TabLine#"))) + (local tab (. (vim.fn.gettabinfo i) 1)) + (local tabbuf tab.variables.buffers) + (var bufname :) + (when tabbuf + (set bufname (. (. tabbuf tab.curwin) :name))) + (set s (.. s " " i " " (vim.fn.fnamemodify bufname ":t"))) + (when (not= i (vim.fn.tabpagenr "$")) + (set s (.. s "%#TabLine#|%#TabLine#")))) + (.. s "%T%#TabLineFill#%=")) +(vim.api.nvim_set_keymap :n :x + ":tabdo if tabpagenr() > 1 | tabclose | endif" + {:noremap true :silent true}) +(require :treesitter-context) +((. (require :nvim-treesitter.configs) :setup) {:autotag {:enable true} + :highlight {:enable true + :enable_vim_regex_highlighting true} + :incremental_selection {:enable true + :keymaps {:init_selection : + :node_decremental : + :node_incremental : + :pscope_incremental :}} + :indent {:enable false} + :playground {:disable {} + :enable true} + :textobjects {:select {:enable true + :keymaps {:ac "@class.outer" + :af "@function.outer" + :ic "@class.inner" + :if "@function.inner"} + :lookahead true}} + :yati {:default_fallback :auto + :default_lazy true + :disable [:nix] + :enable true}}) +((. (require :nvim-autopairs) :setup) {:check_ts true}) +(local parser-config + ((. (require :nvim-treesitter.parsers) :get_parser_configs))) +(set parser-config.tsx.filetype_to_parsername [:javascript :typescript.tsx]) +(set parser-config.astro.filetype_to_parsername + [:javascript :typescript.tsx :astro]) +((. (require :guess-indent) :setup) {:auto_cmd true + :filetype_exclude [:netrw :tutor]}) +(remap :n :m + (fn [] + ((. (require :harpoon.mark) :add_file))) + {:desc "[H]arpoon [M]ark"}) +(fn harpoon-nav [key nav-file-index lead-keybind] + (set-forcibly! lead-keybind (or lead-keybind :h)) + (assert (= (type key) :string) "expect key to be string(keybind)") + (assert (and (= (type nav-file-index) :number) (>= nav-file-index 1)) + "expect 1-indexed number for file index") + (remap :n (.. lead-keybind key) + (fn [] + ((. (require :harpoon.ui) :nav_file) nav-file-index)) + {:desc (.. "[H]arpoon navigate " (tostring nav-file-index))})) +(harpoon-nav :f 1) +(harpoon-nav :j 2) +(harpoon-nav :d 3) +(harpoon-nav :k 4) +(remap :n :hh + (fn [] + ((. (require :harpoon.ui) :toggle_quick_menu)))) +(for [i 1 10] + (harpoon-nav (tostring (% i 10)) i) + (remap :n (.. :t (tostring (% i 10))) + (fn [] + ((. (require :harpoon.term) :gotoTerminal) i)))) +((. (require :neogit) :setup) {}) +(remap :n :gs (fn [] + ((. (require :neogit) :open) {})) + {:desc "[G]it [S]tatus"}) +((. (require :inlay-hints) :setup) {:eol {:right_align false} + :only_current_line false}) +(fn on-attach [client bufnr] + (fn nmap [keys func desc] + (when desc (set-forcibly! desc (.. "LSP: " desc))) + (vim.keymap.set :n keys func {:buffer bufnr : desc :noremap true})) + + (nmap :rn vim.lsp.buf.rename "[R]e[n]ame") + (nmap :ca vim.lsp.buf.code_action "[C]ode [A]ction") + (vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc") + (nmap :df (fn [] (vim.lsp.buf.format {:async true})) + "[D]ocument [F]ormat") + (nmap :gd vim.lsp.buf.definition "[G]oto [D]efinition") + (nmap :gi vim.lsp.buf.implementation "[G]oto [I]mplementation") + (nmap :gr (. (require :telescope.builtin) :lsp_references)) + (nmap :ds (. (require :telescope.builtin) :lsp_document_symbols) + "[D]ocument [S]ymbols") + (nmap :ws (. (require :telescope.builtin) + :lsp_dynamic_workspace_symbols) + "[W]orkspace [S]ymbols") + (nmap :K vim.lsp.buf.hover "Hover Documentation") + (nmap : vim.lsp.buf.signature_help "Signature Documentation") + (nmap :gD vim.lsp.buf.declaration "[G]oto [D]eclaration") + (nmap :gtd vim.lsp.buf.type_definition "[G]oto [T]ype [D]efinition") + (nmap :D vim.lsp.buf.type_definition "Type [D]efinition") + (nmap :wa vim.lsp.buf.add_workspace_folder "[W]orkspace [A]dd Folder") + (nmap :wr vim.lsp.buf.remove_workspace_folder + "[W]orkspace [R]emove Folder") + (nmap :wl + (fn [] + (print (vim.inspect (vim.lsp.buf.list_workspace_folders)))) + "[W]orkspace [L]ist Folders") + ((. (require :inlay-hints) :on_attach) client bufnr)) +(local cmp (require :cmp)) +(local luasnip (require :luasnip)) +(local lspkind (require :lspkind)) +(local source-mapping {:buffer "[Buffer]" + :nvim_lsp "[LSP]" + :nvim_lua "[Lua]" + :path "[Path]"}) +(cmp.event:on :confirm_done ((. (require :nvim-autopairs.completion.cmp) + :on_confirm_done))) +(cmp.setup {:formatting {:format (fn [entry vim-item] + (set vim-item.kind + (lspkind.symbolic vim-item.kind + {:mode :symbol})) + (set vim-item.menu + (. source-mapping entry.source_name)) + (local maxwidth 80) + (set vim-item.abbr + (string.sub vim-item.abbr 1 maxwidth)) + vim-item)} + :mapping (cmp.mapping.preset.insert {: (cmp.mapping.scroll_docs 4) + : (cmp.mapping.complete) + : (cmp.mapping.scroll_docs (- 4)) + : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace + :select true}) + : (cmp.mapping (fn [fallback] + (if (cmp.visible) + (cmp.select_prev_item) + (luasnip.jumpable (- 1)) + (luasnip.jump (- 1)) + (fallback))) + [:i :s]) + : (cmp.mapping (fn [fallback] + (if (cmp.visible) + (cmp.select_next_item) + (luasnip.expand_or_jumpable) + (luasnip.expand_or_jump) + (fallback))) + [:i :s])}) + :snippet {:expand (fn [args] (luasnip.lsp_expand args.body))} + :sources (cmp.config.sources [{:name :nvim_lsp} + {:name :luasnip} + {:name :buffer} + {:name :path}])}) +(local capabilities ((. (require :cmp_nvim_lsp) :default_capabilities))) +(local servers [:clangd + :rust_analyzer + :pyright + :tsserver + :lua_ls + :cmake + :tailwindcss + :prismals + :rnix + :eslint + :terraformls + :tflint + :svelte + :astro + :clojure_lsp + :bashls + :yamlls + :ansiblels + :jsonls + :denols + :gopls + :nickel_ls + :pylsp]) +((. (require :mason) :setup) {:PATH :append + :ui {:check_outdated_packages_on_open true + :icons {:package_installed "✓" + :package_pending "➜" + :package_uninstalled "✗"}}}) +((. (require :mason-lspconfig) :setup) {:automatic_installation false}) +(local inlay-hint-tsjs + {:includeInlayEnumMemberValueHints true + :includeInlayFunctionLikeReturnTypeHints true + :includeInlayFunctionParameterTypeHints true + :includeInlayParameterNameHints :all + :includeInlayPropertyDeclarationTypeHints true + :includeInlayVariableTypeHints true + :inlcudeInlayParameterNameHintsWhenArgumentMatchesName false}) +((. (require :mason-lspconfig) :setup_handlers) {1 (fn [server-name] + ((. (. (require :lspconfig) + server-name) + :setup) {: capabilities + :on_attach on-attach})) + :denols (fn [] + ((. (. (require :lspconfig) + :denols) + :setup) {: capabilities + :on_attach on-attach + :root_dir ((. (require :lspconfig.util) + :root_pattern) :deno.json + :deno.jsonc)})) + :lua_ls (fn [] + ((. (. (require :lspconfig) + :lua_ls) + :setup) {: capabilities + :on_attach on-attach + :settings {:Lua {:diagnostics {:globals [:vim]} + :format {:defaultConfig {:indent_size 4 + :indent_style :space} + :enable true} + :hint {:enable true} + :runtime {:path (vim.split package.path + ";") + :version :LuaJIT} + :telemetry {:enable false} + :workspace {:library (vim.api.nvim_get_runtime_file "" + true)}}}})) + :pyright (fn [] + ((. (. (require :lspconfig) + :pyright) + :setup) {: capabilities + :on_attach on-attach + :settings {:pyright {:disableLanguageServices false + :disableOrganizeImports false} + :python {:analysis {:autoImportCompletions true + :autoSearchPaths true + :diagnosticMode :openFilesOnly + :extraPaths {} + :logLevel :Information + :pythonPath :python + :stubPath :typings + :typeCheckingMode :basic + :typeshedPaths {} + :useLibraryCodeForTypes false + :venvPath ""} + :linting {:mypyEnabled true}}}})) + :tsserver (fn [] + ((. (. (require :lspconfig) + :tsserver) + :setup) {: capabilities + :on_attach on-attach + :root_dir ((. (require :lspconfig.util) + :root_pattern) :package.json) + :settings {:javascript inlay-hint-tsjs + :typescript inlay-hint-tsjs}})) + :yamlls (fn [] + ((. (. (require :lspconfig) + :yamlls) + :setup) {: capabilities + :on_attach on-attach + :settings {:yaml {:keyOrdering false}}}))}) +((. (require :rust-tools) :setup) {:dap {:adapter {:command :lldb-vscode + :name :rt_lldb + :type :executable}} + :server {: capabilities + :cmd [:rust-analyzer] + :on_attach (fn [client bufnr] + (fn nmap [keys + func + desc] + (when desc + (set-forcibly! desc + (.. "LSP: " + desc))) + (vim.keymap.set :n + keys + func + {:buffer bufnr + : desc + :noremap true})) + + (on-attach client + bufnr) + (nmap :K + (. (. (require :rust-tools) + :hover_actions) + :hover_actions) + "Hover Documentation")) + :settings {:rust-analyzer {:cargo {:loadOutDirsFromCheck true} + :checkOnSave {:command :clippy + :extraArgs [:--all + "--" + :-W + "clippy::all"]} + :procMacro {:enable true} + :rustfmt {:extraArgs [:+nightly]}}} + :standalone true} + :tools {:crate_graph {:backend :x11 + :enabled_graphviz_backends [:bmp + :cgimage + :canon + :dot + :gv + :xdot + :xdot1.2 + :xdot1.4 + :eps + :exr + :fig + :gd + :gd2 + :gif + :gtk + :ico + :cmap + :ismap + :imap + :cmapx + :imap_np + :cmapx_np + :jpg + :jpeg + :jpe + :jp2 + :json + :json0 + :dot_json + :xdot_json + :pdf + :pic + :pct + :pict + :plain + :plain-ext + :png + :pov + :ps + :ps2 + :psd + :sgi + :svg + :svgz + :tga + :tiff + :tif + :tk + :vml + :vmlz + :wbmp + :webp + :xlib + :x11] + :full true + :output nil} + :executor (. (require :rust-tools/executors) + :termopen) + :hover_actions {:auto_focus false + :border [["╭" + :FloatBorder] + ["─" + :FloatBorder] + ["╮" + :FloatBorder] + ["│" + :FloatBorder] + ["╯" + :FloatBorder] + ["─" + :FloatBorder] + ["╰" + :FloatBorder] + ["│" + :FloatBorder]]} + :inlay_hints {:auto false + :highlight :NonText + :max_len_align false + :max_len_align_padding 1 + :only_current_line true + :other_hints_prefix "=> " + :parameter_hints_prefix "<- " + :right_align false + :right_align_padding 7 + :show_parameter_hints true} + :on_initialized (fn [] + ((. (require :inlay-hints) + :set_all))) + :reload_workspace_from_cargo_toml true}}) +((. (require :zk) :setup) {:lsp {:auto_attach {:enable true + :filetypes [:markdown]} + :config {:cmd [:zk :lsp] + :name :zk + :on_attach on-attach}} + :picker :telescope}) +((. (require :zk.commands) :add) :ZkOrphans + (fn [options] + (set-forcibly! options + (vim.tbl_extend :force + {:orphan true} + (or options + {}))) + ((. (require :zk) :edit) options + {:title "Zk Orphans (unlinked notes)"}))) +((. (require :zk.commands) :add) :ZkGrep + (fn [match-ctor] + (var grep-str match-ctor) + (var ___match___ nil) + (if (or (= match-ctor nil) (= match-ctor "")) + (do + (vim.fn.inputsave) + (set grep-str + (vim.fn.input "Grep string: >")) + (vim.fn.inputrestore) + (set ___match___ {:match grep-str})) + (= (type match-ctor) :string) + (set ___match___ {:match grep-str})) + ((. (require :zk) :edit) ___match___ + {:mutli_select false + :title (.. "Grep: '" + grep-str + "'")}))) +((. (require :gitsigns) :setup) {:signs {:add {:text "+"} + :change {:text "~"} + :changedelete {:text "~"} + :delete {:text "_"} + :topdelete {:text "‾"}}}) +((. (require :lualine) :setup) {:inactive_sections {:lualine_a {} + :lualine_b {} + :lualine_c [{1 :filename + :file_status true + :path 1}] + :lualine_x [:location] + :lualine_y {} + :lualine_z {}} + :options {:icons_enabled true} + :sections {:lualine_a [:mode] + :lualine_b [:branch + :diff + :diagnostics] + :lualine_c [{1 :filename + :file_status true + :newfile_status false + :path 1 + :symbols {:modified "[+]" + :newfile "[New]" + :readonly "[-]" + :unnamed "[Unnamed]"}}] + :lualine_x [:encoding + :fileformat + :filetype] + :lualine_y [:progress] + :lualine_z [:location]}}) +((. (require :nvim-surround) :setup) {}) +((. (require :tsql) :setup)) +((. (require :fidget) :setup) {:align {:bottom true :right true} + :debug {:logging false :strict false} + :fmt {:fidget (fn [fidget-name spinner] + (string.format "%s %s" spinner + fidget-name)) + :leftpad true + :max_width 0 + :stack_upwards true + :task (fn [task-name message percentage] + (string.format "%s%s [%s]" message + (or (and percentage + (string.format " (%s%%)" + percentage)) + "") + task-name))} + :sources {:* {:ignore false}} + :text {:commenced :Started + :completed :Completed + :done "✔" + :spinner :moon} + :timer {:fidget_decay 2000 + :spinner_rate 125 + :task_decay 1000} + :window {:blend 100 + :border :none + :relative :editor + :zindex nil}}) diff --git a/native_configs/neovim/init.lua b/native_configs/neovim/init.lua index b4b3979..ff1c73c 100644 --- a/native_configs/neovim/init.lua +++ b/native_configs/neovim/init.lua @@ -1,138 +1,162 @@ --- What: Mono-file nvim configuration file --- Why: Easy to see through everything without needing to navigate thru files --- Features: --- - LSP +-- What: Mono-file nvim configuration file Why: Easy to see through everything without needing to navigate thru files Features: - LSP -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) -- - df to format document -- - Harpoon marks: Navigate through main files within each project -- --- REQUIREMENTS: --- - zk @ https://github.com/mickael-menu/zk --- - prettierd @ npm install -g @fsouza/prettierd +-- Auto-installs vim-plug vim.cmd([[ let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' let plug_path = data_dir . '/autoload/plug.vim' if empty(glob(plug_path)) - execute '!curl -fLo '.plug_path.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - execute 'so '.plug_path + execute '!curl -fLo '.plug_path.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + execute 'so '.plug_path endif ]]) -local function truthy(v) return v ~= nil end - -local function cfg(cfg_var, do_fn) if truthy(cfg_var) then do_fn() end end - -- vim-plug local Plug = vim.fn['plug#'] +-- prepare a list of installed plugins from rtp +local installed_plugins = {} +-- NOTE: nvim_list_runtime_paths will expand wildcard paths for us. +for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do + local last_folder_start = path:find("/[^/]*$") + if last_folder_start then + local plugin_name = path:sub(last_folder_start + 1) + installed_plugins[plugin_name] = true + end +end + +local wplug_log = require('plenary.log').new({ plugin = 'wplug_log', level = 'debug', use_console = false }) +-- Do Plug if plugin not yet linked in `rtp`. This takes care of Nix-compatibility +local function WPlug(plugin_path, ...) + local plugin_name = string.lower(plugin_path:match("/([^/]+)$")) + if not installed_plugins[plugin_name] then + wplug_log.info("Plugging " .. plugin_path) + Plug(plugin_path, ...) + end +end + vim.call('plug#begin') -- libs and dependencies -Plug('nvim-lua/plenary.nvim') -- The base of all plugins +-- Plug('nvim-lua/plenary.nvim') -- The base of all plugins -- plugins -Plug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua -Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting -Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects -Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser +WPlug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua +WPlug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting +WPlug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects +WPlug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser -- TODO: this might need to be taken extra care in our Nix config --- What this Plug declaration means is this repo needs to be built on our running environment +-- What this WPlug declaration means is this repo needs to be built on our running environment -- ----- -- What to do: -- - Run `make` at anytime before Nix is done on this repository --- - Might mean that we fetch this repository, run make, and copy to destination folder --- - Make sure that if we run `make` at first Plug run, that `make` is idempotent +-- - Might mean that we fetch this repository, run make, and copy to destination folder +-- - Make sure that if we run `make` at first WPlug run, that `make` is idempotent -- OR --- Make sure that Plug does not run `make` and use the output it needs -Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'make >> /tmp/log 2>&1' }) -Plug('nvim-telescope/telescope-file-browser.nvim') +-- Make sure that WPlug does not run `make` and use the output it needs +WPlug('nvim-telescope/telescope-fzf-native.nvim', + { ['do'] = 'make >> /tmp/log 2>&1' }) +WPlug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions -Plug('neovim/nvim-lspconfig') -- built-in LSP configurations -Plug('hrsh7th/cmp-nvim-lsp') -Plug('hrsh7th/cmp-path') -Plug('hrsh7th/cmp-buffer') -Plug('hrsh7th/cmp-cmdline') -Plug('hrsh7th/nvim-cmp') -Plug('onsails/lspkind-nvim') -Plug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent --- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) +WPlug('neovim/nvim-lspconfig') -- built-in LSP configurations +WPlug('hrsh7th/cmp-nvim-lsp') +WPlug('hrsh7th/cmp-path') +WPlug('hrsh7th/cmp-buffer') -- Recommends words within the buffer +WPlug('hrsh7th/cmp-cmdline') +WPlug('hrsh7th/nvim-cmp') +WPlug('hrsh7th/cmp-nvim-lsp-signature-help') +WPlug('onsails/lspkind-nvim') +WPlug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent +WPlug('nathanalderson/yang.vim') +-- WPlug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- DevExp -Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... -Plug('windwp/nvim-ts-autotag') -- matches tags hello -Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer -Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines -Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns -Plug('tpope/vim-fugitive') -- git commands in nvim -Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager -Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason -Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project -Plug('TimUntersberger/neogit') -- Easy-to-see git status -Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics -Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands -Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein" -Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator -Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) -Plug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) -Plug('kylechui/nvim-surround') -- surrounds with tags/parenthesis -Plug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration +WPlug('windwp/nvim-autopairs') -- matches pairs like [] (),... +WPlug('windwp/nvim-ts-autotag') -- matches tags hello +WPlug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer +WPlug('j-hui/fidget.nvim') -- Progress bar for LSP +WPlug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines +WPlug('lewis6991/gitsigns.nvim') -- add git info to sign columns +WPlug('tpope/vim-fugitive') -- git commands in nvim +WPlug('williamboman/mason.nvim') -- LSP, debuggers,... package manager +WPlug('williamboman/mason-lspconfig.nvim') -- lsp config for mason +WPlug('ThePrimeagen/harpoon') -- 1-click through marked files per project +WPlug('TimUntersberger/neogit') -- Easy-to-see git status +WPlug('folke/trouble.nvim') -- File-grouped workspace diagnostics +WPlug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands +WPlug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein" +WPlug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator +-- WPlug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) +WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) +WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis +WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration -- UI & colorscheme -Plug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts -Plug('gruvbox-community/gruvbox') -- theme provider -Plug('nvim-lualine/lualine.nvim') -- fancy status line -Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines -Plug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes -Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog -Plug('folke/todo-comments.nvim') -- Highlights TODO +WPlug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts +WPlug('gruvbox-community/gruvbox') -- theme provider +WPlug('nvim-lualine/lualine.nvim') -- fancy status line +WPlug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines +WPlug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes +WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog +WPlug('folke/todo-comments.nvim') -- Highlights TODO +WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support +WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color for tailiwnd for compe -- other utilities -Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) -Plug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope -Plug('nvim-treesitter/playground') -- Sees Treesitter AST - less hair pulling, more PRs -Plug('saadparwaiz1/cmp_luasnip') -- snippet engine -Plug('L3MON4D3/LuaSnip') -- snippet engine -Plug('mickael-menu/zk-nvim') -- Zettelkasten +WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope +WPlug('nvim-treesitter/playground') -- Sees Treesitter AST - less hair pulling, more PRs +WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine +WPlug('L3MON4D3/LuaSnip') -- snippet engine +WPlug('mickael-menu/zk-nvim') -- Zettelkasten +WPlug('folke/neodev.nvim') -- Neovim + lua development setup -- Switch cases: -- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust) -- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case -- `gs.` -> dot.case (R) -Plug('arthurxavierx/vim-caser') -- switch cases +WPlug('arthurxavierx/vim-caser') -- switch cases --------- vim.call('plug#end') +local PLUGIN_URI = 'gh:pegasust:dotfiles' +local PLUGIN_LEVEL = 'debug' +local log = require('plenary.log').new({ plugin = PLUGIN_URI, level = PLUGIN_LEVEL, use_console = false }) + vim.cmd([[ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) - PlugInstall --sync | autocmd VimEnter * so $MYVIMRC + PlugInstall --sync | autocmd VimEnter * so $MYVIMRC endif ]]) -- special terminals, place them at 4..=7 for ergonomics +-- NOTE: this requires a flawless startup, otherwise, it's going to throw errors +-- since we're basically simulating keystrokes +-- TODO: The correct behavior is to register terminal keystroke with an assigned +-- buffer vim.api.nvim_create_autocmd({ "VimEnter" }, { - callback = function() - local function named_term(term_idx, term_name) - require('harpoon.term').gotoTerminal(term_idx) - vim.cmd([[:exe ":file ]] .. term_name .. [[" | :bfirst]]) - end - - -- term:ctl at 4 - named_term(4, "term:ctl") - -- term:dev at 5 - named_term(5, "term:dev") - -- term:repl at 7 - named_term(7, "term:repl") - -- term:repl at 6 - named_term(6, "term:repl2") + callback = function() + local function named_term(term_idx, term_name) + require('harpoon.term').gotoTerminal(term_idx) + vim.cmd([[:exe ":file ]] .. term_name .. [[" | :bfirst]]) end + + -- term:ctl at 4 + named_term(4, "term:ctl") + -- term:dev at 5 + named_term(5, "term:dev") + -- term:repl at 7 + named_term(7, "term:repl") + -- term:repl at 6 + named_term(6, "term:repl2") + end }) - -vim.g.gruvbox_contrast_dark="soft"; -vim.g.gruvbox_contrast_light="soft"; +vim.g.gruvbox_contrast_dark = "soft"; +vim.g.gruvbox_contrast_light = "soft"; vim.opt.ignorecase = true; vim.opt.smartcase = true; vim.opt.incsearch = true; @@ -150,7 +174,7 @@ vim.opt.scrolloff = 30; vim.opt.signcolumn = "yes"; vim.opt.colorcolumn = "80"; -vim.opt.background = "light"; +vim.opt.background = "dark"; vim.api.nvim_create_user_command('Dark', function(opts) -- opts: {name, args: str, fargs: Splited, range, ...} @@ -158,17 +182,17 @@ vim.api.nvim_create_user_command('Dark', function(opts) local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_dark; vim.g.gruvbox_contrast_dark = contrast; vim.opt.background = "dark"; -end, - {nargs = "?";}) + end, + { nargs = "?", }) vim.api.nvim_create_user_command('Light', function(opts) -- opts: {name, args: str, fargs: Splited, range, ...} ---@type string - local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_dark; + local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_light; vim.g.gruvbox_contrast_light = contrast; vim.opt.background = "light"; -end, - {nargs = "?";}) + end, + { nargs = "?", }) vim.opt.lazyredraw = true vim.opt.termguicolors = true @@ -176,9 +200,14 @@ vim.opt.cursorline = true -- some plugins misbehave when we do swap files vim.opt.swapfile = false vim.opt.backup = false -vim.opt.undodir = vim.fn.stdpath('state')..'/.vim/undodir' +vim.opt.undodir = vim.fn.stdpath('state') .. '/.vim/undodir' vim.opt.undofile = true -vim.opt.completeopt = 'menuone,noselect' +-- show menu even if there's 1 selection, and default to no selection +-- Note that we're not setitng `noinsert`, which allows us to "foresee" what the +-- completion would give us. This is faithful to VSCode +vim.opt.completeopt = { "menu", "menuone", "noselect", "noinsert" } + + -- vim.opt.clipboard = "unnamedplus" -- more aggressive swap file writing. ThePrimeagen believes higher number -- leads to low DX @@ -204,14 +233,65 @@ vim.keymap.set('n', 'e', vim.diagnostic.open_float) -- opens diag in box -- vim.keymap.set('n', 'wq', vim.diagnostic.setqflist) -- workspace diags vim.keymap.set('n', 'q', 'TroubleToggle loclist') vim.keymap.set('n', 'wq', 'TroubleToggle workspace_diagnostics') +vim.keymap.set('n', 'gg', 'GuessIndent') -- color, highlighting, UI stuffs -vim.cmd([[ +vim.cmd([[ colorscheme gruvbox ]]) require('hlargs').setup() require('nvim-web-devicons').setup() -require('trouble').setup() +require('trouble').setup { + position = "bottom", -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT + fold_open = "", -- icon used for open folds + fold_closed = "", -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { + -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = "q", -- close the list + cancel = "", -- cancel the preview and get back to your last window / buffer / cursor + refresh = "r", -- manually refresh + jump = { "", "" }, -- jump to the diagnostic or open / close folds + open_split = { "" }, -- open buffer in new split + open_vsplit = { "" }, -- open buffer in new vsplit + open_tab = { "" }, -- open buffer in new tab + jump_close = { "o" }, -- jump to the diagnostic and close the list + toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode + switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR + toggle_preview = "P", -- toggle auto_preview + hover = "K", -- opens a small popup with the full multiline message + preview = "p", -- preview the diagnostic location + close_folds = { "zM", "zm" }, -- close all folds + open_folds = { "zR", "zr" }, -- open all folds + toggle_fold = { "zA", "za" }, -- toggle fold of current file + previous = "k", -- previous item + next = "j" -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = "", + warning = "", + hint = "", + information = "", + other = "", + }, + use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client +} + -- TODO: Any way to collect all the TODOs and its variants? require('todo-comments').setup() @@ -219,8 +299,8 @@ require('todo-comments').setup() -- plugin keymaps local function remap(mode, key_cmd, binded_fn, opts) - opts = opts or { remap = true } - return vim.keymap.set(mode, key_cmd, binded_fn, opts) + opts = opts or { remap = true } + return vim.keymap.set(mode, key_cmd, binded_fn, opts) end -- Comment.nvim @@ -231,76 +311,84 @@ vim.opt.listchars:append "space:⋅" vim.opt.listchars:append "eol:↴" require("indent_blankline").setup { - show_end_of_line = true, - space_char_blankline = " ", + show_end_of_line = true, + space_char_blankline = " ", + } -- User command that transform into 2-spaces by translating to tabstop vim.api.nvim_create_user_command( - 'HalfSpaces', - function(opts) - vim.api.nvim_command("set ts=2 sts=2 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=1 sts=1 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'HalfSpaces', + function(opts) + vim.api.nvim_command("set ts=2 sts=2 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=1 sts=1 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) vim.api.nvim_create_user_command( - 'DoubleSpaces', - function(opts) - -- cannot really do 1-space tab. The minimum is 2-space to begin - -- doubling - vim.api.nvim_command("set ts=2 sts=2 noet") - vim.api.nvim_command("retab!") - vim.api.nvim_command("set ts=4 sts=4 et") - vim.api.nvim_command("retab") - vim.api.nvim_command("GuessIndent") - end, - { nargs = 0 } + 'DoubleSpaces', + function(opts) + -- cannot really do 1-space tab. The minimum is 2-space to begin + -- doubling + vim.api.nvim_command("set ts=2 sts=2 noet") + vim.api.nvim_command("retab!") + vim.api.nvim_command("set ts=4 sts=4 et") + vim.api.nvim_command("retab") + vim.api.nvim_command("GuessIndent") + end, + { nargs = 0 } ) -- telescope local fb_actions = require "telescope".extensions.file_browser.actions +local tel_actions = require("telescope.actions") +local tel_actionset = require("telescope.actions.set") + +local function term_height() + return vim.opt.lines:get() +end + require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, + defaults = { + mappings = { + n = { + [''] = function(prompt_bufnr) tel_actionset.shift_selection(prompt_bufnr, -math.floor(term_height() / 2)) end, + [''] = function(prompt_bufnr) tel_actionset.shift_selection(prompt_bufnr, math.floor(term_height() / 2)) end, + }, }, - extensions = { - fzf = { - fuzzy = true, -- allow fuzzy matches - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case' - }, - file_browser = { - theme = require('telescope.themes').get_ivy().theme, - hiject_netrw = true, -- disables netrw and use file-browser instead - mappings = { - ["i"] = {}, -- disable any shortcut in insert mode for now - ["n"] = { - ["c"] = fb_actions.create, - ["r"] = fb_actions.rename, - ["m"] = fb_actions.move, - ["y"] = fb_actions.copy, - ["d"] = fb_actions.remove, - ["o"] = fb_actions.open, - ["g"] = fb_actions.goto_parent_dir, - ["e"] = fb_actions.goto_home_dir, - ["w"] = fb_actions.goto_cwd, - ["t"] = fb_actions.change_cwd, - ["f"] = fb_actions.toggle_browser, - ["h"] = fb_actions.toggle_hidden, - ["s"] = fb_actions.toggle_all, - } - } + }, + extensions = { + fzf = { + fuzzy = true, -- allow fuzzy matches + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case' + }, + file_browser = { + theme = require('telescope.themes').get_ivy().theme, + hiject_netrw = true, -- disables netrw and use file-browser instead + mappings = { + ["i"] = {}, -- disable any shortcut in insert mode for now + ["n"] = { + ["c"] = fb_actions.create, + ["r"] = fb_actions.rename, + ["m"] = fb_actions.move, + ["y"] = fb_actions.copy, + ["d"] = fb_actions.remove, + ["o"] = fb_actions.open, + ["g"] = fb_actions.goto_parent_dir, + ["e"] = fb_actions.goto_home_dir, + ["w"] = fb_actions.goto_cwd, + ["t"] = fb_actions.change_cwd, + ["f"] = fb_actions.toggle_browser, + ["h"] = fb_actions.toggle_hidden, + ["s"] = fb_actions.toggle_all, } + } } + } } -- Telescope key remap stuffs @@ -309,102 +397,144 @@ pcall(require('telescope').load_extension, 'file_browser') remap('n', '', 'Telescope', { desc = 'Open Telescope general search' }) remap('n', 'fm', function() - require("telescope").extensions.file_browser.file_browser({}) + require("telescope").extensions.file_browser.file_browser({}) end, { desc = '[F]ile [M]utation' }) remap('n', 'ff', function() - require('telescope.builtin').find_files({ - hidden = false, - no_ignore = false, - follow = false, - }) + require('telescope.builtin').find_files({ + hidden = false, + no_ignore = false, + follow = false, + }) end, { desc = '[F]ind [F]ile' }) remap('n', 'fa', function() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - follow = true, - }) + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + follow = true, + }) end, { desc = '[F]ind [A]ll files' }) remap('n', 'fg', function() - require('telescope.builtin').live_grep() -end, { desc = '[F]ind by [G]rep' }) + require('telescope.builtin').live_grep() +end, { desc = '[F]ind thru [G]rep' }) + +remap('n', 'fug', function() + -- This relies on many factors: We use `rg` and that `-g '**/*'` effectively + -- drops ignore rules like the default `.gitignore` rule. + require('telescope.builtin').live_grep({ glob_pattern = '**/*' }) +end, { desc = '[F]ind thru [u]nrestricted [G]rep' }) remap('n', 'fb', function() - require('telescope.builtin').buffers() + require('telescope.builtin').buffers() end, { desc = '[F]ind existing [B]uffers' }) remap('n', 'fh', function() - require('telescope.builtin').help_tags() + require('telescope.builtin').help_tags() end, { desc = '[F]ind [H]elp' }) remap('n', 'fd', function() - require('telescope.builtin').diagnostics() + require('telescope.builtin').diagnostics() end, { desc = '[F]ind [D]iagnostics' }) -- ZK remap stuffs remap('n', 'zf', function() - -- vim.cmd([[:ZkNotes]]) - require('zk').edit({}, { multi_select = false }) + -- vim.cmd([[:ZkNotes]]) + require('zk').edit({}, { multi_select = false }) end, { desc = '[Z]ettelkasten [F]iles' }) remap('n', 'zg', function() - vim.cmd([[:ZkGrep]]) + vim.cmd(":ZkGrep") end, { desc = '[Z]ettelkasten [G]rep' }) +-- tab management {{{ + +-- Jump to specific tab with [number] +for i = 1, 9 do + vim.api.nvim_set_keymap('n', '' .. i, ':tabn ' .. i .. '', { noremap = true, silent = true }) +end + +-- Show tab number in tab display +vim.o.showtabline = 1 +vim.o.tabline = '%!v:lua.my_tabline()' + +function _G.my_tabline() + local s = '' + for i = 1, vim.fn.tabpagenr('$') do + if i == vim.fn.tabpagenr() then + s = s .. '%' .. i .. 'T%#TabLineSel#' + else + s = s .. '%' .. i .. 'T%#TabLine#' + end + local tab = vim.fn.gettabinfo(i)[1] + local tabbuf = tab.variables.buffers + local bufname = "" + if tabbuf then + bufname = tabbuf[tab.curwin].name + end + -- Canonicalize tab/buf name + s = s .. ' ' .. i .. ' ' .. vim.fn.fnamemodify(bufname, ':t') + if i ~= vim.fn.tabpagenr('$') then + s = s .. '%#TabLine#|%#TabLine#' + end + end + return s .. '%T%#TabLineFill#%=' +end + +-- Close all tabs except the first one +vim.api.nvim_set_keymap('n', 'x', ':tabdo if tabpagenr() > 1 | tabclose | endif', + { noremap = true, silent = true, desc = "Close all tabs except the first one", }) + +-- }}} + -- treesitter require 'treesitter-context' require('nvim-treesitter.configs').setup { - yati = { - enable = true, default_lazy = true, default_fallback = "auto", - disable = { "nix" } + yati = { + enable = true, + default_lazy = true, + default_fallback = "auto", + disable = { "nix" } + }, + indent = { enable = false }, + highlight = { + enable = true, + enable_vim_regex_highlighting = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = '' }, - indent = { enable = false }, - ensure_installed = { - 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", - "clojure", "fennel", "bash", "nix", "query", - }, - sync_install = false, - highlight = { - enable = true, - enable_vim_regex_highlighting = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - pscope_incremental = '' - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - }, - playground = { - enable = true, - disable = {} - }, - -- automatically close and modify HTML and TSX tags - autotag = { - enable = true, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, }, + }, + playground = { + enable = true, + disable = {} + }, + -- automatically close and modify HTML and TSX tags + autotag = { + enable = true, + }, } require('nvim-autopairs').setup { - check_ts = true, + check_ts = true, } local parser_config = require('nvim-treesitter.parsers').get_parser_configs() @@ -413,29 +543,29 @@ parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", " require('guess-indent').setup { - auto_cmd = true, -- Set to false to disable automatic execution - filetype_exclude = { -- A list of filetypes for which the auto command gets disabled - "netrw", - "tutor", - }, + auto_cmd = true, + filetype_exclude = { -- A list of filetypes for which the auto command gets disabled + "netrw", + "tutor", + }, - buftype_exclude = { -- A list of buffer types for which the auto command gets disabled - "help", - "nofile", - "terminal", - -- "prompt", - }, + -- buftype_exclude = { -- A list of buffer types for which the auto command gets disabled + -- "help", + -- "nofile", + -- "terminal", + -- -- "prompt", + -- }, } -- harpoon: O(1) buffer/terminal switching remap('n', 'm', function() require('harpoon.mark').add_file() end, { desc = "[H]arpoon [M]ark" }) local function harpoon_nav(key, nav_file_index, lead_keybind) - lead_keybind = lead_keybind or 'h' - assert(type(key) == "string", "expect key to be string(keybind)") - assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") - return remap('n', lead_keybind .. key, - function() require('harpoon.ui').nav_file(nav_file_index) end, - { desc = "[H]arpoon navigate " .. tostring(nav_file_index) }) + lead_keybind = lead_keybind or 'h' + assert(type(key) == "string", "expect key to be string(keybind)") + assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") + return remap('n', lead_keybind .. key, + function() require('harpoon.ui').nav_file(nav_file_index) end, + { desc = "[H]arpoon navigate " .. tostring(nav_file_index) }) end -- remap letters to index. Inspired by alternating number of Dvorak programmer @@ -446,12 +576,12 @@ harpoon_nav('d', 3) harpoon_nav('k', 4) remap('n', 'hh', function() require('harpoon.ui').toggle_quick_menu() end) for i = 1, 10 do - -- harpoon: navigate files by numbers - harpoon_nav(tostring(i % 10), i) - -- harpoon: navigate terms by numbers - remap('n', 't' .. tostring(i % 10), function() - require('harpoon.term').gotoTerminal(i) - end) + -- harpoon: navigate files by numbers + harpoon_nav(tostring(i % 10), i) + -- harpoon: navigate terms by numbers + remap('n', 't' .. tostring(i % 10), function() + require('harpoon.term').gotoTerminal(i) + end) end -- neogit: easy-to-see git status. Provides only productivity on staging/unstage @@ -461,482 +591,689 @@ remap('n', 'gs', function() require('neogit').open({}) end, { desc = "[G -- LSP settings -- This function gets run when an LSP connects to a particular buffer. require("inlay-hints").setup { - only_current_line = false, - eol = { - right_align = false, - } -} -local on_attach = function(client, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end + -- renderer to use + -- possible options are dynamic, eol, virtline and custom + -- renderer = "inlay-hints/render/dynamic", + renderer = "inlay-hints/render/eol", - vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + hints = { + parameter = { + show = true, + highlight = "whitespace", + }, + type = { + show = true, + highlight = "Whitespace", + }, + }, + + -- Only show inlay hints for the current line + only_current_line = false, + + eol = { + -- whether to align to the extreme right or not + right_align = false, + + -- padding from the right if right_align is true + right_align_padding = 7, + + parameter = { + separator = ", ", + format = function(hints) + return string.format(" <- (%s)", hints) + end, + }, + + type = { + separator = ", ", + format = function(hints) + return string.format(" => %s", hints) + end, + }, + }, +} + + +local on_attach = function(client, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + end - -- symbols and gotos - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('gr', require('telescope.builtin').lsp_references) - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- NOTE: I have no clue what this does again + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + nmap('df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat') - -- documentations. See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- symbols and gotos + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('gr', require('telescope.builtin').lsp_references) + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('gtd', vim.lsp.buf.type_definition, '[G]oto [T]ype [D]efinition') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + -- documentations & helps + -- NOTE: When you press K, it shows in-line Documentation + -- This is to stay faithful with vim's default keybind for help. + -- See `:help K` for even more info on Vim's original keybindings for help + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + -- nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - end, '[W]orkspace [L]ist Folders') - - -- enable inlay hints if available - require('inlay-hints').on_attach(client, bufnr) + -- Less likely LSP functionality to be used + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('gtd', vim.lsp.buf.type_definition, '[G]oto [T]ype [D]efinition') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + -- + -- Very rarely used + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + -- enable inlay hints if available + require('inlay-hints').on_attach(client, bufnr) end -- nvim-cmp + local cmp = require 'cmp' local luasnip = require 'luasnip' local lspkind = require('lspkind') -local source_mapping = { - buffer = '[Buffer]', - nvim_lsp = '[LSP]', - nvim_lua = '[Lua]', - -- cmp_tabnine = '[T9]', - path = '[Path]', -} + +lspkind.init { + symbol_map = { + Copilot = "", + }, +} cmp.event:on( - "confirm_done", - require('nvim-autopairs.completion.cmp').on_confirm_done() + "confirm_done", + require('nvim-autopairs.completion.cmp').on_confirm_done() ) -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, +---@alias EntryFilter {id: integer, compe: lsp.CompletionItem, return_type: string, return_type2: string, score: number, label: string, source_name: string, bufnr: number?, offset: number?, kind: lsp.CompletionItemKind } +---@param entry cmp.Entry +---@return EntryFilter +local function entry_filter_sync(entry) + local compe = entry:get_completion_item() + local return_type = compe.data and compe.data.return_type + local return_type2 = compe.detail + local score = entry.score + local label = compe.label + local source_name = entry.source.name + local bufnr = entry.context.bufnr + local offset = entry:get_offset() + local kind = entry:get_kind() + local id = entry.id + return { + id = id, + compe = compe, + return_type = return_type, + return_type2 = return_type2, + score = score, + label = label, + source_name = source_name, + bufnr = bufnr, + offset = offset, + kind = kind, + } +end + +---@param entry cmp.Entry +---@param callback fun(entry: EntryFilter): any +local function entry_filter(entry, callback) + entry:resolve(function() + callback(entry_filter_sync(entry)) + end) +end + +---@type cmp.ConfigSchema +local cmp_config = { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, }, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() + -- NOTE: rebind tab and shift-tab since it may break whenever we + -- need to peform manual indentation + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + + }, + performance = { + debounce = 60, + throttle = 30, + }, + formatting = { + fields = { 'abbr', 'kind', 'menu' }, + -- vim_items: complete-items (`:h complete-items`) + -- word, abbr, menu, info, kind, icase, equal, dup, empty, user_data + format = function(entry, vim_item) + local kind_fn = lspkind.cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + gh_issues = "[issues]", + tn = "[TabNine]", + eruby = "[erb]", + nvim_lsp_signature_help = "[sig]", + } + } + vim_item = kind_fn(entry, vim_item) + + -- copium that this will force resolve for entry + entry_filter(entry, function(entry) + if entry.source_name == "nvim_lsp" then + log.debug('format:entry: ' .. vim.inspect(entry, { depth = 2 })) + end + end) + + return require('tailwindcss-colorizer-cmp').formatter(entry, vim_item) + end, + }, + sources = cmp.config.sources( --[[@as cmp.SourceConfig[]] { + { name = 'nvim_lsp', max_item_count = 30, }, + { name = 'nvim_lsp_signature_help' }, + -- NOTE: Path is triggered by `.` and `/`, so when it comes up, it's + -- usually desirable. + { name = 'path', max_item_count = 20, }, + { name = 'luasnip', max_item_count = 20, }, + { + name = 'buffer', + option = { + -- default is only in the current buffer. This grabs recommendations + -- from all visible buffers + get_bufnrs = function() + -- Must always have current buffer + local bufs = { [0] = true } + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + local byte_size = vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf)) + if byte_size <= 1024 * 1024 then -- 1 MiB max + bufs[buf] = true end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - }, - formatting = { - format = function(entry, vim_item) - vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' }) - vim_item.menu = source_mapping[entry.source_name] - -- if entry.source.name == "cmp_tabnine" then - -- local detail = (entry.completion_item.data or {}).detail - -- vim_item.kind = "" - -- if detail and detail:find('.*%%.*') then - -- vim_item.kind = vim_item.kind .. ' ' .. detail - -- end - -- - -- if (entry.completion_item.data or {}).multiline then - -- vim_item.kind = vim_item.kind .. ' ' .. '[ML]' - -- end - -- end - local maxwidth = 80 - vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth) - return vim_item + end + return vim.tbl_keys(bufs) end, + }, + max_item_count = 20, + } + -- NOTE: I don't like cmdline that much. Most of the time, it recommends more harm than good + -- { name = 'cmp_tabnine' }, + -- { name = "conjure" }, + }), + experimental = { ghost_text = { hl_group = "Comment" }, }, + sorting = { + comparators = { + cmp.config.compare.exact, + cmp.config.compare.recently_used, + cmp.config.compare.offset, + cmp.config.compare.score, + cmp.config.compare.kind, + cmp.config.compare.locality, + cmp.config.compare.sort_text, + cmp.config.compare.scope, }, - sources = cmp.config.sources { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = "conjure" }, - -- { name = 'cmp_tabnine' }, - }, + }, } + + +cmp.setup(vim.tbl_deep_extend("force", require('cmp.config.default')(), cmp_config)) +-- set max autocomplete height. this prevents huge recommendations to take over the screen +vim.o.pumheight = 15 -- 15/70 is good enough ratio for me. I generally go with 80-90 max height, though +vim.o.pumblend = 10 -- semi-transparent for the art, nothing too useful (neovim recommends 0-30) + +-- `/` cmdline search. +cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) +-- `:` cmdline vim command. +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { + name = 'cmdline', + option = { + ignore_cmds = { 'Man', '!' } + } + } + }) +}) + -- nvim-cmp supports additional completion capabilities local capabilities = require('cmp_nvim_lsp').default_capabilities() -- local tabnine = require('cmp_tabnine.config') -- tabnine.setup({ --- max_lines = 1000, --- max_num_results = 20, --- sort = true, --- run_on_every_keystroke = true, --- snippet_placeholder = '..', --- ignored_file_types = {}, --- show_prediction_strength = true, +-- max_lines = 1000, +-- max_num_results = 20, +-- sort = true, +-- run_on_every_keystroke = true, +-- snippet_placeholder = '..', +-- ignored_file_types = {}, +-- show_prediction_strength = true, -- }) -- default language servers local servers = { - 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', - 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels", - "jsonls", "denols" + 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'lua_ls', 'cmake', 'tailwindcss', 'prismals', + 'nil_ls', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels", + "jsonls", "denols", "gopls", "nickel_ls", 'pylsp', } require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - }, - check_outdated_packages_on_open = true, + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" }, - -- The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration - -- Which means Mason's installed path is prioritized against our local install - -- see: https://git.pegasust.com/pegasust/aoc/commit/b45dc32c74d84c9f787ebce7a174c9aa1d411fc2 - -- This introduces some pitfalls, so we'll take the approach of trusting user's local installation - PATH = "append"; + check_outdated_packages_on_open = true, + }, + -- NOTE: The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration + -- Which means Mason's installed path is prioritized against our local install + -- see: https://git.pegasust.com/pegasust/aoc/commit/b45dc32c74d84c9f787ebce7a174c9aa1d411fc2 + -- This introduces some pitfalls, so we'll take the approach of trusting user's local installation + PATH = "append", }) require('mason-lspconfig').setup({ - ensure_installed = servers, - automatic_installation = true + -- ensure_installed = servers, + ensure_installed = { + "pylsp", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver", + "ansiblels", "yamlls", "docker_compose_language_service", "jsonls", + }, + automatic_installation = false, }) local inlay_hint_tsjs = { - includeInlayEnumMemberValueHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayFunctionParameterTypeHints = true, - includeInlayParameterNameHints = 'all', -- "none" | "literals" | "all" - inlcudeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayVariableTypeHints = true, + includeInlayEnumMemberValueHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayParameterNameHints = 'all', -- "none" | "literals" | "all" + inlcudeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayVariableTypeHints = true, }; require('mason-lspconfig').setup_handlers({ - -- default handler - function(server_name) - require('lspconfig')[server_name].setup { - on_attach = on_attach, - capabilities = capabilities, + -- default handler + function(server_name) + require('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, + } + end, + ["lua_ls"] = function() + require('lspconfig').lua_ls.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = vim.split(package.path, ";"), + }, + diagnostics = { + globals = { "vim" } + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + -- Don't prompt me to select + checkThirdParty = false, + }, + telemetry = { enable = false }, + hint = { + enable = true, + }, + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = 4, + }, + }, + }, + }, + } + end, + ["pyright"] = function() + require('lspconfig').pyright.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + pyright = { + disableLanguageServices = false, + disableOrganizeImports = false, + }, + python = { + analysis = { + autoImportCompletions = true, + autoSearchPaths = true, + diagnosticMode = "openFilesOnly", + -- diagnosticSeverityOverrides = + extraPaths = {}, + logLevel = "Information", + stubPath = "typings", + typeCheckingMode = "basic", + typeshedPaths = {}, + useLibraryCodeForTypes = false, + pythonPath = "python", + venvPath = "", + }, + linting = { + mypyEnabled = true, + } + }, + }, + } + end, + ["tsserver"] = function() + require('lspconfig').tsserver.setup { + on_attach = on_attach, + capabilities = capabilities, + -- TODO: Have to figure out an alternative config for monorepo to prevent + -- Deno from injecting TS projects. + -- Monorepo support: spawn one instance of lsp within the git + -- repos. + -- root_dir = require('lspconfig.util').root_pattern('.git'), + root_dir = require('lspconfig.util').root_pattern('package.json'), + settings = { + javascript = inlay_hint_tsjs, + typescript = inlay_hint_tsjs, + } + } + end, + ["denols"] = function() + require('lspconfig').denols.setup { + on_attach = on_attach, + capabilities = capabilities, + root_dir = require('lspconfig.util').root_pattern("deno.json", "deno.jsonc"), + } + end, + ["yamlls"] = function() + require('lspconfig').yamlls.setup { + on_attach = on_attach, + capabilities = capabilities, + settings = { + yaml = { + keyOrdering = false, } - end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - path = vim.split(package.path, ";"), - }, - diagnostics = { - globals = { "vim" } - }, - workspace = { - library = vim.api.nvim_get_runtime_file('', true) - }, - telemetry = { enable = false }, - hint = { enable = true, }, - format = { - enable = true, - defaultConfig = { - indent_style = "space", - indent_size = 4, - } - } - } - } - } - end, - ["tsserver"] = function() - require('lspconfig').tsserver.setup { - on_attach = on_attach, - capabilities = capabilities, - -- TODO: Have to figure out an alternative config for monorepo to prevent - -- Deno from injecting TS projects. - -- Monorepo support: spawn one instance of lsp within the git - -- repos. - -- root_dir = require('lspconfig.util').root_pattern('.git'), - root_dir = require('lspconfig.util').root_pattern('package.json'), - settings = { - javascript = inlay_hint_tsjs, - typescript = inlay_hint_tsjs, - } - } - end, - ["denols"] = function() - require('lspconfig').denols.setup { - on_attach = on_attach, - capabilities = capabilities, - root_dir = require('lspconfig.util').root_pattern("deno.json", "deno.jsonc"), - } - end, - -- ["rust_analyzer"] = function() - -- require('lspconfig').rust_analyzer.setup { - -- on_attach = on_attach, - -- capabilities = capabilities, - -- settings = { - -- checkOnSave = { - -- command = "clippy", - -- } - -- } - -- } - -- end, - -- ["astro"] = function() - -- print('configuring astro') - -- require('lspconfig').astro.setup { - -- on_attach = on_attach, - -- capabilities = capabilities, - -- init_options = { - -- configuration = {}, - -- typescript = { - -- serverPath = data_dir - -- } - -- } - -- } - -- end + }, + } + end, + ["nil_ls"] = function() + require('lspconfig').nil_ls.setup { + on_attach = on_attach, + capabilities = capabilities, + --- refer to https://github.com/oxalica/nil/blob/main/docs/configuration.md + --- for the list of configurations available for `nil_ls` + settings = { + ["nil"] = { + formatting = { + command = { "nix", "run", "nixpkgs#alejandra" }, + }, + nix = { + flake = { + -- calls `nix flake archive` to put a flake and its output to store + autoArchive = true, + -- auto eval flake inputs for improved completion + autoEvalInputs = true, + }, + }, + }, + }, + } + end, }) require("rust-tools").setup { - tools = { -- rust-tools options + tools = { + -- rust-tools options - -- how to execute terminal commands - -- options right now: termopen / quickfix - executor = require("rust-tools/executors").termopen, - - -- callback to execute once rust-analyzer is done initializing the workspace - -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" - on_initialized = function() - require('inlay-hints').set_all() - end, - - -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. - reload_workspace_from_cargo_toml = true, - - -- These apply to the default RustSetInlayHints command - inlay_hints = { - -- automatically set inlay hints (type hints) - -- default: true - auto = false, - - -- Only show inlay hints for the current line - only_current_line = false, - - -- whether to show parameter hints with the inlay hints or not - -- default: true - show_parameter_hints = true, - - -- prefix for parameter hints - -- default: "<-" - parameter_hints_prefix = "<- ", - - -- prefix for all the other hints (type, chaining) - -- default: "=>" - other_hints_prefix = "=> ", - - -- whether to align to the length of the longest line in the file - max_len_align = false, - - -- padding from the left if max_len_align is true - max_len_align_padding = 1, - - -- whether to align to the extreme right or not - right_align = false, - - -- padding from the right if right_align is true - right_align_padding = 7, - - -- The color of the hints - highlight = "Comment", - }, - - -- options same as lsp hover / vim.lsp.util.open_floating_preview() - hover_actions = { - - -- the border that is used for the hover window - -- see vim.api.nvim_open_win() - border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - }, - - -- whether the hover action window gets automatically focused - -- default: false - auto_focus = false, - }, - - -- settings for showing the crate graph based on graphviz and the dot - -- command - crate_graph = { - -- Backend used for displaying the graph - -- see: https://graphviz.org/docs/outputs/ - -- default: x11 - backend = "x11", - -- where to store the output, nil for no output stored (relative - -- path from pwd) - -- default: nil - output = nil, - -- true for all crates.io and external crates, false only the local - -- crates - -- default: true - full = true, - - -- List of backends found on: https://graphviz.org/docs/outputs/ - -- Is used for input validation and autocompletion - -- Last updated: 2021-08-26 - enabled_graphviz_backends = { - "bmp", - "cgimage", - "canon", - "dot", - "gv", - "xdot", - "xdot1.2", - "xdot1.4", - "eps", - "exr", - "fig", - "gd", - "gd2", - "gif", - "gtk", - "ico", - "cmap", - "ismap", - "imap", - "cmapx", - "imap_np", - "cmapx_np", - "jpg", - "jpeg", - "jpe", - "jp2", - "json", - "json0", - "dot_json", - "xdot_json", - "pdf", - "pic", - "pct", - "pict", - "plain", - "plain-ext", - "png", - "pov", - "ps", - "ps2", - "psd", - "sgi", - "svg", - "svgz", - "tga", - "tiff", - "tif", - "tk", - "vml", - "vmlz", - "wbmp", - "webp", - "xlib", - "x11", - }, - }, + -- how to execute terminal commands + -- options right now: termopen / quickfix + executor = require("rust-tools/executors").termopen, + -- callback to execute once rust-analyzer is done initializing the workspace + -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" + on_initialized = function() + require('inlay-hints').set_all() + end, + -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. + reload_workspace_from_cargo_toml = true, + -- These apply to the default RustSetInlayHints command + inlay_hints = { + -- automatically set inlay hints (type hints) + -- default: true + auto = false, + -- Only show inlay hints for the current line + only_current_line = true, + -- whether to show parameter hints with the inlay hints or not + -- default: true + show_parameter_hints = true, + -- prefix for parameter hints + -- default: "<-" + parameter_hints_prefix = "<- ", + -- prefix for all the other hints (type, chaining) + -- default: "=>" + other_hints_prefix = "=> ", + -- whether to align to the length of the longest line in the file + max_len_align = false, + -- padding from the left if max_len_align is true + max_len_align_padding = 1, + -- whether to align to the extreme right or not + right_align = false, + -- padding from the right if right_align is true + right_align_padding = 7, + -- The color of the hints use `:highlight` for a pick-and-choose menu + highlight = "NonText", }, - - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim - -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer - server = { - -- standalone file support - -- setting it to false may improve startup time - standalone = true, - on_attach = function(client, bufnr) - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) - end - on_attach(client, bufnr) - require('inlay-hints').on_attach(client, bufnr) - nmap('K', require 'rust-tools'.hover_actions.hover_actions, 'Hover Documentation') - - end, - capabilities = capabilities, - settings = { - checkOnSave = { - command = "clippy", - } - } - - }, -- rust-analyzer options - - -- debugging stuff - dap = { - adapter = { - type = "executable", - command = "lldb-vscode", - name = "rt_lldb", - }, + -- options same as lsp hover / vim.lsp.util.open_floating_preview() + hover_actions = { + -- the border that is used for the hover window + -- see vim.api.nvim_open_win() + border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + }, + -- whether the hover action window gets automatically focused + -- default: false + auto_focus = false, }, + -- settings for showing the crate graph based on graphviz and the dot + -- command + crate_graph = { + -- Backend used for displaying the graph + -- see: https://graphviz.org/docs/outputs/ + -- default: x11 + backend = "x11", + -- where to store the output, nil for no output stored (relative + -- path from pwd) + -- default: nil + output = nil, + -- true for all crates.io and external crates, false only the local + -- crates + -- default: true + full = true, + -- List of backends found on: https://graphviz.org/docs/outputs/ + -- Is used for input validation and autocompletion + -- Last updated: 2021-08-26 + enabled_graphviz_backends = { + "bmp", + "cgimage", + "canon", + "dot", + "gv", + "xdot", + "xdot1.2", + "xdot1.4", + "eps", + "exr", + "fig", + "gd", + "gd2", + "gif", + "gtk", + "ico", + "cmap", + "ismap", + "imap", + "cmapx", + "imap_np", + "cmapx_np", + "jpg", + "jpeg", + "jpe", + "jp2", + "json", + "json0", + "dot_json", + "xdot_json", + "pdf", + "pic", + "pct", + "pict", + "plain", + "plain-ext", + "png", + "pov", + "ps", + "ps2", + "psd", + "sgi", + "svg", + "svgz", + "tga", + "tiff", + "tif", + "tk", + "vml", + "vmlz", + "wbmp", + "webp", + "xlib", + "x11", + }, + }, + }, + + -- all the opts to send to nvim-lspconfig + -- these override the defaults set by rust-tools.nvim + -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer + server = { + -- standalone file support + -- setting it to false may improve startup time + standalone = true, + on_attach = function(client, bufnr) + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc }) + end + on_attach(client, bufnr) + nmap('K', require 'rust-tools'.hover_actions.hover_actions, 'Hover Documentation') + end, + capabilities = capabilities, + cmd = { "rust-analyzer" }, + settings = { + ["rust-analyzer"] = { + -- enable clippy on save + checkOnSave = { + command = "clippy", + extraArgs = { "--all", "--", "-W", "clippy::all" }, + }, + rustfmt = { + extraArgs = { "+nightly" }, + }, + cargo = { + loadOutDirsFromCheck = true, + }, + procMacro = { + enable = true, + }, + }, + }, + }, -- rust-analyzer options + + -- debugging stuff + dap = { + adapter = { + type = "executable", + command = "lldb-vscode", + name = "rt_lldb", + }, + }, } require('zk').setup({ - picker = "telescope", - lsp = { - config = { - cmd = { "zk", "lsp" }, - name = "zk", - on_attach = on_attach, - }, - auto_attach = { - enable = true, - filetypes = { "markdown" } - }, + picker = "telescope", + lsp = { + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, }, + auto_attach = { + enable = true, + filetypes = { "markdown" } + }, + }, }) -- Custom ZkOrphans that determines unlinked notes -- `:ZkOrphans {tags = {"work"}}` require('zk.commands').add("ZkOrphans", function(options) - options = vim.tbl_extend("force", { orphan = true }, options or {}) - -- zk.edit opens notes picker - require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) + options = vim.tbl_extend("force", { orphan = true }, options or {}) + -- zk.edit opens notes picker + require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" }) end) -- -- ZkGrep: opens file picker @@ -945,63 +1282,176 @@ end) -- Params: -- match_ctor: string | {match= :string,...} | "" | nil require('zk.commands').add("ZkGrep", function(match_ctor) - -- handle polymorphic `match_ctor` - local grep_str = match_ctor - local match - if match_ctor == nil or match_ctor == '' then - vim.fn.inputsave() - grep_str = vim.fn.input('Grep string: >') - vim.fn.inputrestore() - match = { match = grep_str } - elseif type(match_ctor) == 'string' then - match = { match = grep_str } - end - require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'", mutli_select = false }) + -- handle polymorphic `match_ctor` + local grep_str = match_ctor + local match + if match_ctor == nil or match_ctor == '' then + vim.fn.inputsave() + grep_str = vim.fn.input('Grep string: >') + match = { match = grep_str } + elseif type(match_ctor) == 'string' then + match = { match = grep_str } + end + require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'", mutli_select = false }) end) -- Gitsigns require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - } + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + } } require('lualine').setup { - options = { - icons_enabled = true, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { - { 'filename', - file_status = true, - newfile_status = false, - path = 1, - symbols = { - modified = '[+]', - readonly = '[-]', - unnamed = '[Unnamed]', - newfile = '[New]', - }, - }, + options = { + icons_enabled = true, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { + { + 'filename', + file_status = true, + newfile_status = false, + path = 1, + symbols = { + modified = '[+]', + readonly = '[-]', + unnamed = '[Unnamed]', + newfile = '[New]', }, - lualine_x = { 'encoding', 'fileformat', 'filetype', }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, + }, }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { 'filename', path = 1, file_status = true, }, }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {}, - } + lualine_x = { 'encoding', 'fileformat', 'filetype', }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { 'filename', path = 1, file_status = true, }, }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + } } require('nvim-surround').setup {} +require('fidget').setup({ + text = { + spinner = "moon", -- animation shown when tasks are ongoing + done = "✔", -- character shown when all tasks are complete + commenced = "Started", -- message shown when task starts + completed = "Completed", -- message shown when task completes + }, + align = { + bottom = true, -- align fidgets along bottom edge of buffer + right = true, -- align fidgets along right edge of buffer + }, + timer = { + spinner_rate = 125, -- frame rate of spinner animation, in ms + fidget_decay = 2000, -- how long to keep around empty fidget, in ms + task_decay = 1000, -- how long to keep around completed task, in ms + }, + window = { + relative = "editor", -- where to anchor, either "win" or "editor" + blend = 100, -- &winblend for the window + zindex = nil, -- the zindex value for the window + border = "none", -- style of border for the fidget window + }, + fmt = { + leftpad = true, -- right-justify text in fidget box + stack_upwards = true, -- list of tasks grows upwards + max_width = 0, -- maximum width of the fidget box + fidget = -- function to format fidget title + function(fidget_name, spinner) + return string.format("%s %s", spinner, fidget_name) + end, + task = -- function to format each task line + function(task_name, message, percentage) + return string.format( + "%s%s [%s]", + message, + percentage and string.format(" (%s%%)", percentage) or "", + task_name + ) + end, + }, + sources = { + -- Sources to configure + ['*'] = { -- Name of source + ignore = false, -- Ignore notifications from this source + }, + }, + debug = { + logging = false, -- whether to enable logging, for debugging + strict = false, -- whether to interpret LSP strictly + }, +}) + +-- Messaages as buf because it's so limiting to work with builtin view menu from neovim +vim.api.nvim_create_user_command('ShowLogs', function(opts) + local plugin_name = opts.fargs[1] or PLUGIN_URI + local min_level = opts.fargs[2] or PLUGIN_LEVEL + local logfile = string.format("%s/%s.log", vim.api.nvim_call_function("stdpath", { "cache" }), plugin_name) + + -- Ensure that the logfile exists + local file = io.open(logfile, 'r') + if not file then + print(string.format("No logfile found for plugin '%s'", vim.inspect(plugin_name))) + print("Attempted paths: %s", vim.inspect(logfile)) + return + end + file:close() + + vim.cmd('vnew ' .. logfile) + + -- Load messages from the log file + local file_messages = vim.fn.readfile(logfile) + local levels = { trace = 1, debug = 2, info = 3, warn = 4, error = 5, fatal = 6 } + local min_index = levels[min_level] or 3 + local filtered_messages = {} + for _, message in ipairs(file_messages) do + local level = message:match("^%[([a-z]+)") + if levels[level] and levels[level] >= min_index then + table.insert(filtered_messages, message) + end + end + + vim.api.nvim_buf_set_lines(0, 0, -1, false, filtered_messages) + vim.cmd('setlocal ft=log') + vim.cmd('setlocal nomodifiable') +end, { nargs = "*", }) + +require("colorizer").setup { + filetypes = { "*" }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = true, -- "Name" codes like Blue or blue + RRGGBBAA = true, -- #RRGGBBAA hex codes + AARRGGBB = true, -- 0xAARRGGBB hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = true, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = true, parsers = { "css" }, }, -- Enable sass colors + virtualtext = "■", + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, +} diff --git a/native_configs/ssh/config b/native_configs/ssh/config index a1b2f67..61c7ae2 100644 --- a/native_configs/ssh/config +++ b/native_configs/ssh/config @@ -1,6 +1,3 @@ -Host * - IdentityFile ~/.ssh/id_rsa - # felia mirror on windows Host felia-win HostName felia.coati-celsius.ts.net @@ -52,3 +49,94 @@ Host noami User htran Port 22 +Host sr1 + HostName 10.30.76.46 + User htran + Port 22 + StrictHostKeyChecking no + HostKeyAlgorithms=+ssh-dss,ssh-rsa + KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 + +Host bgp1 + HostName 10.111.100.113 + User htran + Port 22 + StrictHostKeyChecking no + HostKeyAlgorithms=+ssh-dss,ssh-rsa + KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 + +Host bgp2 + HostName 10.111.100.114 + User htran + Port 22 + StrictHostKeyChecking no + HostKeyAlgorithms=+ssh-dss,ssh-rsa + KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 +Host d1-30 + HostName 10.111.103.60 + User htran + Port 22 + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + IdentityFile ~/.ssh/id_ed25519 + IdentityFile ~/.ssh/id_rsa + +Host d3l-3 + HostName 10.111.103.65 + User htran + Port 22 + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + IdentityFile ~/.ssh/id_ed25519 + IdentityFile ~/.ssh/id_rsa + +Host dev0 + HostName 10.100.200.230 + User htran + Port 22 + +Host dev2 + HostName 10.100.200.210 + User htran + Port 22 + +Host dev1 + HostName 10.100.200.220 + User htran + Port 22 + + +Host ztp-egi + HostName 10.23.27.201 + User root + Port 22 + +Host goat + HostName 10.133.32.100 + User "EGN NOC" + Port 22 + +Host portal2 + HostName portal2.egihosting.com + User root + Port 22 + +Host egn-rest-api + HostName egn-rest-api.egihosting.com + User root + Port 22 + +Host gl-egi + HostName gitlab.egihosting.com + User git + Port 22 + IdentityFile ~/.ssh/id_ed25519 + +Host 10.111.103.* + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + +Host * + IdentityFile ~/.ssh/id_ed25519 + IdentityFile ~/.ssh/id_rsa + diff --git a/native_configs/starship/starship.toml b/native_configs/starship/starship.toml index 14eaf5c..3334c74 100644 --- a/native_configs/starship/starship.toml +++ b/native_configs/starship/starship.toml @@ -3,6 +3,11 @@ [aws] symbol = " " +[c] +disabled = false +# commands = [ [ 'cc', '--version' ], [ 'gcc', '--version' ], [ 'clang', '--version' ] ] +detect_extensions = ["c", "h", "cc", "cpp", "hh", "hpp"] + [conda] symbol = " " diff --git a/native_configs/tmux/tmux.conf b/native_configs/tmux/tmux.conf index f5e7187..0af00fb 100644 --- a/native_configs/tmux/tmux.conf +++ b/native_configs/tmux/tmux.conf @@ -14,7 +14,19 @@ setw -g pane-base-index 1 set-option -g renumber-windows on # status bar -set -g status-style 'bg=#333333 fg=#5eacd3' +# set -g status-style 'bg=#333333 fg=#5eacd3' +# set -g status-interval 60 +# set -g status-right-style 'bg=#333333 fg=#5eacd3' +# set -g status-right-length 50 +# set -g status-left " " # Keybinds +# Enter copy mode with 'v' in vi mode +bind-key -Tcopy-mode-vi v send-keys -X begin-selection + +# Copy selection with 'y' in vi mode +bind-key -Tcopy-mode-vi y send-keys -X copy-selection-and-cancel set-window-option -g mode-keys vi + +# # Log +# set-option -g history-file /tmp/.tmux.log diff --git a/nix-conf/home-manager/base/alacritty.nix b/nix-conf/home-manager/base/alacritty.nix index 5f08776..a05ed0d 100644 --- a/nix-conf/home-manager/base/alacritty.nix +++ b/nix-conf/home-manager/base/alacritty.nix @@ -1,53 +1,51 @@ -{ config -, proj_root -, myLib -, ... -}: -let +{ + config, + proj_root, + myLib, + ... +}: let inherit (myLib) fromYaml; actualConfig = fromYaml (builtins.readFile "${proj_root.config.path}//alacritty/alacritty.yml"); cfg = config.base.alacritty; -in -{ - options.base.alacritty = - { - font.family = myLib.mkOption { - type = myLib.types.singleLineStr; - default = actualConfig.font.normal.family; - description = '' - The font family for Alacritty - ''; - example = "DroidSansMono NF"; - }; - font.size = myLib.mkOption { - type = myLib.types.number; - default = actualConfig.font.size; - description = '' - The default font size for Alacritty. This is probably measured in px. - ''; - example = 7.0; - }; - enable = myLib.mkOption { - type = myLib.types.bool; - default = true; - description = '' - Enables alacritty - ''; - example = true; - }; - _actualConfig = myLib.mkOption { - type = myLib.types.attrs; - visible = false; - default = actualConfig; - description = "underlying default config"; - }; - additionalConfigPath = myLib.mkOption { - type = myLib.types.nullOr myLib.types.path; - visible = false; - default = null; - description = "impurely write our alacritty.yml to this path"; - }; +in { + options.base.alacritty = { + font.family = myLib.mkOption { + type = myLib.types.singleLineStr; + default = actualConfig.font.normal.family; + description = '' + The font family for Alacritty + ''; + example = "DroidSansMono NF"; }; + font.size = myLib.mkOption { + type = myLib.types.number; + default = actualConfig.font.size; + description = '' + The default font size for Alacritty. This is probably measured in px. + ''; + example = 7.0; + }; + enable = myLib.mkOption { + type = myLib.types.bool; + default = true; + description = '' + Enables alacritty + ''; + example = true; + }; + _actualConfig = myLib.mkOption { + type = myLib.types.attrs; + visible = false; + default = actualConfig; + description = "underlying default config"; + }; + additionalConfigPath = myLib.mkOption { + type = myLib.types.nullOr myLib.types.path; + visible = false; + default = null; + description = "impurely write our alacritty.yml to this path"; + }; + }; config.programs.alacritty = { enable = cfg.enable; diff --git a/nix-conf/home-manager/base/darwin-spotlight.nix b/nix-conf/home-manager/base/darwin-spotlight.nix new file mode 100644 index 0000000..6b9724a --- /dev/null +++ b/nix-conf/home-manager/base/darwin-spotlight.nix @@ -0,0 +1,54 @@ +{ + lib, + pkgs, + config, + ... +}: { + # This patch exists since Darwin's search bar requires solid apps and not + # symlinked + # TODO: QA + # - [x] works for base case + # - [x] works for repeated case + # - [ ] works after base case, then removed + # - [ ] works for repeated case, then removed + + # Copy GUI apps to "~/Applications/Home Manager Apps" + # Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334 + home.activation.patch-spotlight = + if pkgs.stdenv.isDarwin + then let + apps = pkgs.buildEnv { + name = "home-manager-applications"; + paths = config.home.packages; + pathsToLink = "/Applications"; + }; + in + lib.hm.dag.entryAfter ["linkGeneration"] '' + # Install MacOS applications to the user environment. + HM_APPS="$HOME/Applications/Home Manager Apps" + # Reset current state + if [ -e "$HM_APPS" ]; then + $DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)" + fi + $DRY_RUN_CMD mkdir -p "$HM_APPS" + # .app dirs need to be actual directories for Finder to detect them as Apps. + # In the env of Apps we build, the .apps are symlinks. We pass all of them as + # arguments to cp and make it dereference those using -H + $DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS" + $DRY_RUN_CMD chmod +w -R "$HM_APPS" + '' + else ""; + # We need this in case upstream home-manager changes the behavior of linking + # applications + home.activation.remove-patch-spotlight = + if pkgs.stdenv.isDarwin + then + lib.hm.dag.entryBefore ["checkLinkTargets"] '' + HM_APPS="$HOME/Applications/Home Manager Apps" + # Reset current state + if [ -e "$HM_APPS" ]; then + $DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)" + fi + '' + else ""; +} diff --git a/nix-conf/home-manager/base/default.nix b/nix-conf/home-manager/base/default.nix index d3a0d50..6cb88af 100644 --- a/nix-conf/home-manager/base/default.nix +++ b/nix-conf/home-manager/base/default.nix @@ -1,6 +1,4 @@ -{nix-index-database -,... -}@inputs:{ +{nix-index-database, ...} @ inputs: { mkModuleArgs = import ./mkModuleArgs.nix; modules = [ ./alacritty.nix diff --git a/nix-conf/home-manager/base/git.nix b/nix-conf/home-manager/base/git.nix index cd57aa7..a563fee 100644 --- a/nix-conf/home-manager/base/git.nix +++ b/nix-conf/home-manager/base/git.nix @@ -1,8 +1,8 @@ -{ config -, myLib -, ... -}: -let +{ + config, + myLib, + ... +}: let cfg = config.base.git; baseAliases = { a = "add"; @@ -15,12 +15,11 @@ let co = "checkout"; b = "branch"; }; -in -{ +in { options.base.git = { aliases = myLib.mkOption { type = myLib.types.attrs; - default = { }; + default = {}; example = baseAliases; description = '' Additional git aliases. This settings comes with base configuration. @@ -50,7 +49,7 @@ in .gitignore patterns that are applied in every repository. This is useful for IDE-specific settings. ''; - example = [ ".direnv" "node_modules" ]; + example = [".direnv" "node_modules"]; }; enable = myLib.mkOption { type = myLib.types.bool; diff --git a/nix-conf/home-manager/base/graphics.nix b/nix-conf/home-manager/base/graphics.nix index 646b720..2527fe9 100644 --- a/nix-conf/home-manager/base/graphics.nix +++ b/nix-conf/home-manager/base/graphics.nix @@ -1,11 +1,14 @@ -{ pkgs, config, lib, ... }: -let +{ + pkgs, + config, + lib, + ... +}: let cfg = config.base.graphics; cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null); types = lib.types; -in -{ - imports = [ ./shells.nix ]; +in { + imports = [./shells.nix]; options.base.graphics = { enable = lib.mkEnableOption "graphics"; _enable = lib.mkOption { @@ -23,14 +26,14 @@ in ]; }; defaultPackage = lib.mkOption { - type = types.nullOr (types.enum [ "nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee" ]); + type = types.nullOr (types.enum ["nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee"]); description = "Which nixGL package to be aliased as `nixGL` on the shell"; default = null; example = "nixGLIntel"; }; }; }; - # importing shells does not mean we're enabling everything, if we do mkDefault false + # NOTE: importing shells does not mean we're enabling everything, if we do mkDefault false # but the dilemma is, if the user import BOTH graphics.nix and shells.nix # they will also need to do `config.base.shells.enable` # generally, we want the behavior: import means enable @@ -41,6 +44,6 @@ in nixGL = cfg.useNixGL.defaultPackage; }; }; - home.packages = [ cfg.useNixGL.package ]; + home.packages = [cfg.useNixGL.package]; }; } diff --git a/nix-conf/home-manager/base/keepass.nix b/nix-conf/home-manager/base/keepass.nix index e985131..247adec 100644 --- a/nix-conf/home-manager/base/keepass.nix +++ b/nix-conf/home-manager/base/keepass.nix @@ -1,10 +1,14 @@ -{ config, proj_root, pkgs, lib, ... }: -let +{ + config, + proj_root, + pkgs, + lib, + ... +}: let cfg = config.base.keepass; trimNull = lib.filterAttrsRecursive (name: value: value != null); -in -{ - imports = [ ./graphics.nix ]; +in { + imports = [./graphics.nix]; options.base.keepass = { enable = lib.mkEnableOption "keepass"; use_gui = lib.mkOption { @@ -42,12 +46,18 @@ in }; }; config = lib.mkIf cfg.enable { - home.packages = [ - pkgs.kpcli-py # kp but is in cli - ] ++ (if cfg.use_gui or config.base.graphics._enable then [ - pkgs.keepass # Personal secret management - ] else [ ]); - home.file.".kp/config.ini".text = lib.generators.toINI { } (trimNull { + home.packages = + [ + pkgs.kpcli-py # kp but is in cli + ] + ++ ( + if cfg.use_gui or config.base.graphics._enable + then [ + pkgs.keepass # Personal secret management + ] + else [] + ); + home.file.".kp/config.ini".text = lib.generators.toINI {} (trimNull { default = { KEEPASSDB = cfg.path; KEEPASSDB_KEYFILE = cfg.keyfile_path; diff --git a/nix-conf/home-manager/base/mkModuleArgs.nix b/nix-conf/home-manager/base/mkModuleArgs.nix index 844e7c9..b5a0561 100644 --- a/nix-conf/home-manager/base/mkModuleArgs.nix +++ b/nix-conf/home-manager/base/mkModuleArgs.nix @@ -1,20 +1,20 @@ -# Turns given inputs into the standardized shape of the inputs to configure +# Turns given inputs into the standardized shape of the inputs to configure # custom base modules in this directory. -{ pkgs -, lib ? pkgs.lib -, ... -}@inputs: -let +{ + pkgs, + lib ? pkgs.lib, + ... +} @ inputs: let recursiveUpdate = lib.recursiveUpdate; - _lib = recursiveUpdate lib (import ../../lib { inherit pkgs lib; }); + _lib = recursiveUpdate lib (import ../../lib {inherit pkgs lib;}); proj_root = builtins.toString ./../../..; in -# TODO: Unpollute inputs -recursiveUpdate inputs { - proj_root = { - path = proj_root; - config.path = "${proj_root}/native_configs"; - scripts.path = "${proj_root}/scripts"; - }; - myLib = _lib; -} + # TODO: Unpollute inputs + recursiveUpdate inputs { + proj_root = { + path = proj_root; + config.path = "${proj_root}/native_configs"; + scripts.path = "${proj_root}/scripts"; + }; + myLib = _lib; + } diff --git a/nix-conf/home-manager/base/neovim.nix b/nix-conf/home-manager/base/neovim.nix index f9677cd..2083f16 100644 --- a/nix-conf/home-manager/base/neovim.nix +++ b/nix-conf/home-manager/base/neovim.nix @@ -1,81 +1,91 @@ -# TODO: vim-plug and Mason supports laziness. Probably worth it to explore -# incremental dependencies based on the project -# TODO: just install these things, then symlink to mason's bin directory +# TODO: vim-plug and Mason supports laziness. Probably worth it to explore incremental dependencies based on the project TODO: just install these things, then symlink to mason's bin directory # # One thing to consider, though, /nix/store of `nix-shell` or `nix-develop` -# might be different from `home-manager`'s -{ pkgs, lib, config, proj_root, ... }: -let - # NOTE: Failure 1: buildInputs is pretty much ignored - # my_neovim = pkgs.neovim-unwrapped.overrideDerivation (old: { - # # TODO: is there a more beautiful way to override propagatedBuildInputs? - # name = "hungtr-" + old.name; - # buildInputs = (old.buildInputs or []) ++ [ - # pkgs.tree-sitter # highlighting - # rust_pkgs # for potentially rust-analyzer - # pkgs.fzf - # pkgs.ripgrep - # pkgs.zk - # pkgs.fd - # ]; - # NOTE: Failure 2: propagatedBuildInputs probably only concerns dyn libs - # }); - # NOTE: Failure 3: must be unwrapped neovim because home-manager does the wrapping - # my_neovim = pkgs.neovim; - +# might be different from `home-manager`'s (~/.nix_profile/bin/jq) +{ + pkgs, + lib, + config, + proj_root, + ... +}: let # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace # and is added to the path after wrapping. # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` # see: :/--suffix.*PATH # there should be mentions of additional packages my_neovim = pkgs.neovim-unwrapped; - rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith + rust_pkgs = + pkgs.rust-bin.selectLatestNightlyWith ( toolchain: - toolchain.default.override { - extensions = [ "rust-src" ]; - } - )); - nvim_pkgs = [ - # pkgs.gccStdenv - pkgs.gcc - pkgs.tree-sitter - pkgs.fzf # file name fuzzy search - pkgs.ripgrep # content fuzzy search - pkgs.zk # Zettelkasten (limited support) - pkgs.fd # Required by a Telescope plugin (?) - pkgs.stdenv.cc.cc.lib - pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo - pkgs.rust4cargo + toolchain.default.override { + extensions = ["rust-src" "rust-analyzer" "rust-docs" "rustfmt" "clippy" "miri"]; + } + ); + nvim_pkgs = + [ + # pkgs.gccStdenv + pkgs.tree-sitter + pkgs.fzf # file name fuzzy search + pkgs.ripgrep # content fuzzy search + pkgs.zk # Zettelkasten (limited support) + pkgs.fd # Required by a Telescope plugin (?) + pkgs.stdenv.cc.cc.lib + pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo + pkgs.rust4cargo + pkgs.nickel + pkgs.nls + pkgs.go # doesn't work, Mason installs from runtime path - # Language-specific stuffs - pkgs.sumneko-lua-language-server - # pkgs.python3Packages.python-lsp-server - pkgs.nodePackages.pyright - pkgs.python3Packages.pylint - pkgs.python3Packages.flake8 - # pkgs.ansible-lint - pkgs.python38Packages.ansible - pkgs.ansible-language-server - # TODO: the devShell should provide rust-analyzer so that - # cargo test builds binaries compatible with rust-analyzer + # Language-specific stuffs + pkgs.sumneko-lua-language-server + # pkgs.python3Packages.python-lsp-server + pkgs.nodePackages.pyright + pkgs.python3Packages.pylint + pkgs.python3Packages.flake8 + # FIXME: installing ansible from here just doesn't work :/ + # pkgs.ansible-lint + # pkgs.python38Packages.ansible + # pkgs.ansible-language-server + # TODO: the devShell should provide rust-analyzer so that + # cargo test builds binaries compatible with rust-analyzer - # pkgs.rust-analyzer - # rust_pkgs - # pkgs.evcxr # Rust REPL for Conjure! - ]; -in -{ + # pkgs.rust-analyzer + # rust_pkgs + # pkgs.evcxr # Rust REPL for Conjure! + ] + ++ lib.optionals (pkgs.stdenv.isDarwin) ( + let + inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; + in [ + System + CoreFoundation + ] + ); +in { options.base.neovim = { enable = lib.mkOption { default = true; description = "enable personalized neovim as default editor"; type = lib.types.bool; example = false; + f = let + adder = { + __functor = self: arg: + if builtins.isInt arg + then self // {x = self.x + arg;} + else self.x; + x = 0; + }; + in { + what = adder 1 2 3 {}; + }; }; }; config = lib.mkIf config.base.neovim.enable { + # home-manager programs.neovim = { enable = true; package = my_neovim; @@ -83,23 +93,100 @@ in vimAlias = true; withPython3 = true; withNodeJs = true; - # Attempt 4: Correct way to make neovim aware of packages - # homeConfigurations.config.programs.neovim takes UNWRAPPED neovim - # and wraps it. - # Ideally, we build our own neovim and add that to config.home.packages - # to share it with nixOS. But we don't really need to share extraPackages = nvim_pkgs; - # only for here for archive-documentation - # extraPython3Packages = (pypkgs: [ - # # pypkgs.python-lsp-server - # pypkgs.ujson - # ]); - # I use vim-plug, so I probably don't require packaging - # extraConfig actually writes to init-home-manager.vim (not lua) - # https://github.com/nix-community/home-manager/pull/3287 - # extraConfig = builtins.readFile "${proj_root}/neovim/init.lua"; + extraLuaConfig = builtins.readFile "${proj_root.config.path}//neovim/init.lua"; + plugins = let + inherit + (pkgs.vimPlugins) + plenary-nvim + nvim-treesitter + nvim-treesitter-textobjects + nvim-treesitter-context + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + nvim-lspconfig + gruvbox-community + neodev-nvim + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + fidget-nvim + rust-tools-nvim + cmp_luasnip + gitsigns-nvim + indent-blankline-nvim + lualine-nvim + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + ; + in [ + plenary-nvim + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + nvim-lspconfig + gruvbox-community + neodev-nvim + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + nvim-treesitter-context + fidget-nvim + rust-tools-nvim + + cmp_luasnip + gitsigns-nvim + indent-blankline-nvim + lualine-nvim + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + ]; }; # home.packages = nvim_pkgs; - xdg.configFile."nvim/init.lua".source = "${proj_root.config.path}//neovim/init.lua"; }; } diff --git a/nix-conf/home-manager/base/private_chromium.nix b/nix-conf/home-manager/base/private_chromium.nix index 5cb7204..9213ba0 100644 --- a/nix-conf/home-manager/base/private_chromium.nix +++ b/nix-conf/home-manager/base/private_chromium.nix @@ -1,9 +1,13 @@ # TODO: maybe throw if base.graphics is not enabled? # Though, headless chromium might be possible -{ config, pkgs, lib, ... }: -let cfg = config.base.private_chromium; -in { + config, + pkgs, + lib, + ... +}: let + cfg = config.base.private_chromium; +in { options.base.private_chromium = { enable = lib.mkOption { type = lib.types.bool; @@ -14,37 +18,41 @@ in ''; }; }; - config = lib.mkIf cfg.enable { + config = lib.mkIf (cfg.enable) { # home.packages = [pkgs.ungoogled-chromium]; programs.chromium = { enable = true; package = pkgs.ungoogled-chromium; - extensions = - let - mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }: - { - inherit id; - crxPath = builtins.fetchurl { - url = "https://clients2.google.com/service/update2/crx" + - "?response=redirect" + - "&acceptformat=crx2,crx3" + - "&prodversion=${browserVersion}" + - "&x=id%3D${id}%26installsource%3Dondemand%26uc"; - name = "${id}.crx"; - inherit sha256; - }; - version = extVersion; - }; - mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version); - in - [ - # vimium - (mkChromiumExt { - id = "dbepggeogbaibhgnhhndojpepiihcmeb"; - sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic"; - extVersion = "1.67.4"; - }) - ]; + extensions = let + # TODO: how about a chrome extension registry? + mkChromiumExtForVersion = browserVersion: { + id, + sha256, + extVersion, + ... + }: { + inherit id; + crxPath = builtins.fetchurl { + url = + "https://clients2.google.com/service/update2/crx" + + "?response=redirect" + + "&acceptformat=crx2,crx3" + + "&prodversion=${browserVersion}" + + "&x=id%3D${id}%26installsource%3Dondemand%26uc"; + name = "${id}.crx"; + inherit sha256; + }; + version = extVersion; + }; + mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version); + in [ + # vimium + (mkChromiumExt { + id = "dbepggeogbaibhgnhhndojpepiihcmeb"; + sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic"; + extVersion = "1.67.4"; + }) + ]; }; }; } diff --git a/nix-conf/home-manager/base/productive_desktop.nix b/nix-conf/home-manager/base/productive_desktop.nix index 944fbff..3227406 100644 --- a/nix-conf/home-manager/base/productive_desktop.nix +++ b/nix-conf/home-manager/base/productive_desktop.nix @@ -1,9 +1,9 @@ # A module that takes care of a GUI-ful, productive desktop environment -inputs@{ pkgs, ... }: { +inputs @ {pkgs, ...}: { imports = [ # slack - ({ pkgs, ... }: { - home.packages = [ + ({pkgs, ...}: { + home.packages = [ pkgs.slack ]; }) diff --git a/nix-conf/home-manager/base/shells.nix b/nix-conf/home-manager/base/shells.nix index 6c278ee..e5bd1f1 100644 --- a/nix-conf/home-manager/base/shells.nix +++ b/nix-conf/home-manager/base/shells.nix @@ -1,14 +1,14 @@ # Configurations for shell stuffs. -# Should probably be decoupled even more -{ config -, proj_root -, myLib -, pkgs -, ... -}: -let cfg = config.base.shells; -in +# Should probably be decoupled even more for each feature { + config, + proj_root, + myLib, + pkgs, + ... +}: let + cfg = config.base.shells; +in { options.base.shells = { enable = myLib.mkOption { type = myLib.types.bool; @@ -30,14 +30,13 @@ in shellAliases = myLib.mkOption { type = myLib.types.attrs; description = "Shell command aliases"; - default = { }; + default = {}; example = { nixGL = "nixGLIntel"; }; }; }; config = myLib.mkIf cfg.enable { - xdg.configFile."starship.toml".source = "${proj_root.config.path}//starship/starship.toml"; # nix: Propagates the environment with packages and vars when enter (children of) # a directory with shell.nix-compatible and .envrc programs.direnv = { @@ -52,16 +51,37 @@ in }; programs.tmux = { enable = true; + # extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf"; + plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed]; extraConfig = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf"; }; + xdg.configFile."tmux/tmux.conf".text = myLib.mkOrder 600 '' + set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M ' + ''; + # Colored ls programs.exa = { enable = true; enableAliases = true; }; + # Make the shell look beautiful programs.starship = { enable = true; enableZshIntegration = true; + settings = let + native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml"); + patch-nix = pkgs.lib.recursiveUpdate native { + # WARNING: home-manager fails on here for some reason. Likely not at the + # validation phase (type-checking), but at evaluation phaase (stringify) + # c.commands = [ + # ["nix" "run" "nixpkgs#clang" "--" "--version"] + # ["nix" "run" "nixpkgs#gcc" "--" "--version"] + # ]; + c.commands = "fuk"; + }; + in + patch-nix; }; + # Fuzzy finder. `fzf` for TUI, `fzf -f ''` for UNIX piping programs.fzf.enable = true; programs.bash = { enable = true; @@ -72,10 +92,12 @@ in enable = true; enableCompletion = true; enableAutosuggestions = true; - shellAliases = { - nix-rebuild = "sudo nixos-rebuild switch"; - hm-switch = "home-manager switch --flake"; - } // (cfg.shellAliases or { }); + shellAliases = + { + nix-rebuild = "sudo nixos-rebuild switch"; + hm-switch = "home-manager switch --flake"; + } + // (cfg.shellAliases or {}); history = { size = 10000; path = "${config.xdg.dataHome}/zsh/history"; @@ -89,10 +111,13 @@ in "gitignore" # `gi list` -> `gi java >>.gitignore` "ripgrep" # adds completion for `rg` "rust" # compe for rustc/cargo + "poetry" # compe for poetry - Python's cargo # "vi-mode" # edit promps with vi motions :) ]; }; sessionVariables = { + # Vim mode on the terminal + # VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true; # VI_MODE_SET_CURSOR = true; # ZVM_VI_ESCAPE_BINDKEY = ""; @@ -100,10 +125,11 @@ in ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) }; - initExtra = (cfg.shellInitExtra or "") + '' - source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh - ''; - + initExtra = + (cfg.shellInitExtra or "") + + '' + source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh + ''; }; }; } diff --git a/nix-conf/home-manager/base/ssh.nix b/nix-conf/home-manager/base/ssh.nix index dd02bdf..b14912a 100644 --- a/nix-conf/home-manager/base/ssh.nix +++ b/nix-conf/home-manager/base/ssh.nix @@ -1,11 +1,11 @@ -{ config -, proj_root -, myLib -, ... -}: -let cfg = config.base.ssh; -in { + config, + proj_root, + myLib, + ... +}: let + cfg = config.base.ssh; +in { options.base.ssh.enable = myLib.mkOption { type = myLib.types.bool; default = true; @@ -17,7 +17,6 @@ in config.programs.ssh = { inherit (cfg) enable; forwardAgent = true; - extraConfig = builtins.readFile "${proj_root.config.path}/ssh/config"; + includes = ["${proj_root.config.path}/ssh/config"]; }; } - diff --git a/nix-conf/home-manager/default.nix b/nix-conf/home-manager/default.nix index 0a33c79..c7b1026 100644 --- a/nix-conf/home-manager/default.nix +++ b/nix-conf/home-manager/default.nix @@ -1,11 +1,13 @@ # We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix -(import +( + import ( - let + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - c_ = import ./../../c_.nix {src = ./.;}; + c_ = import ./../../c_.nix; in - c_.fetchTree lock.nodes.flake-compat.locked + c_.fetchTree lock.nodes.flake-compat.locked ) - { src = ./.; } -).defaultNix + {src = ./.;} +) +.defaultNix diff --git a/nix-conf/home-manager/flake.lock b/nix-conf/home-manager/flake.lock index 42737ea..b2bb132 100644 --- a/nix-conf/home-manager/flake.lock +++ b/nix-conf/home-manager/flake.lock @@ -1,5 +1,156 @@ { "nodes": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "cargo-leptos": { + "flake": false, + "locked": { + "lastModified": 1682155645, + "narHash": "sha256-Hya0qk1f0AYhGXwj6C20HVlh/iQnHBjx89ER6fuWdYw=", + "owner": "leptos-rs", + "repo": "cargo-leptos", + "rev": "d49b5883a97a23eff4ab84d76916a8f67da81a76", + "type": "github" + }, + "original": { + "owner": "leptos-rs", + "repo": "cargo-leptos", + "type": "github" + } + }, + "crane": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1681680516, + "narHash": "sha256-EB8Adaeg4zgcYDJn9sR6UMjN/OHdIiMMK19+3LmmXQY=", + "owner": "ipetkov", + "repo": "crane", + "rev": "54b63c8eae4c50172cb50b612946ff1d2bc1c75c", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { + "inputs": { + "flake-compat": "flake-compat_6", + "flake-utils": "flake-utils_8", + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_3" + }, + "locked": { + "lastModified": 1676162383, + "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678957337, + "narHash": "sha256-Gw4nVbuKRdTwPngeOZQOzH/IFowmz4LryMPDiJN/ah4=", + "owner": "numtide", + "repo": "devshell", + "rev": "3e0e60ab37cd0bf7ab59888f5c32499d851edb47", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "nixlib": [ + "nix-boost", + "std", + "nixpkgs" + ], + "yants": [ + "nix-boost", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1659548052, + "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", + "owner": "divnix", + "repo": "data-merge", + "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "data-merge", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs_8", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1677306201, + "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0923f0c162f65ae40261ec940406049726cfeab4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -16,11 +167,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -29,13 +180,159 @@ "type": "github" } }, - "flake-utils": { + "flake-compat_3": { + "flake": false, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_6": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1680392223, + "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_10": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -61,11 +358,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -75,6 +372,57 @@ } }, "flake-utils_4": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_6": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_7": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -89,35 +437,185 @@ "type": "github" } }, - "home-manager": { + "flake-utils_8": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_9": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { "inputs": { "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "pre-commit-hooks-nix", "nixpkgs" - ], + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gnmic": { + "flake": false, + "locked": { + "lastModified": 1681861366, + "narHash": "sha256-lM5Tz2JafXh2zi643mOM53DO756ixc2khiTt/csw9og=", + "owner": "openconfig", + "repo": "gnmic", + "rev": "7c51956133dd4d855818660649640396949f0341", + "type": "github" + }, + "original": { + "owner": "openconfig", + "repo": "gnmic", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "nixpkgs": "nixpkgs_4", "utils": "utils" }, "locked": { - "lastModified": 1673948101, - "narHash": "sha256-cD0OzFfnLFeeaz4jVszH9QiMTn+PBxmcYzrp+xujpwM=", + "lastModified": 1677459247, + "narHash": "sha256-JbakfAiPYmCCV224yAMq/XO0udN5coWv/oazblMKdoY=", "owner": "nix-community", - "repo": "home-manager", - "rev": "bd3efacb82c721edad1ce9eda583df5fb62ab00a", + "repo": "gomod2nix", + "rev": "3cbf3a51fe32e2f57af4c52744e7228bab22983d", "type": "github" }, "original": { "owner": "nix-community", - "repo": "home-manager", + "repo": "gomod2nix", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1678138103, + "narHash": "sha256-D0lao82bV3t2gEFjHiU6RN233t+1MnkQV+bq8MEu2ic=", + "owner": "hercules-ci", + "repo": "haskell-flake", + "rev": "1e1660e6dd00838ba73bc7952e6e73be67da18d1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "ref": "0.1-extraLibraries", + "repo": "haskell-flake", + "type": "github" + } + }, + "hercules-ci-agent": { + "inputs": { + "flake-parts": "flake-parts_3", + "haskell-flake": "haskell-flake", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs", + "pre-commit-hooks-nix": "pre-commit-hooks-nix" + }, + "locked": { + "lastModified": 1678446614, + "narHash": "sha256-Z6Gsba5ahn/N0QlF0vJfIEfnZgCs4qr1IZtXAqjbE7s=", + "owner": "hercules-ci", + "repo": "hercules-ci-agent", + "rev": "0b90d1a87c117a5861785cb85833dd1c9df0b6ef", + "type": "github" + }, + "original": { + "id": "hercules-ci-agent", + "type": "indirect" + } + }, + "hercules-ci-effects": { + "inputs": { + "flake-parts": "flake-parts_2", + "hercules-ci-agent": "hercules-ci-agent", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1681898675, + "narHash": "sha256-nIJ7CAdiHv4i1no/VgDoeTJLzbLYwu5+/Ycoyzn0S78=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "15ff4f63e5f28070391a5b09a82f6d5c6cc5c9d0", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", "type": "github" } }, "kpcli-py": { "flake": false, "locked": { - "lastModified": 1619087457, - "narHash": "sha256-iRNLq5s2WJJHwB4beP5xQDKrBPWS/42s/ozLoSa5gAE=", + "lastModified": 1679142558, + "narHash": "sha256-l18PBzf/P7d3BPcFb5gSDX863MsC7S747qooyg0u2lA=", "owner": "rebkwok", "repo": "kpcli", - "rev": "e4d699e3b3d28887f74185f8fa69d0aade111d84", + "rev": "1c64e7274345d28ebc2607e22211a4ee9f6dbe7f", "type": "github" }, "original": { @@ -126,9 +624,36 @@ "type": "github" } }, + "n2c": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677330646, + "narHash": "sha256-hUYCwJneMjnxTvj30Fjow6UMJUITqHlpUGpXMPXUJsU=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "ebca8f58d450cae1a19c07701a5a8ae40afc9efc", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, "neovim-flake": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" @@ -136,11 +661,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1673937267, - "narHash": "sha256-zixnItZtMZRKK0bEh8UOBeh8JT4jeMzPR2TtacfXmyE=", + "lastModified": 1682581904, + "narHash": "sha256-9P4T2erXXrPxXTTLgD29U/IdKCOYqP4xbwdYswtVBA8=", "owner": "neovim", "repo": "neovim", - "rev": "2093e574c6c934a718f96d0a173aa965d3958a8b", + "rev": "d321deb4a9b05e9d81b79ac166274f4a6e7981bf", "type": "github" }, "original": { @@ -153,20 +678,72 @@ "neovim-nightly-overlay": { "inputs": { "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts", + "hercules-ci-effects": "hercules-ci-effects", "neovim-flake": "neovim-flake", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1673943288, - "narHash": "sha256-TDo9wDfZH+MJ/tTeCtZ67jdHqtVvIxetLpFN9+vqZ7g=", + "lastModified": 1684067841, + "narHash": "sha256-UzOHzcx5KrysKdLZuyU2k5RipVa6wP8EbVeqF/C7OLM=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "3c0bb335936754a2683a84ddf081594ddb567a89", + "rev": "88a6c749a7d126c49f3374f9f28ca452ea9419b8", "type": "github" }, "original": { "owner": "nix-community", "repo": "neovim-nightly-overlay", + "rev": "88a6c749a7d126c49f3374f9f28ca452ea9419b8", + "type": "github" + } + }, + "nix-boost": { + "inputs": { + "cargo-leptos": "cargo-leptos", + "crane": "crane", + "flake-compat": "flake-compat_5", + "gnmic": "gnmic", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_5", + "poetry2nix": "poetry2nix", + "rust-overlay": "rust-overlay_2", + "std": "std" + }, + "locked": { + "lastModified": 1682634888, + "narHash": "sha256-gyQr0FPWMh/I7fvGqsC3xtWQV5rfms2O97le4HzrgdU=", + "ref": "refs/heads/master", + "rev": "f4c97b6948a9292bf36ffe3514285fbe464e6613", + "revCount": 65, + "type": "git", + "url": "https://git.pegasust.com/pegasust/nix-boost.git" + }, + "original": { + "type": "git", + "url": "https://git.pegasust.com/pegasust/nix-boost.git" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673295039, + "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", "type": "github" } }, @@ -177,11 +754,11 @@ ] }, "locked": { - "lastModified": 1673752441, - "narHash": "sha256-/g4ImZWV05CrXRWTSJsda6ztIp7LAPxs2L6RCrbQ66U=", + "lastModified": 1686740472, + "narHash": "sha256-b668DY2qGdBCUwIkk6Z32bcpCsUISQJrEEvhtn1gGgY=", "owner": "mic92", "repo": "nix-index-database", - "rev": "391180f77505c1c8cdd45fe1a59dc89d3e40300a", + "rev": "e11c61073b777e025993c5ef63ddbf776a9cca15", "type": "github" }, "original": { @@ -190,14 +767,46 @@ "type": "github" } }, + "nixago": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "flake-utils" + ], + "nixago-exts": [ + "nix-boost", + "std", + "blank" + ], + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1682297764, + "narHash": "sha256-KcE95ua4IA+nwpaP53Se0x1TZxR538fGGEm8edaLuzU=", + "owner": "nix-community", + "repo": "nixago", + "rev": "d68634526733c79a2ca4fcc87c25a1ceabf132f4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, "nixgl": { "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_2" + "flake-utils": "flake-utils_9", + "nixpkgs": "nixpkgs_9" }, "locked": { "lastModified": 1, - "narHash": "sha256-RkO+8E7MahERHw1C5DNObDjq4xeI+FqaWH9+M7Fv2UE=", + "narHash": "sha256-1Vtx9qxakFbFcKO96LJKbNotI3hN8DpePSfwPfDN9x0=", "path": "./../../out-of-tree/nixGL", "type": "path" }, @@ -208,11 +817,188 @@ }, "nixpkgs": { "locked": { - "lastModified": 1671983799, - "narHash": "sha256-Z2Ro6hFPZHkBqkVXY5/aBUzxi5xizQGvuHQ9+T5B/ks=", + "lastModified": 1678293141, + "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-latest": { + "locked": { + "lastModified": 1687044368, + "narHash": "sha256-7eBtV3lgfgjeyBDa20Xr4O9mlcAHHFYpvo6m16tgLcY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "fad51abd42ca17a60fc1d4cb9382e2d79ae31836", + "rev": "b621273236ab985db5ff7e91171624f2e07e82a1", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1673800717, + "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_10": { + "locked": { + "lastModified": 1686960236, + "narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1683968890, + "narHash": "sha256-FuNtjMvT07cJydY5NRyRhIni/dEwkSkijmFEdsmqdkA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea11a3977f4cba013d8680667616be827c967ac0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1680487167, + "narHash": "sha256-9FNIqrxDZgSliGGN2XJJSvcDYmQbgOANaZA4UWnTdg4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "53dad94e874c9586e71decf82d972dfb640ef044", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1658285632, + "narHash": "sha256-zRS5S/hoeDGUbO+L95wXG9vJNwsSYcl93XiD0HQBXLk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5342fc6fb59d0595d26883c3cadff16ce58e44f3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1682526928, + "narHash": "sha256-2cKh4O6t1rQ8Ok+v16URynmb0rV7oZPEbXkU0owNLQs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d6b863fd9b7bb962e6f9fdf292419a775e772891", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1675940568, + "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", "type": "github" }, "original": { @@ -222,7 +1008,23 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_8": { + "locked": { + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_9": { "locked": { "lastModified": 1660551188, "narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=", @@ -237,35 +1039,174 @@ "type": "github" } }, - "nixpkgs_3": { + "nosys": { "locked": { - "lastModified": 1673796341, - "narHash": "sha256-1kZi9OkukpNmOaPY7S5/+SlCDOuYnP3HkXHvNDyLQcc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "6dccdc458512abce8d19f74195bb20fdb067df50", + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "owner": "divnix", + "repo": "nosys", "type": "github" } }, - "nixpkgs_4": { + "paisano": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ], + "nosys": "nosys", + "yants": [ + "nix-boost", + "std", + "yants" + ] + }, "locked": { - "lastModified": 1665296151, - "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "lastModified": 1678949904, + "narHash": "sha256-oAoF66hYYz1RPh3lEwb9/4e4iyBAfTbQKZRRQ8gP0Ds=", + "owner": "paisano-nix", + "repo": "core", + "rev": "88f2aff10a5064551d1d4cb86800d17084489ce3", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", + "owner": "paisano-nix", + "repo": "core", + "type": "github" + } + }, + "paisano-actions": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677306424, + "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=", + "owner": "paisano-nix", + "repo": "actions", + "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "actions", + "type": "github" + } + }, + "paisano-mdbook-preprocessor": { + "inputs": { + "crane": "crane_2", + "fenix": "fenix", + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ], + "paisano-actions": "paisano-actions", + "std": [ + "nix-boost", + "std" + ] + }, + "locked": { + "lastModified": 1680654400, + "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=", + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "type": "github" + } + }, + "paisano-tui": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "blank" + ], + "std": [ + "nix-boost", + "std" + ] + }, + "locked": { + "lastModified": 1681847764, + "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=", + "owner": "paisano-nix", + "repo": "tui", + "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "tui", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": [ + "nix-boost", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1682555464, + "narHash": "sha256-FdkKWqzKbXmX/tInaNod2S6+yGyLMM1xUdYflmx/jgs=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "863f574729fd26c98ae521ffddd30339041fc51f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "hercules-ci-agent", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1678376203, + "narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "1a20b9708962096ec2481eeb2ddca29ed747770a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", "type": "github" } }, @@ -273,26 +1214,55 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "home-manager": "home-manager", + "home-manager": [ + "nixpkgs" + ], "kpcli-py": "kpcli-py", "neovim-nightly-overlay": "neovim-nightly-overlay", + "nix-boost": "nix-boost", "nix-index-database": "nix-index-database", "nixgl": "nixgl", - "nixpkgs": "nixpkgs_3", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs_10", + "nixpkgs-latest": "nixpkgs-latest", + "rust-overlay": "rust-overlay_4" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1677221702, + "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_4" + "flake-utils": [ + "nix-boost", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "crane", + "nixpkgs" + ] }, "locked": { - "lastModified": 1673922364, - "narHash": "sha256-U0XIY/Y/x4fFtlCZKMtWlqOYUnLiXj4F42GQHxWuPow=", + "lastModified": 1680488274, + "narHash": "sha256-0vYMrZDdokVmPQQXtFpnqA2wEgCCUXf5a3dDuDVshn0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "4e0f9b8a5102387f8d19901bced16a256a6ccdc7", + "rev": "7ec2ff598a172c6e8584457167575b3a1a5d80d8", "type": "github" }, "original": { @@ -301,13 +1271,186 @@ "type": "github" } }, + "rust-overlay_2": { + "inputs": { + "flake-utils": "flake-utils_6", + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1682561982, + "narHash": "sha256-x0LtoiGT9gQ7Sn8SvjV3CIUqGu/GLDBDAoa5lXyef/8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "cc85c38ed6f7ecb9d7eb3d71be3c6f01b87e92f9", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { + "inputs": { + "flake-utils": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "nix-boost", + "std", + "paisano-mdbook-preprocessor", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_4": { + "inputs": { + "flake-utils": "flake-utils_10", + "nixpkgs": "nixpkgs_11" + }, + "locked": { + "lastModified": 1686968542, + "narHash": "sha256-Gjlj7UeHqMFRAYyefeoLnSjLo8V+0XheIamojNEyTbE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "01d84cd842e48e89be67e4c2d9dc46aa7709adc5", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "std": { + "inputs": { + "arion": [ + "nix-boost", + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils_7", + "incl": "incl", + "makes": [ + "nix-boost", + "std", + "blank" + ], + "microvm": [ + "nix-boost", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": "nixpkgs_7", + "paisano": "paisano", + "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor", + "paisano-tui": "paisano-tui", + "yants": "yants" + }, + "locked": { + "lastModified": 1682297963, + "narHash": "sha256-lB89W0c4/gqArk2g7bOhsDHMgYz29E+yaYyCK35D9A4=", + "owner": "divnix", + "repo": "std", + "rev": "a0f9dd33cff37e2c532e2c236d011e2ecd77286d", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", "type": "github" }, "original": { @@ -315,6 +1458,28 @@ "repo": "flake-utils", "type": "github" } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "nix-boost", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667096281, + "narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=", + "owner": "divnix", + "repo": "yants", + "rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } } }, "root": "root", diff --git a/nix-conf/home-manager/flake.nix b/nix-conf/home-manager/flake.nix index 3b3abda..499f6a8 100644 --- a/nix-conf/home-manager/flake.nix +++ b/nix-conf/home-manager/flake.nix @@ -10,13 +10,16 @@ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; + max-jobs = 12; }; description = "simple home-manager config"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-latest.url = "github:nixos/nixpkgs"; home-manager = { url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; + # url = "github:pegasust/home-manager/starship-config-type"; + follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; nixgl.url = "path:./../../out-of-tree/nixGL"; @@ -26,14 +29,13 @@ url = "path:../../out-of-tree/flake-compat"; flake = false; }; + nix-boost.url = "git+https://git.pegasust.com/pegasust/nix-boost.git"; kpcli-py = { url = "github:rebkwok/kpcli"; flake = false; }; neovim-nightly-overlay = { - url = "github:nix-community/neovim-nightly-overlay"; - # Pin to a nixpkgs revision that doesn't have NixOS/nixpkgs#208103 yet - inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836"; + url = "github:nix-community/neovim-nightly-overlay?rev=88a6c749a7d126c49f3374f9f28ca452ea9419b8"; }; nix-index-database = { url = "github:mic92/nix-index-database"; @@ -41,81 +43,88 @@ }; }; - outputs = - flake_inputs@{ nixpkgs - , home-manager - , nixgl - , rust-overlay - , flake-utils - , kpcli-py - , neovim-nightly-overlay - , ... - }: - let - # config_fn:: system -> config - cross_platform = config_fn: ({ - packages = builtins.foldl' - (prev: system: prev // { + outputs = flake_inputs @ { + nixpkgs, + home-manager, + nixgl, + rust-overlay, + flake-utils, + kpcli-py, + neovim-nightly-overlay, + nix-boost, + nixpkgs-latest, + ... + }: let + # config_fn:: system -> config + cross_platform = config_fn: { + packages = + builtins.foldl' + (prev: system: + prev + // { "${system}" = config_fn system; }) - { } - flake-utils.lib.defaultSystems; - }); - in - cross_platform (system: - let - overlays = import ./../../overlays.nix (flake_inputs // {inherit system;}); + {} + flake-utils.lib.defaultSystems; + }; + in + cross_platform (system: let + overlays = import ./overlays.nix (flake_inputs // {inherit system;}); # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; pkgs = import nixpkgs { inherit system overlays; - config = { allowUnfree = true; }; + config = {allowUnfree = true;}; }; # lib = (import ../lib { inherit pkgs; lib = pkgs.lib; }); base = import ./base flake_inputs; inherit (base) mkModuleArgs; - nerd_font_module = { config, pkgs, ... }: { + nerd_font_module = { + config, + pkgs, + ... + }: { fonts.fontconfig.enable = true; home.packages = [ - (pkgs.nerdfonts.override { fonts = [ "DroidSansMono" ]; }) + # list of fonts are available at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix + (pkgs.nerdfonts.override {fonts = ["Hack"];}) ]; - # For some reasons, Windows es in the font name as DroidSansMono NF - # so we need to override this - base.alacritty.font.family = "DroidSansMono Nerd Font"; + base.alacritty.font.family = "Hack Nerd Font Mono"; }; - in - { + in { debug = { inherit overlays pkgs base; }; - homeConfigurations = - let - x11_wsl = '' - # x11 output for WSL - export DISPLAY=$(ip route list default | awk '{print $3}'):0 - export LIBGL_ALWAYS_INDIRECT=1 - ''; - in - { - "hungtr" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = base.modules ++ [ + homeConfigurations = let + x11_wsl = '' + # x11 output for WSL + export DISPLAY=$(ip route list default | awk '{print $3}'):0 + export LIBGL_ALWAYS_INDIRECT=1 + ''; + in { + "hungtr" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = + base.modules + ++ [ ./home.nix ]; - # optionally pass inarguments to module - # we migrate this from in-place modules to allow flexibility - # in this case, we can add "home" to input arglist of home.nix - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "hungtr"; - homeDirectory = "/home/hungtr"; - }; + # optionally pass inarguments to module + # we migrate this from in-place modules to allow flexibility + # in this case, we can add "home" to input arglist of home.nix + extraSpecialArgs = mkModuleArgs { + inherit pkgs; + myHome = { + username = "hungtr"; + homeDirectory = "/home/hungtr"; }; }; - "hungtr@bao" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = base.modules ++ [ + }; + "hungtr@bao" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = + base.modules + ++ [ ./home.nix nerd_font_module ./base/productive_desktop.nix @@ -128,21 +137,23 @@ base.graphics.useNixGL.enable = true; } ]; - # optionally pass inarguments to module - # we migrate this from in-place modules to allow flexibility - # in this case, we can add "home" to input arglist of home.nix - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "hungtr"; - homeDirectory = "/home/hungtr"; - }; + # optionally pass inarguments to module + # we migrate this from in-place modules to allow flexibility + # in this case, we can add "home" to input arglist of home.nix + extraSpecialArgs = mkModuleArgs { + inherit pkgs; + myHome = { + username = "hungtr"; + homeDirectory = "/home/hungtr"; }; }; - # Personal darwin, effectively serves as the Darwin edge channel - "hungtran" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = base.modules ++ [ + }; + # Personal darwin, effectively serves as the Darwin edge channel + "hungtran" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = + base.modules + ++ [ ./home.nix { base.graphics.enable = false; @@ -157,83 +168,86 @@ { base.private_chromium.enable = false; } + { + home.packages = [ + pkgs.postman + ]; + } ]; - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "hungtran"; - homeDirectory = "/Users/hungtran"; - }; + extraSpecialArgs = mkModuleArgs { + inherit pkgs; + myHome = { + username = "hungtran"; + homeDirectory = "/Users/hungtran"; }; }; - # Work darwin - "htran" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = base.modules ++ [ + }; + # Work darwin + "htran" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = + base.modules + ++ [ ./home.nix + ./base/productive_desktop.nix + ./base/darwin-spotlight.nix + { + base.private_chromium.enable = false; + } + nerd_font_module { base.graphics.enable = false; # don't want to deal with GL stuffs on mac yet :/ base.graphics.useNixGL.defaultPackage = null; - # NOTE: this actually does not exist - base.keepass.path = "/Users/htran/keepass.kdbx"; base.alacritty.font.size = 11.0; base.git.name = "Hung"; base.git.email = "htran@egihosting.com"; } - nerd_font_module - ]; - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "htran"; - homeDirectory = "/Users/htran"; - }; - }; - }; - "nixos@Felia" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ - ./home.nix { - base.shells = { - shellInitExtra = '' - '' + x11_wsl; - }; + home.packages = [ + pkgs.postman + ]; } + {base.keepass.enable = pkgs.lib.mkForce false;} ]; - # optionally pass inarguments to module - # we migrate this from in-place modules to allow flexibility - # in this case, we can add "home" to input arglist of home.nix - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "nixos"; - homeDirectory = "/home/nixos"; - }; + extraSpecialArgs = mkModuleArgs { + inherit pkgs; + myHome = { + username = "htran"; + homeDirectory = "/Users/htran"; }; }; - # NOTE: This is never actually tested. This is for Ubuntu@Felia - # "ubuntu_admin" = home-manager.lib.homeManagerConfiguration { - # inherit pkgs; - # modules = [ - # ./home.nix - # ]; - # extraSpecialArgs = { - # myLib = lib; - # myHome = { - # username = "ubuntu_admin"; - # homeDirectory = "/home/ubuntu_admin"; - # shellInitExtra = '' - # '' + x11_wsl; - # }; - # }; - # }; - - # Personal laptop - hwtr = home-manager.lib.homeManagerConfiguration { + }; + "nixos@Felia" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./home.nix + { + base.shells = { + shellInitExtra = + '' + '' + + x11_wsl; + }; + } + ]; + # optionally pass inarguments to module + # we migrate this from in-place modules to allow flexibility + # in this case, we can add "home" to input arglist of home.nix + extraSpecialArgs = mkModuleArgs { inherit pkgs; - modules = base.modules ++ [ + myHome = { + username = "nixos"; + homeDirectory = "/home/nixos"; + }; + }; + }; + # Personal laptop + hwtr = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = + base.modules + ++ [ ./home.nix ./base/graphics.nix { @@ -244,17 +258,17 @@ ./base/productive_desktop.nix ]; - extraSpecialArgs = mkModuleArgs { - inherit pkgs; - myHome = { - username = "hwtr"; - homeDirectory = "/home/hwtr"; - packages = [ - pkgs.postman - ]; - }; + extraSpecialArgs = mkModuleArgs { + inherit pkgs; + myHome = { + username = "hwtr"; + homeDirectory = "/home/hwtr"; + packages = [ + pkgs.postman + ]; }; }; }; + }; }); } diff --git a/nix-conf/home-manager/fromYamlSandbox/flake.lock b/nix-conf/home-manager/fromYamlSandbox/flake.lock deleted file mode 100644 index 65e798e..0000000 --- a/nix-conf/home-manager/fromYamlSandbox/flake.lock +++ /dev/null @@ -1,44 +0,0 @@ -{ - "nodes": { - "from-yaml": { - "flake": false, - "locked": { - "lastModified": 1667993008, - "narHash": "sha256-X5RWyebq+j56mUGGCmZTVcJBy6Y/QgFEMHklaz+GOt0=", - "owner": "pegasust", - "repo": "fromYaml", - "rev": "23d2616051f5a781dcfe2915a526925fd9cdd08c", - "type": "github" - }, - "original": { - "owner": "pegasust", - "repo": "fromYaml", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1667811565, - "narHash": "sha256-HYml7RdQPQ7X13VNe2CoDMqmifsXbt4ACTKxHRKQE3Q=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "667e5581d16745bcda791300ae7e2d73f49fff25", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "from-yaml": "from-yaml", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/nix-conf/home-manager/fromYamlSandbox/flake.nix b/nix-conf/home-manager/fromYamlSandbox/flake.nix deleted file mode 100644 index 1bfc84a..0000000 --- a/nix-conf/home-manager/fromYamlSandbox/flake.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - from-yaml = { - url = "github:pegasust/fromYaml"; - flake = false; - }; - }; - outputs = { nixpkgs, from-yaml, ... }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - lib = { - fromYaml = import "${from-yaml}/fromYaml.nix" { lib = pkgs.lib; }; - }; - in - { - inherit nixpkgs; - inherit from-yaml; - inherit lib; - inherit pkgs; - fromYamlFn = lib.fromYaml; - yamlCmd = str: (builtins.fromJSON (pkgs.runCommand "echo ${str} | yq")); - test_0 = '' - key_bindings: - - hello: - "N" - ''; - key_bind = '' - key_bindings: - - { key: N, mods: Control, action: CreateNewWindow } - # - { key: Paste, action: Paste } - # - { key: Copy, action: Copy } - #- { key: L, mods: Control, action: ClearLogNotice } - #- { key: L, mods: Control, mode: ~Vi|~Search, chars: "\x0c" } - #- { key: PageUp, mods: Shift, mode: ~Alt, action: ScrollPageUp } - #- { key: PageDown, mods: Shift, mode: ~Alt, action: ScrollPageDown } - #- { key: Home, mods: Shift, mode: ~Alt, action: ScrollToTop } - #- { key: End, mods: Shift, mode: ~Alt, action: ScrollToBottom } - - # Vi Mode - #- { key: Space, mods: Shift|Control, mode: ~Search, action: ToggleViMode } - - { key: Escape, mods: Shift, mode: ~Search, action: ToggleViMode } - #- { key: Space, mods: Shift|Control, mode: Vi|~Search, action: ScrollToBottom } - #- { key: Escape, mode: Vi|~Search, action: ClearSelection } - #- { key: I, mode: Vi|~Search, action: ToggleViMode } - #- { key: I, mode: Vi|~Search, action: ScrollToBottom } - #- { key: C, mods: Control, mode: Vi|~Search, action: ToggleViMode } - #- { key: Y, mods: Control, mode: Vi|~Search, action: ScrollLineUp } - #- { key: E, mods: Control, mode: Vi|~Search, action: ScrollLineDown } - #- { key: G, mode: Vi|~Search, action: ScrollToTop } - #- { key: G, mods: Shift, mode: Vi|~Search, action: ScrollToBottom } - #- { key: B, mods: Control, mode: Vi|~Search, action: ScrollPageUp } - #- { key: F, mods: Control, mode: Vi|~Search, action: ScrollPageDown } - #- { key: U, mods: Control, mode: Vi|~Search, action: ScrollHalfPageUp } - #- { key: D, mods: Control, mode: Vi|~Search, action: ScrollHalfPageDown } - #- { key: Y, mode: Vi|~Search, action: Copy } - #- { key: Y, mode: Vi|~Search, action: ClearSelection } - #- { key: Copy, mode: Vi|~Search, action: ClearSelection } - #- { key: V, mode: Vi|~Search, action: ToggleNormalSelection } - #- { key: V, mods: Shift, mode: Vi|~Search, action: ToggleLineSelection } - #- { key: V, mods: Control, mode: Vi|~Search, action: ToggleBlockSelection } - #- { key: V, mods: Alt, mode: Vi|~Search, action: ToggleSemanticSelection } - #- { key: Return, mode: Vi|~Search, action: Open } - #- { key: Z, mode: Vi|~Search, action: CenterAroundViCursor } - #- { key: K, mode: Vi|~Search, action: Up } - #- { key: J, mode: Vi|~Search, action: Down } - #- { key: H, mode: Vi|~Search, action: Left } - #- { key: L, mode: Vi|~Search, action: Right } - #- { key: Up, mode: Vi|~Search, action: Up } - #- { key: Down, mode: Vi|~Search, action: Down } - #- { key: Left, mode: Vi|~Search, action: Left } - #- { key: Right, mode: Vi|~Search, action: Right } - #- { key: Key0, mode: Vi|~Search, action: First } - #- { key: Key4, mods: Shift, mode: Vi|~Search, action: Last } - #- { key: Key6, mods: Shift, mode: Vi|~Search, action: FirstOccupied } - #- { key: H, mods: Shift, mode: Vi|~Search, action: High } - #- { key: M, mods: Shift, mode: Vi|~Search, action: Middle } - #- { key: L, mods: Shift, mode: Vi|~Search, action: Low } - #- { key: B, mode: Vi|~Search, action: SemanticLeft } - #- { key: W, mode: Vi|~Search, action: SemanticRight } - #- { key: E, mode: Vi|~Search, action: SemanticRightEnd } - #- { key: B, mods: Shift, mode: Vi|~Search, action: WordLeft } - #- { key: W, mods: Shift, mode: Vi|~Search, action: WordRight } - #- { key: E, mods: Shift, mode: Vi|~Search, action: WordRightEnd } - #- { key: Key5, mods: Shift, mode: Vi|~Search, action: Bracket } - #- { key: Slash, mode: Vi|~Search, action: SearchForward } - #- { key: Slash, mods: Shift, mode: Vi|~Search, action: SearchBackward } - #- { key: N, mode: Vi|~Search, action: SearchNext } - #- { key: N, mods: Shift, mode: Vi|~Search, action: SearchPrevious } - - # Search Mode - #- { key: Return, mode: Search|Vi, action: SearchConfirm } - #- { key: Escape, mode: Search, action: SearchCancel } - #- { key: C, mods: Control, mode: Search, action: SearchCancel } - #- { key: U, mods: Control, mode: Search, action: SearchClear } - #- { key: W, mods: Control, mode: Search, action: SearchDeleteWord } - #- { key: P, mods: Control, mode: Search, action: SearchHistoryPrevious } - #- { key: N, mods: Control, mode: Search, action: SearchHistoryNext } - #- { key: Up, mode: Search, action: SearchHistoryPrevious } - #- { key: Down, mode: Search, action: SearchHistoryNext } - #- { key: Return, mode: Search|~Vi, action: SearchFocusNext } - #- { key: Return, mods: Shift, mode: Search|~Vi, action: SearchFocusPrevious } - - # (Windows, Linux, and BSD only) - - { key: V, mods: Control|Shift, mode: ~Vi, action: Paste } - - { key: C, mods: Control|Shift, action: Copy } - ''; - }; -} - diff --git a/nix-conf/home-manager/home.nix b/nix-conf/home-manager/home.nix index b338fcc..9c5f86e 100644 --- a/nix-conf/home-manager/home.nix +++ b/nix-conf/home-manager/home.nix @@ -3,18 +3,20 @@ # This file represents the base settings for each machine # Additional configurations goes to profiles/ # or inlined in flake.nix -{ config # Represents the realized final configuration -, pkgs # This is by default just ``= import {}` -, myHome -, myLib -, option # The options we're given, this might be useful for typesafety? -, proj_root -, ... -}: -let - inherit (myLib) fromYaml; -in { + config, + # Represents the realized final configuration + pkgs, + # This is by default just ``= import {}` + myHome, + myLib, + option, + # The options we're given, this might be useful for typesafety? + proj_root, + ... +}: let + inherit (myLib) fromYaml; +in { imports = [ ./base/neovim.nix ./base/keepass.nix @@ -24,43 +26,47 @@ in homeDirectory = myHome.homeDirectory; stateVersion = myHome.stateVersion or "22.05"; }; - home.packages = pkgs.lib.unique ([ - # pkgs.ncdu - pkgs.rclone # cloud file operations - pkgs.htop # system diagnostics in CLI - pkgs.ripgrep # content fuzzy search - pkgs.unzip # compression - pkgs.zip # compression + home.packages = pkgs.lib.unique ( + [ + # pkgs.ncdu + pkgs.rclone # cloud file operations + pkgs.htop # system diagnostics in CLI + pkgs.ripgrep # content fuzzy search + pkgs.unzip # compression + pkgs.zip # compression - # cool utilities - pkgs.yq # Yaml adaptor for jq (only pretty print, little query) - # pkgs.xorg.xclock # TODO: only include if have gui # For testing GL installation - # pkgs.logseq # TODO: only include if have GL # Obsidian alt - pkgs.mosh # Parsec for SSH - pkgs.nixops_unstable # nixops v2 # insecure for now - pkgs.lynx # Web browser at your local terminal - pkgs.zk + # cool utilities + pkgs.yq-go # Yaml adaptor for jq (only pretty print, little query) + # pkgs.xorg.xclock # TODO: only include if have gui # For testing GL installation + # pkgs.logseq # TODO: only include if have GL # Obsidian alt + pkgs.mosh # Parsec for SSH + # pkgs.nixops_unstable # nixops v2 # insecure for now + pkgs.lynx # Web browser at your local terminal + pkgs.zk - # pkgs.tailscale # VPC;; This should be installed in system-nix - pkgs.python310 # dev packages should be in project - # pkgs.python310.numpy - # pkgs.python310Packages.tensorflow - # pkgs.python310Packages.scikit-learn - ] ++ (myHome.packages or [ ]) ++ (if pkgs.system == "x86_64-linux" then [ - pkgs.logseq - ] else [ ]) + # pkgs.tailscale # VPC;; This should be installed in system-nix + pkgs.python310 # dev packages should be in project + # pkgs.python310.numpy + # pkgs.python310Packages.tensorflow + # pkgs.python310Packages.scikit-learn + ] + ++ (myHome.packages or []) + ++ ( + if pkgs.system == "x86_64-linux" + then [ + pkgs.logseq + ] + else [] + ) ); - ## Configs ## + ## Configs ## xdg.configFile."zk/config.toml".source = "${proj_root.config.path}//zk/config.toml"; ## Programs ## programs.jq = { enable = true; }; - # not exist in home-manager - # have to do it at system level - # services.ntp.enable = true; # automatic time programs.nix-index = { enable = true; enableBashIntegration = true; diff --git a/nix-conf/home-manager/htran/nix.conf b/nix-conf/home-manager/htran/nix.conf new file mode 100644 index 0000000..93b8bba --- /dev/null +++ b/nix-conf/home-manager/htran/nix.conf @@ -0,0 +1,6 @@ +accept-flake-config = true +experimental-features = nix-command flakes +post-build-hook = /etc/nix/upload-to-cache.sh +trusted-users = root htran hungtran hwtr +max-jobs = 8 +cores = 12 diff --git a/nix-conf/home-manager/hwtr/nix.conf b/nix-conf/home-manager/hwtr/nix.conf index 899ea7a..65a4873 100644 --- a/nix-conf/home-manager/hwtr/nix.conf +++ b/nix-conf/home-manager/hwtr/nix.conf @@ -1,3 +1,5 @@ accept-flake-config = true experimental-features = nix-command flakes +post-build-hook = /etc/nix/upload-to-cache.sh +trusted-users = root htran hungtran hwtr diff --git a/nix-conf/home-manager/nix.conf b/nix-conf/home-manager/nix.conf new file mode 100644 index 0000000..a9ba586 --- /dev/null +++ b/nix-conf/home-manager/nix.conf @@ -0,0 +1,4 @@ +accept-flake-config = true +experimental-features = nix-command flakes +post-build-hook = /etc/nix/upload-to-cache.sh +trusted-users = root htran hungtran hwtr diff --git a/nix-conf/home-manager/overlays.nix b/nix-conf/home-manager/overlays.nix new file mode 100644 index 0000000..0bd9639 --- /dev/null +++ b/nix-conf/home-manager/overlays.nix @@ -0,0 +1,71 @@ +flake_input @ { + kpcli-py, + nixgl, + rust-overlay, + neovim-nightly-overlay, + system, + nix-boost, + nixpkgs-latest, + ... +}: let + kpcli-py = final: prev: { + # use python3.9, which works because of cython somehow? + kpcli-py = final.poetry2nix.mkPoetryApplication { + projectDir = flake_input.kpcli-py; + overrides = final.poetry2nix.defaultPoetryOverrides.extend (self: super: { + # tableformatter requires setuptools + tableformatter = super.tableformatter.overridePythonAttrs ( + old: { + buildInputs = (old.buildInputs or []) ++ [self.setuptools self.cython_3]; + src = old.src; + } + ); + kpcli = super.kpcli.overridePythonAttrs (old: { + buildInputs = (old.buildInputs or []) ++ [self.setuptools]; + }); + + # ubersmith = super.ubersmith.overridePythonAttrs (old: { + # buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ + # py-final.setuptools + # py-final.pip + # ]); + # + # src = final.fetchFromGitHub { + # owner = "jasonkeene"; + # repo = "python-ubersmith"; + # rev = "0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a"; + # sha256 = "sha256-Dystt7CBtjpLkgzCsAif8WkkYYeLyh7VMehAtwoDGuM="; + # }; + # }); + }); + }; + }; + + rust = final: prev: let + nightlyRustWithExts = exts: + final.rust-bin.selectLatestNightlyWith ( + toolchain: (toolchain.minimal.override { + extensions = exts; + }) + ); + # https://rust-lang.github.io/rustup/concepts/profiles.html + rust-default-components = ["rust-docs" "rustfmt" "clippy"]; + rust-dev-components = rust-default-components ++ ["rust-src" "rust-analyzer" "miri"]; + in { + rust4devs = nightlyRustWithExts rust-dev-components; + rust4cargo = nightlyRustWithExts []; + rust4normi = nightlyRustWithExts rust-default-components; + }; + + vimPlugins = final: prev: { + inherit (nixpkgs-latest.legacyPackages.${system}) vimPlugins; + }; +in [ + nix-boost.overlays.default + nixgl.overlays.default + rust-overlay.overlays.default + neovim-nightly-overlay.overlay + rust + kpcli-py + vimPlugins +] diff --git a/nix-conf/home-manager/profiles/default.nix b/nix-conf/home-manager/profiles/default.nix index 1734c70..e52952a 100644 --- a/nix-conf/home-manager/profiles/default.nix +++ b/nix-conf/home-manager/profiles/default.nix @@ -1,5 +1,8 @@ # main module exporter for different configuration profiles -{ pkgs, libs, ... } @ inputs: { + pkgs, + libs, + ... +} @ inputs: { hwtr = import ./hwtr.nix; } diff --git a/nix-conf/lib/default.nix b/nix-conf/lib/default.nix index c7ec7d9..66449f9 100644 --- a/nix-conf/lib/default.nix +++ b/nix-conf/lib/default.nix @@ -1,12 +1,12 @@ -{ pkgs -, lib ? pkgs.lib -, ... -}@flake_import: -let - serde = import ./serde { inherit pkgs lib; }; +{ + pkgs, + lib ? pkgs.lib, + ... +} @ flake_import: let + serde = import ./serde {inherit pkgs lib;}; recursiveUpdate = lib.recursiveUpdate; in -recursiveUpdate (recursiveUpdate pkgs.lib lib) { - fromYaml = serde.fromYaml; - fromYamlPath = serde.fromYamlPath; -} + recursiveUpdate (recursiveUpdate pkgs.lib lib) { + fromYaml = serde.fromYaml; + fromYamlPath = serde.fromYamlPath; + } diff --git a/nix-conf/lib/serde/default.nix b/nix-conf/lib/serde/default.nix index b4c9299..8a50344 100644 --- a/nix-conf/lib/serde/default.nix +++ b/nix-conf/lib/serde/default.nix @@ -1,30 +1,39 @@ # Takes care of serializing and deserializing to some formats # Blame: Pegasust # TODO: Add to* formats from pkgs.formats.* -{ pkgs -, lib -} @ inputs: -let - yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage - ({ runCommand }: +{ + pkgs, + lib, +} @ inputs: let + yamlToJsonDrv = yamlContent: outputPath: + pkgs.callPackage + ({runCommand}: # runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33 - runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; } + runCommand outputPath + { + inherit yamlContent; + nativeBuildInputs = [pkgs.yq]; + } # run yq which outputs '.' (no filter) on file at yamlPath # note that $out is passed onto the bash/sh script for execution '' echo "$yamlContent" | yq >$out '') - { }; -in -{ + {}; +in { # Takes in a yaml string and produces a derivation with translated JSON at $outputPath # similar to builtins.fromJSON, turns a YAML string to nix attrset fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json")); - fromYamlPath = yamlPath: builtins.fromJSON ( - builtins.readFile ( - yamlToJsonDrv + fromYamlPath = yamlPath: + builtins.fromJSON ( + builtins.readFile ( + yamlToJsonDrv ( - builtins.readFile yamlPath) - "any-output.json")); - # TODO: fromToml? + builtins.readFile yamlPath + ) + "any-output.json" + ) + ); + fromTOML = builtins.fromTOML; + fromJSON = builtins.fromJSON; } diff --git a/nix-conf/pkgs/default.nix b/nix-conf/pkgs/default.nix index 7f47280..81eccdd 100644 --- a/nix-conf/pkgs/default.nix +++ b/nix-conf/pkgs/default.nix @@ -1,10 +1,12 @@ # This module aims to be merge (not inject/override) with top-level pkgs to provide # personalized/custom packages -{ pkgs -, lib -, naersk # rust packages -, ... -}@pkgs_input: { +{ + pkgs, + lib, + naersk, + # rust packages + ... +} @ pkgs_input: { # dot-hwtr = import "./dot-hwtr" pkgs_input; cargo-bacon = pkgs.rustPlatform.buildRustPackage rec { pname = "bacon"; diff --git a/nix-conf/pkgs/flake.nix b/nix-conf/pkgs/flake.nix index 2e17df4..2af6c0c 100644 --- a/nix-conf/pkgs/flake.nix +++ b/nix-conf/pkgs/flake.nix @@ -4,10 +4,12 @@ rust-overlay.url = "github:oxalica/rust-overlay"; naersk.url = "gihub:nix-community/naersk"; }; - outputs = { nixpkgs, rust-overlay, naersk }: - let - pkgs = import nixpkgs { overlays = [ rust-overlay.overlays.default ]; }; - lib = pkgs.lib; - in - (import ./default.nix { inherit pkgs lib naersk; }); + outputs = { + nixpkgs, + rust-overlay, + naersk, + }: let + pkgs = import nixpkgs {overlays = [rust-overlay.overlays.default];}; + lib = pkgs.lib; + in (import ./default.nix {inherit pkgs lib naersk;}); } diff --git a/nix-conf/secrets.nix b/nix-conf/secrets.nix index 0c5bf16..ec5a5f3 100644 --- a/nix-conf/secrets.nix +++ b/nix-conf/secrets.nix @@ -10,10 +10,8 @@ let all = users // systems; # stands for calculus c_ = builtins; -in -{ - "system/secrets/s3fs.age".publicKeys = c_.attrValues (all); - "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all); - "system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all); - +in { + "system/secrets/s3fs.age".publicKeys = c_.attrValues all; + "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; + "system/secrets/_nhitrl.age".publicKeys = c_.attrValues all; } diff --git a/nix-conf/system/configuration.nix b/nix-conf/system/configuration.nix index e4318dd..6c18c04 100755 --- a/nix-conf/system/configuration.nix +++ b/nix-conf/system/configuration.nix @@ -1,61 +1,71 @@ -{ lib, pkgs, config, modulesPath, specialArgs, ... }: -let +{ + lib, + pkgs, + config, + modulesPath, + specialArgs, + ... +}: let hostname = specialArgs.hostname; enableSSH = specialArgs.enableSSH or true; - _networking = lib.recursiveUpdate { hostName = hostname; } (specialArgs._networking or { }); - _boot = specialArgs._boot or { }; - _services = specialArgs._services or { }; + _networking = lib.recursiveUpdate {hostName = hostname;} (specialArgs._networking or {}); + _boot = specialArgs._boot or {}; + _services = specialArgs._services or {}; includeHardware = specialArgs.includeHardware or true; proj_root = builtins.toString ./../..; in -with lib; -{ - imports = (if includeHardware then [ - "${proj_root}/hosts/${hostname}/hardware-configuration.nix" - ] else [ ]) ++ [ - "${modulesPath}/profiles/minimal.nix" - "${proj_root}/modules/tailscale.sys.nix" - "${proj_root}/modules/mosh.sys.nix" - ]; - boot = _boot; + with lib; { + imports = + ( + if includeHardware + then [ + "${proj_root}/hosts/${hostname}/hardware-configuration.nix" + ] + else [] + ) + ++ [ + "${modulesPath}/profiles/minimal.nix" + "${proj_root}/modules/tailscale.sys.nix" + "${proj_root}/modules/mosh.sys.nix" + ]; + boot = _boot; - # prune old builds - nix.settings.auto-optimise-store = true; + # prune old builds + nix.settings.auto-optimise-store = true; - # Enable nix flakes - nix.package = pkgs.nixFlakes; - nix.extraOptions = '' - experimental-features = nix-command flakes - ''; - users.users.hungtr = { - isNormalUser = true; - home = "/home/hungtr"; - description = "pegasust/hungtr"; - extraGroups = [ "wheel" "networkmanager" "audio" ]; - }; - users.users.root = { - # openssh runs in root, no? This is because port < 1024 requires root. - openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/native_configs/ssh/authorized_keys"); - }; + # Enable nix flakes + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + users.users.hungtr = { + isNormalUser = true; + home = "/home/hungtr"; + description = "pegasust/hungtr"; + extraGroups = ["wheel" "networkmanager" "audio"]; + }; + users.users.root = { + # openssh runs in root, no? This is because port < 1024 requires root. + openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/native_configs/ssh/authorized_keys"); + }; - # Some basic programs - programs.neovim = { - enable = true; - defaultEditor = true; - }; + # Some basic programs + programs.neovim = { + enable = true; + defaultEditor = true; + }; - programs.git = { - enable = true; - # more information should be configured under user level - # See other config at @/home-nix - }; - - environment.systemPackages = [ - pkgs.gnumake - pkgs.wget - pkgs.inetutils # network diag - pkgs.mtr # network diag - pkgs.sysstat # sys diag - ]; -} + programs.git = { + enable = true; + # more information should be configured under user level + # See other config at @/home-nix + }; + environment.systemPackages = [ + pkgs.gnumake + pkgs.wget + pkgs.inetutils # network diag + pkgs.mtr # network diag + pkgs.sysstat # sys diag + ]; + } diff --git a/nix-conf/system/flake.nix b/nix-conf/system/flake.nix index e2e7c10..2b94aa3 100644 --- a/nix-conf/system/flake.nix +++ b/nix-conf/system/flake.nix @@ -7,208 +7,227 @@ }; }; - outputs = { self, nixpkgs, agenix, ... }: - let - lib = nixpkgs.lib; - proj_root = ./../..; - # TODO: Change respectively to the system or make a nix shell to alias `nix run github:ryantm/agenix -- ` - base_modules = [ - agenix.nixosModule - { - age.secrets.s3fs = { - file = ./secrets/s3fs.age; - # mode = "600"; # owner + group only - # owner = "hungtr"; - # group = "users"; - }; - age.secrets."s3fs.digital-garden" = { - file = ./secrets/s3fs.digital-garden.age; - }; - age.secrets._nhitrl_cred = { - file = ./secrets/_nhitrl.age; - }; - environment.systemPackages = [ agenix.defaultPackage.x86_64-linux ]; - } - ]; - in - { - # Windows with NixOS WSL - nixosConfigurations.Felia = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + outputs = { + self, + nixpkgs, + agenix, + ... + }: let + lib = nixpkgs.lib; + proj_root = ./../..; + # TODO: Change respectively to the system or make a nix shell to alias `nix run github:ryantm/agenix -- ` + base_modules = [ + agenix.nixosModule + { + age.secrets.s3fs = { + file = ../../secrets/s3fs.age; + # mode = "600"; # owner + group only + # owner = "hungtr"; + # group = "users"; + }; + age.secrets."s3fs.digital-garden" = { + file = ../../secrets/s3fs.digital-garden.age; + }; + age.secrets._nhitrl_cred = { + file = ../../secrets/_nhitrl.age; + }; + environment.systemPackages = [agenix.defaultPackage.x86_64-linux]; + } + ]; + in { + # Windows with NixOS WSL + nixosConfigurations.Felia = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./wsl-configuration.nix { system.stateVersion = "22.05"; } ]; - specialArgs = { - # includeHardware = false; - hostname = "Felia"; - _services.openssh = { - permitRootLogin = "no"; - enable = true; - }; + specialArgs = { + # includeHardware = false; + hostname = "Felia"; + _services.openssh = { + permitRootLogin = "no"; + enable = true; }; }; - nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + }; + nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./configuration.nix { system.stateVersion = "22.05"; mod.tailscale.enable = true; } ]; - specialArgs = { - hostname = "lizzi"; - _networking = { - interfaces.eth1.ipv4.addresses = [{ + specialArgs = { + hostname = "lizzi"; + _networking = { + interfaces.eth1.ipv4.addresses = [ + { address = "71.0.0.1"; prefixLength = 24; - }]; - firewall = { - enable = true; - allowedTCPPorts = [ 80 443 22 ]; - }; - useDHCP = false; - # required so that we get IP address from linode - interfaces.eth0.useDHCP = true; - }; - _boot.loader.grub.enable = true; - _boot.loader.grub.version = 2; - _services.openssh = { - permitRootLogin = "no"; + } + ]; + firewall = { enable = true; + allowedTCPPorts = [80 443 22]; }; - _services.gitea = { - enable = true; - stateDir = "/gitea"; - rootUrl = "https://git.pegasust.com"; - settings = { - repository = { - "ENABLE_PUSH_CREATE_USER" = true; - "ENABLE_PUSH_CREATE_ORG" = true; - }; - }; - }; - # Highly suspect that thanks to nginx, ipv6 is disabled? - _services.nginx = { - enable = true; - clientMaxBodySize = "100m"; # Allow big file transfers over git :^) - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - virtualHosts."git.pegasust.com" = { - # Gitea hostname - sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem"; - sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem"; - forceSSL = true; # Runs on port 80 and 443 - locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea + useDHCP = false; + # required so that we get IP address from linode + interfaces.eth0.useDHCP = true; + }; + _boot.loader.grub.enable = true; + _boot.loader.grub.version = 2; + _services.openssh = { + permitRootLogin = "no"; + enable = true; + }; + _services.gitea = { + enable = true; + stateDir = "/gitea"; + rootUrl = "https://git.pegasust.com"; + settings = { + repository = { + "ENABLE_PUSH_CREATE_USER" = true; + "ENABLE_PUSH_CREATE_ORG" = true; }; }; }; + # Highly suspect that thanks to nginx, ipv6 is disabled? + _services.nginx = { + enable = true; + clientMaxBodySize = "100m"; # Allow big file transfers over git :^) + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + virtualHosts."git.pegasust.com" = { + # Gitea hostname + sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem"; + sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem"; + forceSSL = true; # Runs on port 80 and 443 + locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea + }; + }; }; - # Generic machine - nixosConfigurations.pixi = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + }; + # Generic machine + nixosConfigurations.pixi = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./configuration.nix { system.stateVersion = "22.05"; } ]; - specialArgs = { - hostname = "pixi"; - _networking = { - # interfaces.eth1.ipv4.addresses = [{ - # address = "71.0.0.1"; - # prefixLength = 24; - # }]; - firewall = { - enable = false; - allowedTCPPorts = [ 80 443 22 ]; - }; - useDHCP = false; - # interfaces.eth0.useDHCP = true; + specialArgs = { + hostname = "pixi"; + _networking = { + # interfaces.eth1.ipv4.addresses = [{ + # address = "71.0.0.1"; + # prefixLength = 24; + # }]; + firewall = { + enable = false; + allowedTCPPorts = [80 443 22]; }; - _boot.loader.grub.enable = true; - _boot.loader.grub.version = 2; - _services.openssh = { - permitRootLogin = "no"; - enable = true; - }; - _services.gitea = { - enable = true; - stateDir = "/gitea"; - rootUrl = "https://git.pegasust.com"; - settings = { - repository = { - "ENABLE_PUSH_CREATE_USER" = true; - "ENABLE_PUSH_CREATE_ORG" = true; - }; - }; - }; - _services.nginx = { - enable = true; - clientMaxBodySize = "100m"; # Allow big file transfers over git :^) - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - virtualHosts."git.pegasust.com" = { - # Gitea hostname - sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem"; - sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem"; - forceSSL = true; # Runs on port 80 and 443 - locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea + useDHCP = false; + # interfaces.eth0.useDHCP = true; + }; + _boot.loader.grub.enable = true; + _boot.loader.grub.version = 2; + _services.openssh = { + permitRootLogin = "no"; + enable = true; + }; + _services.gitea = { + enable = true; + stateDir = "/gitea"; + rootUrl = "https://git.pegasust.com"; + settings = { + repository = { + "ENABLE_PUSH_CREATE_USER" = true; + "ENABLE_PUSH_CREATE_ORG" = true; }; }; }; + _services.nginx = { + enable = true; + clientMaxBodySize = "100m"; # Allow big file transfers over git :^) + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + virtualHosts."git.pegasust.com" = { + # Gitea hostname + sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem"; + sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem"; + forceSSL = true; # Runs on port 80 and 443 + locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea + }; + }; }; - nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + }; + nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./configuration.nix { system.stateVersion = "22.05"; } ]; - specialArgs = { - hostname = "nyx"; - _networking = { - enableIPv6 = false; - interfaces.eth1.ipv4.addresses = [{ + specialArgs = { + hostname = "nyx"; + _networking = { + enableIPv6 = false; + interfaces.eth1.ipv4.addresses = [ + { address = "71.0.0.2"; prefixLength = 24; - }]; - firewall.enable = true; - useDHCP = false; - interfaces.eth0.useDHCP = true; - }; - _boot.loader.grub.enable = true; - _boot.loader.grub.version = 2; - _services.openssh = { - permitRootLogin = "no"; - enable = true; - }; + } + ]; + firewall.enable = true; + useDHCP = false; + interfaces.eth0.useDHCP = true; + }; + _boot.loader.grub.enable = true; + _boot.loader.grub.version = 2; + _services.openssh = { + permitRootLogin = "no"; + enable = true; }; }; - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + }; + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./configuration.nix { system.stateVersion = "22.05"; } ]; - specialArgs = { - hostname = "nixos"; - }; + specialArgs = { + hostname = "nixos"; }; - nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = base_modules ++ [ + }; + nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = + base_modules + ++ [ ./configuration.nix { system.stateVersion = "22.11"; @@ -218,189 +237,98 @@ # interface = "ens32"; }; networking.interfaces.ens32.ipv4.addresses = [ - {address = "10.100.200.230"; prefixLength = 24;} + { + address = "10.100.200.230"; + prefixLength = 24; + } ]; } ]; - specialArgs = { - hostname = "htran-dev"; - _networking = { - firewall.enable = true; - useDHCP = false; - interfaces.eth0.useDHCP = true; - }; - _boot.loader.grub.enable = true; - _boot.loader.grub.version = 2; - _services.openssh = { - permitRootLogin = "no"; - enable = true; - }; + specialArgs = { + hostname = "htran-dev"; + _networking = { + firewall.enable = true; + useDHCP = false; + interfaces.eth0.useDHCP = true; + }; + _boot.loader.grub.enable = true; + _boot.loader.grub.version = 2; + _services.openssh = { + permitRootLogin = "no"; + enable = true; }; }; - nixosConfigurations.bao = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs.hostname = "bao"; - modules = base_modules ++ [ + }; + nixosConfigurations.bao = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs.hostname = "bao"; + modules = + base_modules + ++ [ ./configuration.nix ./../../modules/storage.perso.sys.nix + ./../../modules/kde.sys.nix # GPU, sound, networking stuffs - ({ config, pkgs, lib, ... }: - let - gpu_pkgs = [ pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools ]; - gpu_conf = { - # openCL - hardware.opengl = { - enable = true; - extraPackages = - let - inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime; - in - [ rocm-opencl-icd rocm-opencl-runtime ]; - # Vulkan - driSupport = true; - driSupport32Bit = true; - package = pkgs.mesa.drivers; - package32 = pkgs.pkgsi686Linux.mesa.drivers; - }; - }; - amd_rx470 = { - # early amd gpu usage - boot.initrd.kernelModules = [ "amdgpu" ]; - services.xserver.enable = true; - services.xserver.videoDrivers = [ "amdgpu" ]; - }; - nv_rtx3060 = { - nixpkgs.config.allowUnfree = true; - services.xserver.enable = true; - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - systemPackages = [ ] ++ gpu_pkgs; - in - lib.recursiveUpdate gpu_conf (lib.recursiveUpdate nv_rtx3060 { - # Use UEFI - boot.loader.systemd-boot.enable = true; + ./../../modules/pulseaudio.sys.nix + ./../../modules/opengl.sys.nix + ./../../modules/nvgpu.sys.nix + ({ + config, + pkgs, + lib, + ... + }: { + mod.tailscale.enable = true; + # Use UEFI + boot.loader.systemd-boot.enable = true; - networking.hostName = "bao"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.hostName = "bao"; # Define your hostname. + # Pick only one of the below networking options. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. - # Enable the X11 windowing system. - services.xserver.enable = true; - # KDE & Plasma 5 - services.xserver.displayManager.sddm.enable = true; - services.xserver.desktopManager.plasma5 = { - enable = true; - excludePackages = let plasma5 = pkgs.libsForQt5; in - [ - plasma5.elisa # audio viewer - plasma5.konsole # I use alacritty instaed - plasma5.plasma-browser-integration - plasma5.print-manager # will enable if I need - plasma5.khelpcenter # why not just write manpages instead :( - # plasma5.ksshaskpass # pls just put prompts on my dear terminal - ]; - }; + time.timeZone = "America/Phoenix"; + # Configure keymap in X11 + services.xserver.layout = "us"; + # services.xserver.xkbOptions = { + # "eurosign:e"; + # "caps:escape" # map caps to escape. + # }; - # disables KDE's setting of askpassword - programs.ssh.askPassword = ""; - programs.ssh.enableAskPassword = false; + # Enable CUPS to print documents. + # services.printing.enable = true; - time.timeZone = "America/Phoenix"; - # Configure keymap in X11 - services.xserver.layout = "us"; - # services.xserver.xkbOptions = { - # "eurosign:e"; - # "caps:escape" # map caps to escape. - # }; + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + # Just an initial user to get this started lol + users.users.user = { + initialPassword = "pw123"; + extraGroups = ["wheel" "networkmanager" "audio"]; + isNormalUser = true; + }; - # Enable CUPS to print documents. - # services.printing.enable = true; + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; - # Enable sound. (pulse audio) - sound.enable = true; - programs.dconf.enable = true; - hardware.pulseaudio.enable = true; - hardware.pulseaudio.support32Bit = true; - nixpkgs.config.pulseaudio = true; - hardware.pulseaudio.extraConfig = "load-module module-combine-sink"; - mod.tailscale.enable = true; + # List services that you want to enable: - # Sound: pipewire - # sound.enable = false; - # hardware.pulseaudio.enable = false; - # services.pipewire = { - # enable = true; - # alsa.enable = true; - # alsa.support32Bit = true; - # pulse.enable = true; - # # Might want to use JACK in the future - # jack.enable = true; - # }; - # - # security.rtkit.enable = true; + # Enable the OpenSSH daemon. + services.openssh.enable = true; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - # users.users.alice = { - # isNormalUser = true; - # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - # packages = with pkgs; [ - # firefox - # thunderbird - # ]; - # }; - # Just an initial user to get this started lol - users.users.user = { - initialPassword = "pw123"; - extraGroups = [ "wheel" "networkmanager" "audio" ]; - isNormalUser = true; - }; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - neovim - wget - ] ++ systemPackages; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. - # system.copySystemConfiguration = true; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "22.11"; # Did you read the comment? - })) + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "22.11"; # Did you read the comment? + }) ]; - }; }; + }; } diff --git a/nix-conf/system/hardware-configuration.nix b/nix-conf/system/hardware-configuration.nix index e45b92a..e37389b 100644 --- a/nix-conf/system/hardware-configuration.nix +++ b/nix-conf/system/hardware-configuration.nix @@ -1,17 +1,20 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelParams = ["console=ttyS0,19200n8"]; boot.loader.grub.extraConfig = '' serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 terminal_input serial; @@ -20,17 +23,15 @@ boot.loader.grub.forceInstall = true; boot.loader.grub.device = "nodev"; boot.loader.timeout = 10; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.kernelModules = []; + boot.extraModulePackages = []; - fileSystems."/" = - { - device = "/dev/sda"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/sda"; + fsType = "ext4"; + }; - swapDevices = - [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/nixos-wsl/default.nix b/nix-conf/system/nixos-wsl/default.nix index 873ece4..0205bc8 100644 --- a/nix-conf/system/nixos-wsl/default.nix +++ b/nix-conf/system/nixos-wsl/default.nix @@ -3,11 +3,12 @@ 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; - } + 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 = ./.; - }).defaultNix + }) +.defaultNix diff --git a/nix-conf/system/nixos-wsl/flake.nix b/nix-conf/system/nixos-wsl/flake.nix index 8a62b47..a0996c1 100644 --- a/nix-conf/system/nixos-wsl/flake.nix +++ b/nix-conf/system/nixos-wsl/flake.nix @@ -11,9 +11,13 @@ }; }; - outputs = { self, nixpkgs, flake-utils, ... }: + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: { - nixosModules.wsl = { imports = [ ./modules/build-tarball.nix @@ -31,26 +35,25 @@ ./configuration.nix ]; }; - - } // - flake-utils.lib.eachSystem - (with flake-utils.lib.system; [ "x86_64-linux" "aarch64-linux" ]) - (system: - let - pkgs = import nixpkgs { inherit system; }; - in - { - checks.check-format = pkgs.runCommand "check-format" - { - buildInputs = with pkgs; [ nixpkgs-fmt ]; - } '' + } + // flake-utils.lib.eachSystem + (with flake-utils.lib.system; ["x86_64-linux" "aarch64-linux"]) + ( + system: let + pkgs = import nixpkgs {inherit system;}; + in { + checks.check-format = + pkgs.runCommand "check-format" + { + buildInputs = with pkgs; [nixpkgs-fmt]; + } '' nixpkgs-fmt --check ${./.} mkdir $out # success ''; - devShell = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ nixpkgs-fmt ]; - }; - } - ); + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [nixpkgs-fmt]; + }; + } + ); } diff --git a/nix-conf/system/nixos-wsl/modules/build-tarball.nix b/nix-conf/system/nixos-wsl/modules/build-tarball.nix index feba78d..7f974af 100644 --- a/nix-conf/system/nixos-wsl/modules/build-tarball.nix +++ b/nix-conf/system/nixos-wsl/modules/build-tarball.nix @@ -1,12 +1,24 @@ -{ config, pkgs, lib, ... }: -with builtins; with lib; -let - pkgs2storeContents = l: map (x: { object = x; symlink = "none"; }) l; +{ + config, + pkgs, + lib, + ... +}: +with builtins; +with lib; let + pkgs2storeContents = l: + map + (x: { + object = x; + symlink = "none"; + }) + l; nixpkgs = lib.cleanSource pkgs.path; - channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}" - { preferLocalBuild = true; } + channelSources = + pkgs.runCommand "nixos-${config.system.nixos.version}" + {preferLocalBuild = true;} '' mkdir -p $out cp -prd ${nixpkgs.outPath} $out/nixos @@ -58,10 +70,7 @@ let sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix ''} ''; - -in -{ - +in { options.wsl.tarball = { includeConfig = mkOption { type = types.bool; @@ -70,13 +79,12 @@ in }; }; - config = mkIf config.wsl.enable { # These options make no sense without the wsl-distro module anyway system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" { # No contents, structure will be added by prepare script - contents = [ ]; + contents = []; fileName = "nixos-wsl-${pkgs.hostPlatform.system}"; @@ -92,6 +100,5 @@ in compressCommand = "gzip"; compressionExtension = ".gz"; }; - }; } diff --git a/nix-conf/system/nixos-wsl/modules/docker-desktop.nix b/nix-conf/system/nixos-wsl/modules/docker-desktop.nix index ade86e9..273769b 100644 --- a/nix-conf/system/nixos-wsl/modules/docker-desktop.nix +++ b/nix-conf/system/nixos-wsl/modules/docker-desktop.nix @@ -1,20 +1,23 @@ -{ config, lib, pkgs, ... }: -with builtins; with lib; { - +{ + config, + lib, + pkgs, + ... +}: +with builtins; +with lib; { imports = [ - (mkRenamedOptionModule [ "wsl" "docker" ] [ "wsl" "docker-desktop" ]) + (mkRenamedOptionModule ["wsl" "docker"] ["wsl" "docker-desktop"]) ]; options.wsl.docker-desktop = with types; { enable = mkEnableOption "Docker Desktop integration"; }; - config = - let - cfg = config.wsl.docker-desktop; - in + config = let + cfg = config.wsl.docker-desktop; + in mkIf (config.wsl.enable && cfg.enable) { - environment.systemPackages = with pkgs; [ docker docker-compose @@ -25,7 +28,7 @@ with builtins; with lib; { script = '' ${config.wsl.automountPath}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop ''; - wantedBy = [ "multi-user.target" ]; + wantedBy = ["multi-user.target"]; serviceConfig = { Restart = "on-failure"; RestartSec = "30s"; @@ -35,7 +38,5 @@ with builtins; with lib; { users.groups.docker.members = [ config.wsl.defaultUser ]; - }; - } diff --git a/nix-conf/system/nixos-wsl/modules/docker-native.nix b/nix-conf/system/nixos-wsl/modules/docker-native.nix index 35d10ef..823a769 100644 --- a/nix-conf/system/nixos-wsl/modules/docker-native.nix +++ b/nix-conf/system/nixos-wsl/modules/docker-native.nix @@ -1,6 +1,11 @@ -{ config, lib, pkgs, ... }: -with builtins; with lib; { - +{ + config, + lib, + pkgs, + ... +}: +with builtins; +with lib; { options.wsl.docker-native = with types; { enable = mkEnableOption "Native Docker integration in NixOS."; @@ -15,14 +20,13 @@ with builtins; with lib; { }; }; - config = - let - cfg = config.wsl.docker-native; - in + config = let + cfg = config.wsl.docker-native; + in mkIf (config.wsl.enable && cfg.enable) { nixpkgs.overlays = [ (self: super: { - docker = super.docker.override { iptables = pkgs.iptables-legacy; }; + docker = super.docker.override {iptables = pkgs.iptables-legacy;}; }) ]; diff --git a/nix-conf/system/nixos-wsl/modules/installer.nix b/nix-conf/system/nixos-wsl/modules/installer.nix index 45d191a..20ac4fb 100644 --- a/nix-conf/system/nixos-wsl/modules/installer.nix +++ b/nix-conf/system/nixos-wsl/modules/installer.nix @@ -1,11 +1,19 @@ -{ config, lib, pkgs, ... }: -with builtins; with lib; { - +{ + config, + lib, + pkgs, + ... +}: +with builtins; +with lib; { config = mkIf config.wsl.enable ( let mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix"; - pkgs2storeContents = map (x: { object = x; symlink = "none"; }); + pkgs2storeContents = map (x: { + object = x; + symlink = "none"; + }); rootfs = let tarball = config.system.build.tarball; in "${tarball}/tarball/${tarball.fileName}.tar${tarball.extension}"; @@ -39,25 +47,39 @@ with builtins; with lib; { passwd = pkgs.writeText "passwd" '' root:x:0:0:System administrator:/root:${installer} ''; - in - { - + in { system.build.installer = mkTarball { fileName = "nixos-wsl-installer"; compressCommand = "gzip"; compressionExtension = ".gz"; extraArgs = "--hard-dereference"; - storeContents = with pkgs; pkgs2storeContents [ - installer - ]; + storeContents = with pkgs; + pkgs2storeContents [ + installer + ]; contents = [ - { source = config.environment.etc."wsl.conf".source; target = "/etc/wsl.conf"; } - { source = config.environment.etc."fstab".source; target = "/etc/fstab"; } - { source = passwd; target = "/etc/passwd"; } - { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/sh"; } - { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/mount"; } + { + source = config.environment.etc."wsl.conf".source; + target = "/etc/wsl.conf"; + } + { + source = config.environment.etc."fstab".source; + target = "/etc/fstab"; + } + { + source = passwd; + target = "/etc/passwd"; + } + { + source = "${pkgs.busybox}/bin/busybox"; + target = "/bin/sh"; + } + { + source = "${pkgs.busybox}/bin/busybox"; + target = "/bin/mount"; + } ]; extraCommands = pkgs.writeShellScript "prepare" '' @@ -66,8 +88,6 @@ with builtins; with lib; { ln -s /init bin/wslpath ''; }; - } ); - } diff --git a/nix-conf/system/nixos-wsl/modules/interop.nix b/nix-conf/system/nixos-wsl/modules/interop.nix index b7babfb..ae825eb 100644 --- a/nix-conf/system/nixos-wsl/modules/interop.nix +++ b/nix-conf/system/nixos-wsl/modules/interop.nix @@ -1,9 +1,13 @@ -{ lib, pkgs, config, ... }: - -with builtins; with lib; { + lib, + pkgs, + config, + ... +}: +with builtins; +with lib; { imports = [ - (mkRenamedOptionModule [ "wsl" "compatibility" "interopPreserveArgvZero" ] [ "wsl" "interop" "preserveArgvZero" ]) + (mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"]) ]; options.wsl.interop = with types; { @@ -32,57 +36,56 @@ with builtins; with lib; }; }; - config = - let - cfg = config.wsl.interop; - in + config = let + cfg = config.wsl.interop; + in mkIf config.wsl.enable { - boot.binfmt.registrations = mkIf cfg.register { - WSLInterop = - let - compat = cfg.preserveArgvZero; + WSLInterop = let + compat = cfg.preserveArgvZero; - # WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable - # with the "preserve argv[0]" flag, so if you run `./foo.exe`, the interp gets invoked - # as `/init foo.exe ./foo.exe`. - # argv[0] --^ ^-- actual path - # - # Older versions expect to be called without the argv[0] bit, simply as `/init ./foo.exe`. - # - # We detect that by running `/init /known-not-existing-path.exe` and checking the exit code: - # the new style interp expects at least two arguments, so exits with exit code 1, - # presumably meaning "parsing error"; the old style interp attempts to actually run - # the executable, fails to find it, and exits with 255. - compatWrapper = pkgs.writeShellScript "nixos-wsl-binfmt-hack" '' - /init /nixos-wsl-does-not-exist.exe - [ $? -eq 255 ] && shift - exec /init "$@" - ''; + # WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable + # with the "preserve argv[0]" flag, so if you run `./foo.exe`, the interp gets invoked + # as `/init foo.exe ./foo.exe`. + # argv[0] --^ ^-- actual path + # + # Older versions expect to be called without the argv[0] bit, simply as `/init ./foo.exe`. + # + # We detect that by running `/init /known-not-existing-path.exe` and checking the exit code: + # the new style interp expects at least two arguments, so exits with exit code 1, + # presumably meaning "parsing error"; the old style interp attempts to actually run + # the executable, fails to find it, and exits with 255. + compatWrapper = pkgs.writeShellScript "nixos-wsl-binfmt-hack" '' + /init /nixos-wsl-does-not-exist.exe + [ $? -eq 255 ] && shift + exec /init "$@" + ''; - # use the autodetect hack if unset, otherwise call /init directly - interpreter = if compat == null then compatWrapper else "/init"; + # use the autodetect hack if unset, otherwise call /init directly + interpreter = + if compat == null + then compatWrapper + else "/init"; - # enable for the wrapper and autodetect hack - preserveArgvZero = if compat == false then false else true; - in - { - magicOrExtension = "MZ"; - fixBinary = true; - wrapInterpreterInShell = false; - inherit interpreter preserveArgvZero; - }; + # enable for the wrapper and autodetect hack + preserveArgvZero = + if compat == false + then false + else true; + in { + magicOrExtension = "MZ"; + fixBinary = true; + wrapInterpreterInShell = false; + inherit interpreter preserveArgvZero; + }; }; # Include Windows %PATH% in Linux $PATH. environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"''; - warnings = - let - registrations = config.boot.binfmt.registrations; - in + warnings = let + registrations = config.boot.binfmt.registrations; + in optional (!(registrations ? WSLInterop) && (length (attrNames config.boot.binfmt.registrations)) != 0) "Having any binfmt registrations without re-registering WSLInterop (wsl.interop.register) will break running .exe files from WSL2"; }; - - } diff --git a/nix-conf/system/nixos-wsl/modules/wsl-distro.nix b/nix-conf/system/nixos-wsl/modules/wsl-distro.nix index 4c6eda5..bf4f58c 100644 --- a/nix-conf/system/nixos-wsl/modules/wsl-distro.nix +++ b/nix-conf/system/nixos-wsl/modules/wsl-distro.nix @@ -1,42 +1,46 @@ -{ lib, pkgs, config, ... }: - -with builtins; with lib; { - options.wsl = with types; - let - coercedToStr = coercedTo (oneOf [ bool path int ]) (toString) str; - in - { - enable = mkEnableOption "support for running NixOS as a WSL distribution"; - automountPath = mkOption { - type = str; - default = "/mnt"; - description = "The path where windows drives are mounted (e.g. /mnt/c)"; - }; - automountOptions = mkOption { - type = str; - default = "metadata,uid=1000,gid=100"; - description = "Options to use when mounting windows drives"; - }; - defaultUser = mkOption { - type = str; - default = "nixos"; - description = "The name of the default user"; - }; - startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu"; - wslConf = mkOption { - type = attrsOf (attrsOf (oneOf [ string int bool ])); - description = "Entries that are added to /etc/wsl.conf"; - }; + lib, + pkgs, + config, + ... +}: +with builtins; +with lib; { + options.wsl = with types; let + coercedToStr = coercedTo (oneOf [bool path int]) toString str; + in { + enable = mkEnableOption "support for running NixOS as a WSL distribution"; + automountPath = mkOption { + type = str; + default = "/mnt"; + description = "The path where windows drives are mounted (e.g. /mnt/c)"; }; + automountOptions = mkOption { + type = str; + default = "metadata,uid=1000,gid=100"; + description = "Options to use when mounting windows drives"; + }; + defaultUser = mkOption { + type = str; + default = "nixos"; + description = "The name of the default user"; + }; + startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu"; + wslConf = mkOption { + type = attrsOf (attrsOf (oneOf [string int bool])); + description = "Entries that are added to /etc/wsl.conf"; + }; + }; - config = - let - cfg = config.wsl; - syschdemd = import ../syschdemd.nix { inherit lib pkgs config; inherit (cfg) automountPath defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; }; - in + config = let + cfg = config.wsl; + syschdemd = import ../syschdemd.nix { + inherit lib pkgs config; + inherit (cfg) automountPath defaultUser; + defaultUserHome = config.users.users.${cfg.defaultUser}.home; + }; + in mkIf cfg.enable { - wsl.wslConf = { automount = { enabled = true; @@ -57,9 +61,8 @@ with builtins; with lib; hardware.opengl.enable = true; # Enable GPU acceleration environment = { - etc = { - "wsl.conf".text = generators.toINI { } cfg.wslConf; + "wsl.conf".text = generators.toINI {} cfg.wslConf; # DNS settings are managed by WSL hosts.enable = !config.wsl.wslConf.network.generateHosts; @@ -67,7 +70,7 @@ with builtins; with lib; }; systemPackages = [ - (pkgs.runCommand "wslpath" { } '' + (pkgs.runCommand "wslpath" {} '' mkdir -p $out/bin ln -s /init $out/bin/wslpath '') @@ -79,13 +82,13 @@ with builtins; with lib; users.users.${cfg.defaultUser} = { isNormalUser = true; uid = 1000; - extraGroups = [ "wheel" ]; # Allow the default user to use sudo + extraGroups = ["wheel"]; # Allow the default user to use sudo }; users.users.root = { shell = "${syschdemd}/bin/syschdemd"; # Otherwise WSL fails to login as root with "initgroups failed 5" - extraGroups = [ "root" ]; + extraGroups = ["root"]; }; security.sudo = { @@ -97,7 +100,7 @@ with builtins; with lib; system.activationScripts = { copy-launchers = mkIf cfg.startMenuLaunchers ( - stringAfter [ ] '' + stringAfter [] '' for x in applications icons; do echo "Copying /usr/share/$x" mkdir -p /usr/share/$x @@ -105,7 +108,7 @@ with builtins; with lib; done '' ); - populateBin = stringAfter [ ] '' + populateBin = stringAfter [] '' echo "setting up /bin..." ln -sf /init /bin/wslpath ln -sf ${pkgs.bashInteractive}/bin/bash /bin/sh @@ -134,6 +137,6 @@ with builtins; with lib; enableEmergencyMode = false; }; - warnings = (optional (config.systemd.services.systemd-resolved.enable && config.wsl.wslConf.network.generateResolvConf) "systemd-resolved is enabled, but resolv.conf is managed by WSL"); + warnings = optional (config.systemd.services.systemd-resolved.enable && config.wsl.wslConf.network.generateResolvConf) "systemd-resolved is enabled, but resolv.conf is managed by WSL"; }; } diff --git a/nix-conf/system/nixos-wsl/syschdemd.nix b/nix-conf/system/nixos-wsl/syschdemd.nix index 406dd86..b912fb6 100644 --- a/nix-conf/system/nixos-wsl/syschdemd.nix +++ b/nix-conf/system/nixos-wsl/syschdemd.nix @@ -1,19 +1,19 @@ -{ lib -, pkgs -, config -, automountPath -, defaultUser -, defaultUserHome ? "/home/${defaultUser}" -, ... +{ + lib, + pkgs, + config, + automountPath, + defaultUser, + defaultUserHome ? "/home/${defaultUser}", + ... }: - pkgs.substituteAll { name = "syschdemd"; src = ./syschdemd.sh; dir = "bin"; isExecutable = true; - buildInputs = with pkgs; [ daemonize ]; + buildInputs = with pkgs; [daemonize]; inherit defaultUser defaultUserHome; inherit (pkgs) daemonize; diff --git a/nix-conf/system/profiles/Felia/hardware-configuration.nix b/nix-conf/system/profiles/Felia/hardware-configuration.nix index 97c93fb..245f91b 100644 --- a/nix-conf/system/profiles/Felia/hardware-configuration.nix +++ b/nix-conf/system/profiles/Felia/hardware-configuration.nix @@ -1,15 +1,19 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = [ ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = []; - boot.initrd.availableKernelModules = [ ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = []; + boot.initrd.kernelModules = []; + boot.kernelModules = []; + boot.extraModulePackages = []; ## NOTE: These filesystems are mounted by a wrapper script from nix-wsl @@ -43,25 +47,22 @@ # fsType = "drvfs"; # }; - fileSystems."/mnt/c" = - { - device = "C:"; - fsType = "drvfs"; - }; + fileSystems."/mnt/c" = { + device = "C:"; + fsType = "drvfs"; + }; - fileSystems."/mnt/d" = - { - device = "D:"; - fsType = "drvfs"; - }; + fileSystems."/mnt/d" = { + device = "D:"; + fsType = "drvfs"; + }; - fileSystems."/mnt/f" = - { - device = "F:"; - fsType = "drvfs"; - }; + fileSystems."/mnt/f" = { + device = "F:"; + fsType = "drvfs"; + }; - swapDevices = [ ]; + swapDevices = []; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/profiles/bao/hardware-configuration.nix b/nix-conf/system/profiles/bao/hardware-configuration.nix index 3d4935d..aa90f0a 100644 --- a/nix-conf/system/profiles/bao/hardware-configuration.nix +++ b/nix-conf/system/profiles/bao/hardware-configuration.nix @@ -1,19 +1,22 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; # boot.initrd.kernelModules = [ "amdgpu" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" "coretemp" ]; - boot.extraModulePackages = [ ]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-amd" "coretemp"]; + boot.extraModulePackages = []; fileSystems."/" = # Might be wise to use /dev/nvme0p1 instead @@ -29,7 +32,7 @@ fsType = "vfat"; }; - swapDevices = [ ]; + swapDevices = []; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/profiles/homeless/hardware-configuration.nix b/nix-conf/system/profiles/homeless/hardware-configuration.nix index e45b92a..e37389b 100644 --- a/nix-conf/system/profiles/homeless/hardware-configuration.nix +++ b/nix-conf/system/profiles/homeless/hardware-configuration.nix @@ -1,17 +1,20 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelParams = ["console=ttyS0,19200n8"]; boot.loader.grub.extraConfig = '' serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 terminal_input serial; @@ -20,17 +23,15 @@ boot.loader.grub.forceInstall = true; boot.loader.grub.device = "nodev"; boot.loader.timeout = 10; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.kernelModules = []; + boot.extraModulePackages = []; - fileSystems."/" = - { - device = "/dev/sda"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/sda"; + fsType = "ext4"; + }; - swapDevices = - [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/profiles/lester/hardware-configuration.nix b/nix-conf/system/profiles/lester/hardware-configuration.nix index e45b92a..e37389b 100644 --- a/nix-conf/system/profiles/lester/hardware-configuration.nix +++ b/nix-conf/system/profiles/lester/hardware-configuration.nix @@ -1,17 +1,20 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelParams = ["console=ttyS0,19200n8"]; boot.loader.grub.extraConfig = '' serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 terminal_input serial; @@ -20,17 +23,15 @@ boot.loader.grub.forceInstall = true; boot.loader.grub.device = "nodev"; boot.loader.timeout = 10; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.kernelModules = []; + boot.extraModulePackages = []; - fileSystems."/" = - { - device = "/dev/sda"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/sda"; + fsType = "ext4"; + }; - swapDevices = - [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/profiles/lizzi/hardware-configuration.nix b/nix-conf/system/profiles/lizzi/hardware-configuration.nix index 5fa1db1..4078d1c 100644 --- a/nix-conf/system/profiles/lizzi/hardware-configuration.nix +++ b/nix-conf/system/profiles/lizzi/hardware-configuration.nix @@ -1,17 +1,20 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelParams = ["console=ttyS0,19200n8"]; boot.loader.grub.extraConfig = '' serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 terminal_input serial; @@ -20,8 +23,8 @@ boot.loader.grub.forceInstall = true; boot.loader.grub.device = "nodev"; boot.loader.timeout = 10; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.kernelModules = []; + boot.extraModulePackages = []; fileSystems = { "/" = { @@ -35,8 +38,7 @@ }; }; - swapDevices = - [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/profiles/nyx/hardware-configuration.nix b/nix-conf/system/profiles/nyx/hardware-configuration.nix index 88ffe66..4a88873 100644 --- a/nix-conf/system/profiles/nyx/hardware-configuration.nix +++ b/nix-conf/system/profiles/nyx/hardware-configuration.nix @@ -1,20 +1,23 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = []; + boot.extraModulePackages = []; - boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.kernelParams = ["console=ttyS0,19200n8"]; boot.loader.grub.extraConfig = '' serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 terminal_input serial; @@ -23,14 +26,12 @@ boot.loader.grub.forceInstall = true; boot.loader.grub.device = "nodev"; boot.loader.timeout = 10; - fileSystems."/" = - { - device = "/dev/sda"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/sda"; + fsType = "ext4"; + }; - swapDevices = - [{ device = "/dev/sdb"; }]; + swapDevices = [{device = "/dev/sdb";}]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nix-conf/system/wsl-configuration.nix b/nix-conf/system/wsl-configuration.nix index 48fd9d3..e40b36c 100755 --- a/nix-conf/system/wsl-configuration.nix +++ b/nix-conf/system/wsl-configuration.nix @@ -1,10 +1,7 @@ -{ lib, ... }: - -with lib; -let +{lib, ...}: +with lib; let nixos-wsl = import ./nixos-wsl; -in -{ +in { imports = [ ./configuration.nix nixos-wsl.nixosModules.wsl @@ -21,9 +18,7 @@ in # Enable integration with Docker Desktop (needs to be installed) docker-desktop.enable = true; - }; # users.users..uid = 1000; # networking.hostName = "nixos"; - } diff --git a/nix/cells/dotfiles/devshells.nix b/nix/cells/dotfiles/devshells.nix new file mode 100644 index 0000000..177c8be --- /dev/null +++ b/nix/cells/dotfiles/devshells.nix @@ -0,0 +1,11 @@ +{ + inputs, + cell, +}: let + inherit (inputs) std nixpkgs; +in { + default = std.lib.dev.mkShell { + name = "default"; + imports = [inputs.std.std.devshellProfiles.default]; + }; +} diff --git a/nix/cells/dotfiles/packages/default.nix b/nix/cells/dotfiles/packages/default.nix new file mode 100644 index 0000000..22d70e4 --- /dev/null +++ b/nix/cells/dotfiles/packages/default.nix @@ -0,0 +1,24 @@ +{ + inputs, + cell, +}: let + inherit (inputs.nixpkgs) system; + inherit (inputs.nix-boost.pkgs."${system}".mypkgs) poetry2nix; + inherit (poetry2nix) mkPoetryApplication defaultPoetryOverrides; +in { + kpcli-py = mkPoetryApplication { + projectDir = inputs.kpcli-py; + overrides = defaultPoetryOverrides.extend (self: super: { + # TODO: add this to upstream poetry2nix + tableformatter = super.tableformatter.overridePythonAttrs (old: { + buildInputs = (old.buildInputs or []) ++ [self.setuptools self.cython_3]; + src = old.src; + }); + + kpcli = super.kpcli.overridePythonAttrs (old: { + buildInputs = (old.buildInputs or []) ++ [self.setuptools]; + }); + }); + }; + +} diff --git a/nix/cells/repo/home-configs/default.nix b/nix/cells/repo/home-configs/default.nix new file mode 100644 index 0000000..4384ab5 --- /dev/null +++ b/nix/cells/repo/home-configs/default.nix @@ -0,0 +1,47 @@ +# TODO: this should use winnow with a fair matching of supported systems +{ + inputs, + cell, +}: let + inherit (cell) home-profiles home-modules; + inherit (inputs) home-manager; + pkgs = inputs.nixpkgs; + + # hm is derivation that is compatible with homeConfigurations + home-config = {supported_systems, hm, tested_systems ? []}: + hm // { + _supported_systems = supported_systems; + _tested_systems = tested_systems; + }; + + base-modules = [ + home-profiles.alacritty + # home-profiles.git + home-profiles.ssh + home-profiles.shells + ({config.programs.home-manager.enable = true;}) + home-profiles.nix-index + home-profiles.neovim + ]; +in { + homeConfigurations.htran = home-config { + supported_systems = ["aarch64-darwin" "x86_64-darwin"]; + tested_systems = ["aarch64-darwin"]; + hm = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = base-modules ++ [ + home-profiles.nerd_font_module + home-profiles.git-htran + home-profiles.dev-packages + home-profiles.zk + home-modules.darwin-spotlight + + ({ + home.username = "htran"; + home.homeDirectory = "/Users/htran"; + home.stateVersion = "23.11"; + }) + ]; + }; + }; +} diff --git a/nix/cells/repo/home-modules/default.nix b/nix/cells/repo/home-modules/default.nix new file mode 100644 index 0000000..d5f18c7 --- /dev/null +++ b/nix/cells/repo/home-modules/default.nix @@ -0,0 +1,250 @@ +# This is an interface for home-profiles and should not contain opinionated +# configurations. It should provide alternative configurations, aggregates +# or new configurations +_imports@{ inputs, cell }: +let + namespace = "repo"; + imports = _imports // { inherit namespace; }; +in +{ + git = { config, lib, ... }: + let + cfg = config."${namespace}".git; + baseAliases = { + a = "add"; + c = "commit"; + ca = "commit --amend"; + cm = "commit -m"; + lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; + lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; + sts = "status"; + co = "checkout"; + b = "branch"; + }; + default-user = "Pegasust"; + default-email = "pegasucksgg@gmail.com"; + in + { + options."${namespace}".git = { + aliases = lib.mkOption { + type = lib.types.attrs; + default = { }; + example = baseAliases; + description = '' + Additional git aliases. This settings comes with base configuration. + Redeclaring the base config will override the values. + ''; # TODO: Add baseAliases as string here (builtins.toString doesn't work) + }; + name = lib.mkOption { + type = lib.types.str; + default = default-user; + description = "Git username that appears on commits"; + example = default-user; + }; + email = lib.mkOption { + type = lib.types.str; + default = default-email; + example = default-email; + description = "Git email that appears on commits"; + }; + ignores = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + ".vscode" # vscode settings + ".direnv" # .envrc cached outputs + ".DS_Store" # MacOS users, amrite + ]; + description = '' + .gitignore patterns that are applied in every "${namespace}"sitory. + This is useful for IDE-specific settings. + ''; + example = [ ".direnv" "node_modules" ]; + }; + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Enables git + ''; + example = false; + }; + credentialCacheTimeoutSeconds = lib.mkOption { + type = lib.types.int; + default = 3000; + description = "Credential cache (in-memory store) for Git in seconds."; + example = 3000; + }; + }; + # TODO : anyway to override configuration? + # idk wtf I was thinking about. there is no context in this question + config.programs.git = { + inherit (cfg) enable ignores; + userName = cfg.name; + userEmail = cfg.email; + aliases = baseAliases // cfg.aliases; + extraConfig = { + # TODO: in the case of darwin, git always open up the built-in keychain. + # possibly something we can't really control since we don't have access to `nix-darwin` + credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}"; + }; + lfs.enable = true; + }; + }; + + alacritty = { config, lib, ... }: + let + inherit (inputs.cells.repo.lib) fromYAML; + cfg = config."${namespace}".alacritty; + in + { + options."${namespace}".alacritty = { + font.family = lib.mkOption { + type = lib.types.nullOr lib.types.singleLineStr; + default = null; + description = '' + The font family for Alacritty + ''; + example = "DroidSansMono NF"; + }; + font.size = lib.mkOption { + type = lib.types.nullOr lib.types.number; + default = 11.0; + description = '' + The default font size for Alacritty. This is probably measured in px. + ''; + example = 7.0; + }; + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Enables alacritty + ''; + example = true; + }; + config-path = lib.mkOption { + type = lib.types.path; + description = "Path to alacritty yaml"; + default = null; + example = "./config/alacritty.yaml"; + }; + }; + config.programs.alacritty = { + enable = cfg.enable; + settings = + let + actualConfig = + if cfg.config-path != null then fromYAML (builtins.readFile cfg.config-path) else { }; + in + lib.recursiveUpdate actualConfig { + font.normal.family = lib.mkIf (cfg.font.family != null) cfg.font.family; + font.size = lib.mkIf (cfg.font.size != null) cfg.font.size; + }; + }; + }; + + # TODO: chromium is not really supported on darwin + private_chromium = { config, pkgs, lib, ... }: + let + cfg = config."${namespace}".private_chromium; + in + { + options."${namespace}".private_chromium = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + example = false; + description = '' + Enable extremely lightweight chromium with vimium plugin + ''; + }; + }; + config = lib.mkIf (cfg.enable) { + # home.packages = [pkgs.ungoogled-chromium]; + programs.chromium = { + enable = true; + package = pkgs.ungoogled-chromium; + extensions = + let + # TODO: how about a chrome extension registry? + mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }: + { + inherit id; + crxPath = builtins.fetchurl { + url = "https://clients2.google.com/service/update2/crx" + + "?response=redirect" + + "&acceptformat=crx2,crx3" + + "&prodversion=${browserVersion}" + + "&x=id%3D${id}%26installsource%3Dondemand%26uc"; + name = "${id}.crx"; + inherit sha256; + }; + version = extVersion; + }; + mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version); + in + [ + # vimium + (mkChromiumExt { + id = "dbepggeogbaibhgnhhndojpepiihcmeb"; + sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic"; + extVersion = "1.67.4"; + }) + ]; + }; + }; + }; + + darwin-spotlight = { lib, pkgs, config, ... }: { + # This patch exists since Darwin's search bar requires solid apps and not + # symlinked + # TODO: QA + # - [x] works for base case + # - [x] works for repeated case + # - [ ] works after base case, then removed + # - [ ] works for repeated case, then removed + + # Copy GUI apps to "~/Applications/Home Manager Apps" + # Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334 + home.activation.patch-spotlight = + if pkgs.stdenv.isDarwin then + let + apps = pkgs.buildEnv { + name = "home-manager-applications"; + paths = config.home.packages; + pathsToLink = "/Applications"; + }; + in + lib.hm.dag.entryAfter [ "linkGeneration" ] '' + # Install MacOS applications to the user environment. + HM_APPS="$HOME/Applications/Home Manager Apps" + # Reset current state + if [ -e "$HM_APPS" ]; then + $DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)" + fi + $DRY_RUN_CMD mkdir -p "$HM_APPS" + # .app dirs need to be actual directories for Finder to detect them as Apps. + # In the env of Apps we build, the .apps are symlinks. We pass all of them as + # arguments to cp and make it dereference those using -H + $DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS" + $DRY_RUN_CMD chmod +w -R "$HM_APPS" + '' + else + ""; + # We need this in case upstream home-manager changes the behavior of linking + # applications + home.activation.remove-patch-spotlight = + if pkgs.stdenv.isDarwin then + lib.hm.dag.entryBefore [ "checkLinkTargets" ] '' + HM_APPS="$HOME/Applications/Home Manager Apps" + # Reset current state + if [ -e "$HM_APPS" ]; then + $DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)" + fi + '' + else + ""; + }; + +} + diff --git a/nix/cells/repo/home-modules/nixgl.nix b/nix/cells/repo/home-modules/nixgl.nix new file mode 100644 index 0000000..38162fd --- /dev/null +++ b/nix/cells/repo/home-modules/nixgl.nix @@ -0,0 +1,47 @@ +{ + inputs, + cell, + namespace, +}: { + pkgs, + config, + lib, + ... +}: let + cfg = config."${namespace}".graphics; + cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null); + types = lib.types; +in { + imports = [./shells.nix]; + options."${namespace}".nixgl = { + enable = lib.mkEnableOption "nixgl"; + useNixGL = { + package = lib.mkPackageOption pkgs "nixGL package" { + default = [ + "nixgl" + "auto" + "nixGLDefault" + ]; + }; + defaultPackage = lib.mkOption { + type = types.nullOr (types.enum ["nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee"]); + description = "Which nixGL package to be aliased as `nixGL` on the shell"; + default = null; + example = "nixGLIntel"; + }; + }; + }; + # NOTE: importing shells does not mean we're enabling everything, if we do mkDefault false + # but the dilemma is, if the user import BOTH graphics.nix and shells.nix + # they will also need to do `config."${namespace}".shells.enable` + # generally, we want the behavior: import means enable + config = lib.mkIf cfgEnable { + "${namespace}".graphics._enable = lib.mkForce true; + "${namespace}".shells = { + shellAliases = lib.mkIf (cfg.useNixGL.defaultPackage != null) { + nixGL = cfg.useNixGL.defaultPackage; + }; + }; + home.packages = [cfg.useNixGL.package]; + }; +} diff --git a/nix/cells/repo/home-profiles/default.nix b/nix/cells/repo/home-profiles/default.nix new file mode 100644 index 0000000..3092407 --- /dev/null +++ b/nix/cells/repo/home-profiles/default.nix @@ -0,0 +1,200 @@ +# This creates a layer that is specific to some profiles, but may require +# some variants in environment like username/email, work-oriented or personal +# and many more +_imports @ { + inputs, + cell, +}: let + # TODO: I don't think abstracting namespace away is a good idea in this case + namespace = "repo"; + imports = _imports // {inherit namespace;}; + inherit (cell) home-modules; +in { + neovim = import ./neovim.nix imports; + nerd_font_module = { + config, + pkgs, + ... + }: { + config.fonts.fontconfig.enable = true; + config.home.packages = [ + (pkgs.nerdfonts.override {fonts = ["Hack"];}) + ]; + config."${namespace}".alacritty.font.family = "Hack Nerd Font Mono"; + }; + + secrets = { + age.secrets.s3fs = { + file = "${inputs.self}/secrets/s3fs.age"; + # mode = "600"; # owner + group only + # owner = "hungtr"; + # group = "users"; + }; + age.secrets."s3fs.digital-garden" = { + file = "${inputs.self}/secrets/s3fs.digital-garden.age"; + }; + age.secrets._nhitrl_cred = { + file = "${inputs.self}/secrets/_nhitrl.age"; + }; + age.secrets."wifi.env" = { + file = "${inputs.self}/secrets/wifi.env.age"; + }; + }; + + ssh = { + config, + lib, + ... + }: let + cfg = config."${namespace}".ssh; + in { + options."${namespace}".ssh.enable = lib.mkOption { + type = lib.types.bool; + default = true; + example = false; + description = '' + Enables SSH + ''; + }; + config.programs.ssh = { + inherit (cfg) enable; + forwardAgent = true; + includes = ["${inputs.self}/native_configs/ssh/config"]; + }; + }; + + alacritty = { + config, + lib, + ... + }: let + cfg = config."${namespace}".alacritty; + in { + imports = [ + inputs.cells.repo.home-modules.alacritty + ]; + config."${namespace}".alacritty = { + enable = true; + config-path = "${inputs.self}//native_configs/alacritty/alacritty.yml"; + font.size = 11.0; + font.family = "Hack Nerd Font Mono"; + }; + }; + + shells = import ./shells.nix imports; + + git = { + config, + pkgs, + lib, + ... + }: let + baseAliases = { + a = "add"; + c = "commit"; + ca = "commit --amend"; + cm = "commit -m"; + lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; + lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; + sts = "status"; + co = "checkout"; + b = "branch"; + }; + cfg = config."${namespace}".profile.git; + in { + imports = [ + home-modules.git + ]; + options."${namespace}".profile.git = { + aliases = lib.mkOption { + type = lib.types.attrs; + default = {}; + example = baseAliases; + description = '' + Additional git aliases. This config is merged on top of base aliases. + ''; + }; + name = lib.mkOption { + type = lib.types.str; + default = "Pegasust"; + description = "Git username that appears on commits"; + example = "Pegasust"; + }; + email = lib.mkOption { + type = lib.types.str; + default = "pegasucksgg@gmail.com"; + example = "peagsucksgg@gmail.com"; + description = "Git email that appears on commits"; + }; + ignores = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + ".vscode" # vscode settings + ".direnv" # .envrc cached outputs + ".DS_Store" # MacOS users, amrite + ]; + description = '' + .gitignore patterns that are applied in every repository. + This is useful for IDE-specific or environment-specific settings. + ''; + example = [".direnv" "node_modules"]; + }; + }; + # WARNING: This should be completed wtf + config."${namespace}".git = { + inherit (cfg) name email ignores aliases; + enable = true; + }; + }; + + git-htran = { + imports = [inputs.cells.repo.home-profiles.git]; + config."${namespace}".profile.git = { + name = "htran"; + email = "htran@egihosting.com"; + }; + }; + + git-pegasust = { + imports = [inputs.cells.repo.home-profiles.git]; + config."${namespace}".profile.git = { + email = "pegasucksgg@gmail.com"; + name = "pegasust"; + }; + }; + + dev-packages = let pkgs = inputs.nixpkgs; in { + programs.jq.enable = true; + home.packages = [ + pkgs.htop + pkgs.ripgrep + pkgs.unzip + pkgs.zip + + pkgs.yq-go + pkgs.mosh + pkgs.python310 + ]; + }; + + # Local nixpkgs search and fallback if command not found to search from nixpkgs + nix-index = { + imports = [ + inputs.nix-index-database.hmModules.nix-index + ]; + config.programs.nix-index = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + }; + }; + + # digital garden stack + zk = { + config.xdg.configFile."zk/config.toml".source = "${inputs.self}/native_configs/zk/config.toml"; + # NB: this is done with lib.mkMerge + config.home.packages = [ + inputs.nixpkgs.zk + ]; + }; +} diff --git a/nix/cells/repo/home-profiles/neovim.nix b/nix/cells/repo/home-profiles/neovim.nix new file mode 100644 index 0000000..16f9c91 --- /dev/null +++ b/nix/cells/repo/home-profiles/neovim.nix @@ -0,0 +1,178 @@ +# TODO: vim-plug and Mason supports laziness. Probably worth it to explore incremental dependencies based on the project TODO: just install these things, then symlink to mason's bin directory +# +# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop` +# might be different from `home-manager`'s (~/.nix_profile/bin/jq) +{ + inputs, + cell, + namespace, +}: { + pkgs, + lib, + config, + ... +}: let + # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace + # and is added to the path after wrapping. + # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` + # see: :/--suffix.*PATH + # there should be mentions of additional packages + my_neovim = pkgs.neovim-unwrapped; + inherit (inputs.nixpkgs) system; + nvim_pkgs = + [ + # pkgs.gccStdenv + pkgs.tree-sitter + pkgs.fzf # file name fuzzy search + pkgs.ripgrep # content fuzzy search + pkgs.zk # Zettelkasten (limited support) + pkgs.fd # Required by a Telescope plugin (?) + pkgs.stdenv.cc.cc.lib + pkgs.nil # oxalica's better nix language server + inputs.nix-boost.packages."${system}".rust4cargo + pkgs.nickel + pkgs.nls + + pkgs.go # doesn't work, Mason installs from runtime path + + # Language-specific stuffs + pkgs.sumneko-lua-language-server + # pkgs.python3Packages.python-lsp-server + pkgs.nodePackages.pyright + pkgs.python3Packages.pylint + pkgs.python3Packages.flake8 + # FIXME: installing ansible from here just doesn't work :/ + # pkgs.ansible-lint + # pkgs.python38Packages.ansible + # pkgs.ansible-language-server + # TODO: the devShell should provide rust-analyzer so that + # cargo test builds binaries compatible with rust-analyzer + + # pkgs.rust-analyzer + # rust_pkgs + # pkgs.evcxr # Rust REPL for Conjure! + ] + ++ lib.optionals (pkgs.stdenv.isDarwin) ( + let + inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; + in [ + System + CoreFoundation + ] + ); +in { + options.base.neovim = { + enable = lib.mkOption { + default = true; + description = "enable personalized neovim as default editor"; + type = lib.types.bool; + example = false; + }; + }; + config = lib.mkIf config.base.neovim.enable { + # home-manager + programs.neovim = { + enable = true; + package = my_neovim; + viAlias = true; + vimAlias = true; + withPython3 = true; + withNodeJs = true; + # NOTE: this adds path to the wrapped version of neovim + extraPackages = nvim_pkgs; + extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua"; + plugins = let + inherit + (inputs.nixpkgs-latest.legacyPackages.${system}.vimPlugins) + plenary-nvim + nvim-treesitter + nvim-treesitter-textobjects + nvim-treesitter-context + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + nvim-lspconfig + gruvbox-community + neodev-nvim + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + fidget-nvim + rust-tools-nvim + cmp_luasnip + gitsigns-nvim + indent-blankline-nvim + lualine-nvim + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + ; + in [ + plenary-nvim + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + nvim-lspconfig + gruvbox-community + neodev-nvim + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + nvim-treesitter-context + fidget-nvim + rust-tools-nvim + + cmp_luasnip + gitsigns-nvim + indent-blankline-nvim + lualine-nvim + mason-lspconfig-nvim + mason-nvim + neogit + nlua-nvim + nvim-jqx + nvim-surround + nvim-web-devicons + playground + todo-comments-nvim + trouble-nvim + vim-dispatch + vim-dispatch-neovim + vim-fugitive + vim-jack-in + ]; + }; + # home.packages = nvim_pkgs; + }; +} diff --git a/nix/cells/repo/home-profiles/shells.nix b/nix/cells/repo/home-profiles/shells.nix new file mode 100644 index 0000000..dd06096 --- /dev/null +++ b/nix/cells/repo/home-profiles/shells.nix @@ -0,0 +1,133 @@ +{ + inputs, + cell, + namespace, +}: { + config, + lib, + pkgs, + ... +}: let + cfg = config."${namespace}".shells; +in { + options."${namespace}".shells = { + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable umbrella shell configuration"; + default = true; + example = false; + }; + shellInitExtra = lib.mkOption { + type = lib.types.str; + description = "Extra shell init. The syntax should be sh-compliant"; + default = ""; + example = '' + # X11 support for WSL + export DISPLAY=$(ip route list default | awk '{print $3}'):0 + export LIBGL_ALWAYS_INDIRECT=1 + ''; + }; + shellAliases = lib.mkOption { + type = lib.types.attrs; + description = "Shell command aliases"; + default = {}; + example = { + nixGL = "nixGLIntel"; + }; + }; + }; + config = lib.mkIf cfg.enable { + # nix: Propagates the environment with packages and vars when enter (children of) + # a directory with shell.nix-compatible and .envrc + programs.direnv = { + enable = true; + nix-direnv.enable = true; + # nix-direnv.enableFlakes = true; # must remove. this will always be supported. + }; + # z as smarter cd + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; + programs.tmux = { + enable = true; + plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed]; + extraConfig = builtins.readFile "${inputs.self}/native_configs/tmux/tmux.conf"; + }; + xdg.configFile."tmux/tmux.conf".text = lib.mkOrder 600 '' + set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M ' + ''; + # Colored ls + programs.exa = { + enable = true; + enableAliases = true; + }; + # Make the shell look beautiful + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = let + native = builtins.fromTOML (builtins.readFile "${inputs.self}/native_configs/starship/starship.toml"); + patch-nix = pkgs.lib.recursiveUpdate native { + # WARNING: home-manager fails on here for some reason. Likely not at the + # validation phase (type-checking), but at evaluation phaase (stringify) + # I'm thinking when `settings` are evaluated, it has some sort of + # recursive processing before it gets turned into a toml + # c.commands = [ + # ["nix" "run" "nixpkgs#clang" "--" "--version"] + # ["nix" "run" "nixpkgs#gcc" "--" "--version"] + # ]; + c.disabled = true; + }; + in + patch-nix; + }; + # Fuzzy finder. `fzf` for TUI, `fzf -f ''` for UNIX piping + programs.fzf.enable = true; + programs.bash = { + enable = true; + enableCompletion = true; + initExtra = cfg.shellInitExtra or ""; + }; + programs.zsh = { + enable = true; + enableCompletion = true; + enableAutosuggestions = true; + shellAliases = + { + nix-rebuild = "sudo nixos-rebuild switch"; + hm-switch = "home-manager switch --flake"; + } + // (cfg.shellAliases or {}); + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/history"; + }; + oh-my-zsh = { + enable = true; + plugins = [ + "git" # git command aliases: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git#aliases + "command-not-found" # suggests which package to install; does not support nixos (we have solution already) + "gitignore" # `gi list` -> `gi java >>.gitignore` + "ripgrep" # adds completion for `rg` + "rust" # compe for rustc/cargo + "poetry" # compe for poetry - Python's cargo + ]; + }; + sessionVariables = { + # Vim mode on the terminal + # VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true; + # VI_MODE_SET_CURSOR = true; + # ZVM_VI_ESCAPE_BINDKEY = ""; + ZVM_READKEY_ENGINE = "$ZVM_READKEY_ENGINE_NEX"; + ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) + ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) + }; + initExtra = + (cfg.shellInitExtra or "") + + '' + source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh + ''; + }; + }; +} diff --git a/nix/cells/repo/lib/default.nix b/nix/cells/repo/lib/default.nix new file mode 100644 index 0000000..65c97f6 --- /dev/null +++ b/nix/cells/repo/lib/default.nix @@ -0,0 +1,16 @@ +{ inputs, cell }: +let + namespace = "repo"; # ignore: unused + + yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand + outputPath + { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; } + # run yq which outputs '.' (no filter) on file at yamlPath + # note that $out is passed onto the bash/sh script for execution + '' + echo "$yamlContent" | yq >$out + ''); +in +{ + fromYAML = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json")); +} diff --git a/nix/cells/repo/packages/default.nix b/nix/cells/repo/packages/default.nix new file mode 100644 index 0000000..a66539c --- /dev/null +++ b/nix/cells/repo/packages/default.nix @@ -0,0 +1,6 @@ +{ + inputs, + cell, +}: { + inherit (inputs.cells.dotfiles.packages) kpcli-py; +} diff --git a/nix/cells/repo/userShells.nix b/nix/cells/repo/userShells.nix new file mode 100644 index 0000000..660b472 --- /dev/null +++ b/nix/cells/repo/userShells.nix @@ -0,0 +1,7 @@ +{ + inputs, + cell, +}: { + htran = inputs.cells.dotfiles.devshells.default; + hungtran = inputs.cells.dotfiles.devshells.default; +} diff --git a/out-of-tree/flake-compat/default.nix b/out-of-tree/flake-compat/default.nix index c966c6d..d925572 100644 --- a/out-of-tree/flake-compat/default.nix +++ b/out-of-tree/flake-compat/default.nix @@ -4,182 +4,265 @@ # calls the flake's 'outputs' function. It then returns an attrset # containing 'defaultNix' (to be used in 'default.nix'), 'shellNix' # (to be used in 'shell.nix'). - -{ src, system ? builtins.currentSystem or "unknown-system" }: - -let - +{ + src, + system ? builtins.currentSystem or "unknown-system", +}: let lockFilePath = src + "/flake.lock"; lockFile = builtins.fromJSON (builtins.readFile lockFilePath); - fetchTree = - info: - if info.type == "github" then - { outPath = - fetchTarball - ({ url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); - rev = info.rev; - shortRev = builtins.substring 0 7 info.rev; + fetchTree = info: + if info.type == "github" + then { + outPath = + fetchTarball + ( + {url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}";} + // ( + if info ? narHash + then {sha256 = info.narHash;} + else {} + ) + ); + rev = info.rev; + shortRev = builtins.substring 0 7 info.rev; + lastModified = info.lastModified; + lastModifiedDate = formatSecondsSinceEpoch info.lastModified; + narHash = info.narHash; + } + else if info.type == "git" + then + { + outPath = + builtins.fetchGit + ( + {url = info.url;} + // ( + if info ? rev + then {inherit (info) rev;} + else {} + ) + // ( + if info ? ref + then {inherit (info) ref;} + else {} + ) + // ( + if info ? submodules + then {inherit (info) submodules;} + else {} + ) + ); lastModified = info.lastModified; lastModifiedDate = formatSecondsSinceEpoch info.lastModified; narHash = info.narHash; } - else if info.type == "git" then - { outPath = - builtins.fetchGit - ({ url = info.url; } - // (if info ? rev then { inherit (info) rev; } else {}) - // (if info ? ref then { inherit (info) ref; } else {}) - // (if info ? submodules then { inherit (info) submodules; } else {}) - ); - lastModified = info.lastModified; - lastModifiedDate = formatSecondsSinceEpoch info.lastModified; - narHash = info.narHash; - } // (if info ? rev then { - rev = info.rev; - shortRev = builtins.substring 0 7 info.rev; - } else { - }) - else if info.type == "path" then - { outPath = builtins.path { - path = if builtins.substring 0 1 info.path != "/" - then src + ("/" + info.path) # make this absolute path by prepending ./ + // ( + if info ? rev + then { + rev = info.rev; + shortRev = builtins.substring 0 7 info.rev; + } + else {} + ) + else if info.type == "path" + then { + outPath = builtins.path { + path = + if builtins.substring 0 1 info.path != "/" + then src + ("/" + info.path) # make this absolute path by prepending ./ else info.path; # it's already an absolute path }; - narHash = info.narHash; - } - else if info.type == "tarball" then - { outPath = - fetchTarball - ({ inherit (info) url; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); - } - else if info.type == "gitlab" then - { inherit (info) rev narHash lastModified; - outPath = - fetchTarball - ({ url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; } - // (if info ? narHash then { sha256 = info.narHash; } else {}) - ); - shortRev = builtins.substring 0 7 info.rev; - } + narHash = info.narHash; + } + else if info.type == "tarball" + then { + outPath = + fetchTarball + ( + {inherit (info) url;} + // ( + if info ? narHash + then {sha256 = info.narHash;} + else {} + ) + ); + } + else if info.type == "gitlab" + then { + inherit (info) rev narHash lastModified; + outPath = + fetchTarball + ( + {url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}";} + // ( + if info ? narHash + then {sha256 = info.narHash;} + else {} + ) + ); + shortRev = builtins.substring 0 7 info.rev; + } else # FIXME: add Mercurial, tarball inputs. throw "flake input has unsupported input type '${info.type}'"; - callFlake4 = flakeSrc: locks: - let - flake = import (flakeSrc + "/flake.nix"); + callFlake4 = flakeSrc: locks: let + flake = import (flakeSrc + "/flake.nix"); - inputs = builtins.mapAttrs (n: v: + inputs = + builtins.mapAttrs + (n: v: if v.flake or true then callFlake4 (fetchTree (v.locked // v.info)) v.inputs - else fetchTree (v.locked // v.info)) locks; + else fetchTree (v.locked // v.info)) + locks; - outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;})); - in - assert flake.edition == 201909; - outputs; + outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;})); + in + assert flake.edition == 201909; outputs; - callLocklessFlake = flakeSrc: - let - flake = import (flakeSrc + "/flake.nix"); - outputs = flakeSrc // (flake.outputs ({ self = outputs; })); - in outputs; + callLocklessFlake = flakeSrc: let + flake = import (flakeSrc + "/flake.nix"); + outputs = flakeSrc // (flake.outputs {self = outputs;}); + in + outputs; rootSrc = let # Try to clean the source tree by using fetchGit, if this source # tree is a valid git repository. tryFetchGit = src: if isGit && !isShallow - then - let res = builtins.fetchGit src; - in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res - else { outPath = src; }; + then let + res = builtins.fetchGit src; + in + if res.rev == "0000000000000000000000000000000000000000" + then removeAttrs res ["rev" "shortRev"] + else res + else {outPath = src;}; # NB git worktrees have a file for .git, so we don't check the type of .git isGit = builtins.pathExists (src + "/.git"); isShallow = builtins.pathExists (src + "/.git/shallow"); - in - { lastModified = 0; lastModifiedDate = formatSecondsSinceEpoch 0; } - // (if src ? outPath then src else tryFetchGit src); + { + lastModified = 0; + lastModifiedDate = formatSecondsSinceEpoch 0; + } + // ( + if src ? outPath + then src + else tryFetchGit src + ); # Format number of seconds in the Unix epoch as %Y%m%d%H%M%S. - formatSecondsSinceEpoch = t: - let - rem = x: y: x - x / y * y; - days = t / 86400; - secondsInDay = rem t 86400; - hours = secondsInDay / 3600; - minutes = (rem secondsInDay 3600) / 60; - seconds = rem t 60; + formatSecondsSinceEpoch = t: let + rem = x: y: x - x / y * y; + days = t / 86400; + secondsInDay = rem t 86400; + hours = secondsInDay / 3600; + minutes = (rem secondsInDay 3600) / 60; + seconds = rem t 60; - # Courtesy of https://stackoverflow.com/a/32158604. - z = days + 719468; - era = (if z >= 0 then z else z - 146096) / 146097; - doe = z - era * 146097; - yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; - y = yoe + era * 400; - doy = doe - (365 * yoe + yoe / 4 - yoe / 100); - mp = (5 * doy + 2) / 153; - d = doy - (153 * mp + 2) / 5 + 1; - m = mp + (if mp < 10 then 3 else -9); - y' = y + (if m <= 2 then 1 else 0); + # Courtesy of https://stackoverflow.com/a/32158604. + z = days + 719468; + era = + ( + if z >= 0 + then z + else z - 146096 + ) + / 146097; + doe = z - era * 146097; + yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; + y = yoe + era * 400; + doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + mp = (5 * doy + 2) / 153; + d = doy - (153 * mp + 2) / 5 + 1; + m = + mp + + ( + if mp < 10 + then 3 + else -9 + ); + y' = + y + + ( + if m <= 2 + then 1 + else 0 + ); - pad = s: if builtins.stringLength s < 2 then "0" + s else s; - in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}"; + pad = s: + if builtins.stringLength s < 2 + then "0" + s + else s; + in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}"; allNodes = builtins.mapAttrs - (key: node: - let - sourceInfo = - if key == lockFile.root - then rootSrc - else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]); + ( + key: node: let + sourceInfo = + if key == lockFile.root + then rootSrc + else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]); - subdir = if key == lockFile.root then "" else node.locked.dir or ""; + subdir = + if key == lockFile.root + then "" + else node.locked.dir or ""; - flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix"); + flake = import (sourceInfo + + ( + if subdir != "" + then "/" + else "" + ) + + subdir + + "/flake.nix"); - inputs = builtins.mapAttrs - (inputName: inputSpec: allNodes.${resolveInput inputSpec}) - (node.inputs or {}); + inputs = + builtins.mapAttrs + (inputName: inputSpec: allNodes.${resolveInput inputSpec}) + (node.inputs or {}); - # Resolve a input spec into a node name. An input spec is - # either a node name, or a 'follows' path from the root - # node. - resolveInput = inputSpec: - if builtins.isList inputSpec - then getInputByPath lockFile.root inputSpec - else inputSpec; + # Resolve a input spec into a node name. An input spec is + # either a node name, or a 'follows' path from the root + # node. + resolveInput = inputSpec: + if builtins.isList inputSpec + then getInputByPath lockFile.root inputSpec + else inputSpec; - # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the - # root node, returning the final node. - getInputByPath = nodeName: path: - if path == [] - then nodeName - else - getInputByPath - # Since this could be a 'follows' input, call resolveInput. - (resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path}) - (builtins.tail path); - - outputs = flake.outputs (inputs // { self = result; }); - - result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; }; - in - if node.flake or true then - assert builtins.isFunction flake.outputs; - result + # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the + # root node, returning the final node. + getInputByPath = nodeName: path: + if path == [] + then nodeName else - sourceInfo - ) - lockFile.nodes; + getInputByPath + # Since this could be a 'follows' input, call resolveInput. + (resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path}) + (builtins.tail path); + + outputs = flake.outputs (inputs // {self = result;}); + + result = + outputs + // sourceInfo + // { + inherit inputs; + inherit outputs; + inherit sourceInfo; + }; + in + if node.flake or true + then assert builtins.isFunction flake.outputs; result + else sourceInfo + ) + lockFile.nodes; result = if !(builtins.pathExists lockFilePath) @@ -189,16 +272,30 @@ let else if lockFile.version >= 5 && lockFile.version <= 7 then allNodes.${lockFile.root} else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}"; +in rec { + defaultNix = + (builtins.removeAttrs result ["__functor"]) + // ( + if result ? defaultPackage.${system} + then {default = result.defaultPackage.${system};} + else {} + ) + // ( + if result ? packages.${system}.default + then {default = result.packages.${system}.default;} + else {} + ); -in - rec { - defaultNix = - (builtins.removeAttrs result ["__functor"]) - // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) - // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {}); - - shellNix = - defaultNix - // (if result ? devShell.${system} then { default = result.devShell.${system}; } else {}) - // (if result ? devShells.${system}.default then { default = result.devShells.${system}.default; } else {}); - } + shellNix = + defaultNix + // ( + if result ? devShell.${system} + then {default = result.devShell.${system};} + else {} + ) + // ( + if result ? devShells.${system}.default + then {default = result.devShells.${system}.default;} + else {} + ); +} diff --git a/out-of-tree/nixGL/all.nix b/out-of-tree/nixGL/all.nix index 20d1862..e6b729d 100644 --- a/out-of-tree/nixGL/all.nix +++ b/out-of-tree/nixGL/all.nix @@ -1,25 +1,25 @@ let - pkgs = import ./nixpkgs.nix { config = { allowUnfree = true; }; }; + pkgs = import ./nixpkgs.nix {config = {allowUnfree = true;};}; pure = pkgs.recurseIntoAttrs (pkgs.callPackage ./nixGL.nix { nvidiaVersion = "440.82"; nvidiaHash = "edd415acf2f75a659e0f3b4f27c1fab770cf21614e84a18152d94f0d004a758e"; }); - versionFile440 = (pkgs.callPackage ./nixGL.nix { + versionFile440 = pkgs.callPackage ./nixGL.nix { nvidiaVersionFile = pkgs.writeText "nvidia-version-440.82" '' NVRM version: NVIDIA UNIX x86_64 Kernel Module 440.82 Wed Apr 1 20:04:33 UTC 2020 GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1) ''; - }); + }; - versionFile510 = (pkgs.callPackage ./nixGL.nix { + versionFile510 = pkgs.callPackage ./nixGL.nix { nvidiaVersionFile = pkgs.writeText "nvidia-version-510.54" '' NVRM version: NVIDIA UNIX x86_64 Kernel Module 510.54 Wed Apr 1 20:04:33 UTC 2020 GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1) ''; - }); + }; in -(with pure; [ nixGLIntel nixVulkanNvidia nixGLNvidia nixVulkanIntel ]) -++ (with versionFile440.auto; [ nixGLNvidia nixGLDefault nixVulkanNvidia ]) -++ (with versionFile510.auto; [ nixGLNvidia nixGLDefault nixVulkanNvidia ]) + (with pure; [nixGLIntel nixVulkanNvidia nixGLNvidia nixVulkanIntel]) + ++ (with versionFile440.auto; [nixGLNvidia nixGLDefault nixVulkanNvidia]) + ++ (with versionFile510.auto; [nixGLNvidia nixGLDefault nixVulkanNvidia]) diff --git a/out-of-tree/nixGL/default.nix b/out-of-tree/nixGL/default.nix index 3419421..576e843 100644 --- a/out-of-tree/nixGL/default.nix +++ b/out-of-tree/nixGL/default.nix @@ -1,36 +1,41 @@ { ## Nvidia informations. # Version of the system kernel module. Let it to null to enable auto-detection. - nvidiaVersion ? null -, # Hash of the Nvidia driver .run file. null is fine, but fixing a value here + nvidiaVersion ? null, + # Hash of the Nvidia driver .run file. null is fine, but fixing a value here # will be more reproducible and more efficient. - nvidiaHash ? null -, # Alternatively, you can pass a path that points to a nvidia version file + nvidiaHash ? null, + # Alternatively, you can pass a path that points to a nvidia version file # and let nixGL extract the version from it. That file must be a copy of # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # https://github.com/NixOS/nix/issues/3539 ). - nvidiaVersionFile ? null -, # Enable 32 bits driver + nvidiaVersionFile ? null, + # Enable 32 bits driver # This is on by default, you can switch it to off if you want to reduce a # bit the size of nixGL closure. - enable32bits ? true -, # Make sure to enable config.allowUnfree to the instance of nixpkgs to be + enable32bits ? true, + # Make sure to enable config.allowUnfree to the instance of nixpkgs to be # able to access the nvidia drivers. - pkgs ? import { - config = { allowUnfree = true; }; - } -, # Enable all Intel specific extensions which only works on x86_64 - enableIntelX86Extensions ? true + pkgs ? + import { + config = {allowUnfree = true;}; + }, + # Enable all Intel specific extensions which only works on x86_64 + enableIntelX86Extensions ? true, }: pkgs.callPackage ./nixGL.nix ({ - inherit - nvidiaVersion - nvidiaVersionFile - nvidiaHash - enable32bits - ; -} // (if enableIntelX86Extensions then { } -else { - intel-media-driver = null; - vaapiIntel = null; -})) + inherit + nvidiaVersion + nvidiaVersionFile + nvidiaHash + enable32bits + ; + } + // ( + if enableIntelX86Extensions + then {} + else { + intel-media-driver = null; + vaapiIntel = null; + } + )) diff --git a/out-of-tree/nixGL/fetch.py b/out-of-tree/nixGL/fetch.py index 11d0e3e..688a64e 100755 --- a/out-of-tree/nixGL/fetch.py +++ b/out-of-tree/nixGL/fetch.py @@ -1,65 +1,81 @@ #!/usr/bin/env python3 -import urllib3 +# execution: fetch.py >nvidia_versions.json + +import http.client import json +import sys -http = urllib3.PoolManager() -dl_dir = http.request("GET", "https://download.nvidia.com/XFree86/Linux-x86_64/") +NV_FREE_X86_URL = "download.nvidia.com" +POTENTIAL_SHA256_EXTS = [".sha256sum", ".sha256"] +RIGHT_PAD = " " * 20 -# print(f"{dl_dir.status=}\n{dl_dir.data=}") +conn = http.client.HTTPSConnection(NV_FREE_X86_URL) +conn.request("GET", "/XFree86/Linux-x86_64/") +response = conn.getresponse() +dir_html = response.read() -assert (dl_dir.status < 400), "Error probably occurred" +assert (response.status < 400), "Error occurred fetching for source from" -def find_versions(dir_html: bytes) -> list[str]: - # this algorithm obviously need recursion because we need to discover the items - def _rec(dir_html: bytes, start: int = 0, so_far: list[str] = []) -> list[str]: +def scrape_driver_versions(dir_html: bytes): + # The idea is to recursively follows all interesting `src` from `` + def _rec(dir_html: bytes, href_url_start: int = 0, so_far: list[str] = []) -> list[str]: MATCH_START = b"= 400: - return err_fn(res.status) - return then_fn(res.data) + versions = _rec(dir_html, 0, []) + num_versions = len(versions) + for i, version in enumerate(versions): + print(f"[{i+1}/{num_versions}] Processing version {version}{RIGHT_PAD}", end="\r", file=sys.stderr) + yield version + print() -identity = lambda e: e -none_id = lambda _: None +versions = scrape_driver_versions(dir_html) -def get_sha256(version: str) -> str | None: - for url in sha256_urls(version): - res = http.request("GET", url) - # print(f"attempting: {url}") - if res.status < 400: - return res.data.decode().split()[0] +download_urls_of = lambda ver: [f"/XFree86/Linux-x86_64/{ver}/NVIDIA-Linux-x86_64-{ver}.run"] +sha256_urls_of = lambda ver: [ + f"{url}{dl_ext}" + for dl_ext in POTENTIAL_SHA256_EXTS + for url in download_urls_of(ver) +] + +def sha256_of(version: str) -> str | None: + if int(version.split(".")[0]) < 256: + # Has 3 different packages that we should probably not bother + return None + for url in sha256_urls_of(version): + conn = http.client.HTTPSConnection(NV_FREE_X86_URL) + conn.request("GET", url) + response = conn.getresponse() + if response.status < 400: + return response.read().decode().split()[0] + print(f"No sha256 for {version}{RIGHT_PAD}", file=sys.stderr) return None -fetch_data = [(v, download_urls(v)[0], get_sha256(v)) for v in versions] -fetch_data.append(("latest", *fetch_data[-1][1:])) -# print(fetch_data) +def fetch(version: str): + dl_url = download_urls_of(version)[0] + sha256 = sha256_of(version) + return (version, dl_url, sha256) + +fetch_data = [fetch(v) for v in versions] +fetch_data.append(("latest", *fetch_data[-1][1:])) # now print the JSON object print(json.dumps({ version: { - "url": dl_url, + "url": f"https://{NV_FREE_X86_URL}{dl_url}", "sha256": sha256 } for (version, dl_url, sha256) in fetch_data if sha256 is not None}, indent=4)) -# execution: fetch.py >nvidia_versions.json diff --git a/out-of-tree/nixGL/flake.nix b/out-of-tree/nixGL/flake.nix index bbb7c43..1e05255 100644 --- a/out-of-tree/nixGL/flake.nix +++ b/out-of-tree/nixGL/flake.nix @@ -4,44 +4,46 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "github:nixos/nixpkgs"; - outputs = { self, nixpkgs, flake-utils }: - (flake-utils.lib.eachDefaultSystem (system: - let - isIntelX86Platform = system == "x86_64-linux"; - nix_pkgs = import nixpkgs { inherit system; }; - pkgs = import ./default.nix { - pkgs = nix_pkgs; + outputs = { + self, + nixpkgs, + flake-utils, + }: + (flake-utils.lib.eachDefaultSystem (system: let + isIntelX86Platform = system == "x86_64-linux"; + nix_pkgs = import nixpkgs {inherit system;}; + pkgs = import ./default.nix { + pkgs = nix_pkgs; + enable32bits = isIntelX86Platform; + enableIntelX86Extensions = isIntelX86Platform; + }; + in rec { + packages = { + # makes it easy to use "nix run nixGL --impure -- program" + default = pkgs.auto.nixGLDefault; + + nixGLDefault = pkgs.auto.nixGLDefault; + nixGLNvidia = pkgs.auto.nixGLNvidia; + nixGLNvidiaBumblebee = pkgs.auto.nixGLNvidiaBumblebee; + nixGLIntel = pkgs.nixGLIntel; + nixVulkanNvidia = pkgs.auto.nixVulkanNvidia; + nixVulkanIntel = pkgs.nixVulkanIntel; + }; + + # deprecated attributes for retro compatibility + defaultPackage = packages; + })) + // rec { + # deprecated attributes for retro compatibility + overlay = overlays.default; + overlays.default = final: _: let + isIntelX86Platform = final.system == "x86_64-linux"; + in { + nixgl = import ./default.nix { + pkgs = final; enable32bits = isIntelX86Platform; enableIntelX86Extensions = isIntelX86Platform; }; - in - rec { - - packages = { - # makes it easy to use "nix run nixGL --impure -- program" - default = pkgs.auto.nixGLDefault; - - nixGLDefault = pkgs.auto.nixGLDefault; - nixGLNvidia = pkgs.auto.nixGLNvidia; - nixGLNvidiaBumblebee = pkgs.auto.nixGLNvidiaBumblebee; - nixGLIntel = pkgs.nixGLIntel; - nixVulkanNvidia = pkgs.auto.nixVulkanNvidia; - nixVulkanIntel = pkgs.nixVulkanIntel; - }; - - # deprecated attributes for retro compatibility - defaultPackage = packages; - })) // rec { - # deprecated attributes for retro compatibility - overlay = overlays.default; - overlays.default = final: _: - let isIntelX86Platform = final.system == "x86_64-linux"; - in { - nixgl = import ./default.nix { - pkgs = final; - enable32bits = isIntelX86Platform; - enableIntelX86Extensions = isIntelX86Platform; - }; - }; + }; }; } diff --git a/out-of-tree/nixGL/nixGL.nix b/out-of-tree/nixGL/nixGL.nix index fa74b0c..f1308fa 100644 --- a/out-of-tree/nixGL/nixGL.nix +++ b/out-of-tree/nixGL/nixGL.nix @@ -1,45 +1,46 @@ { # # Nvidia informations. # Version of the system kernel module. Let it to null to enable auto-detection. - nvidiaVersion ? null -, # Hash of the Nvidia driver .run file. null is fine, but fixing a value here + nvidiaVersion ? null, + # Hash of the Nvidia driver .run file. null is fine, but fixing a value here # will be more reproducible and more efficient. - nvidiaHash ? null -, # Alternatively, you can pass a path that points to a nvidia version file + nvidiaHash ? null, + # Alternatively, you can pass a path that points to a nvidia version file # and let nixGL extract the version from it. That file must be a copy of # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # https://github.com/NixOS/nix/issues/3539 ). - nvidiaVersionFile ? null -, # Enable 32 bits driver + nvidiaVersionFile ? null, + # Enable 32 bits driver # This is one by default, you can switch it to off if you want to reduce a # bit the size of nixGL closure. - enable32bits ? true -, writeTextFile -, shellcheck -, pcre -, runCommand -, linuxPackages -, fetchurl -, lib -, runtimeShell -, bumblebee -, libglvnd -, vulkan-validation-layers -, mesa -, libvdpau-va-gl -, intel-media-driver -, vaapiIntel -, pkgsi686Linux -, driversi686Linux -, zlib -, libdrm -, xorg -, wayland -, gcc -}: - -let - writeExecutable = { name, text }: + enable32bits ? true, + writeTextFile, + shellcheck, + pcre, + runCommand, + linuxPackages, + fetchurl, + lib, + runtimeShell, + bumblebee, + libglvnd, + vulkan-validation-layers, + mesa, + libvdpau-va-gl, + intel-media-driver, + vaapiIntel, + pkgsi686Linux, + driversi686Linux, + zlib, + libdrm, + xorg, + wayland, + gcc, +}: let + writeExecutable = { + name, + text, + }: writeTextFile { inherit name text; @@ -59,230 +60,234 @@ let fetch_db = builtins.fromJSON (builtins.readFile ./nvidia_versions.json); top = rec { /* - It contains the builder for different nvidia configuration, parametrized by - the version of the driver and sha256 sum of the driver installer file. + It contains the builder for different nvidia configuration, parametrized by + the version of the driver and sha256 sum of the driver installer file. */ - nvidiaPackages = { version, sha256 ? fetch_db."${version}".sha256 }: - let - nvidiaDrivers = (linuxPackages.nvidia_x11.override { }).overrideAttrs - (oldAttrs: { - pname = "nvidia"; - name = "nvidia-x11-${version}-nixGL"; - inherit version; - src = - let - url = - "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run"; - in - fetchurl { inherit url sha256; }; - useGLVND = true; - }); - nvidiaLibsOnly = nvidiaDrivers.override { - libsOnly = true; - kernel = null; - }; - nixNvidiaWrapper = api: - writeExecutable { - name = "nix${api}Nvidia-${version}"; - text = '' - #!${runtimeShell} - ${lib.optionalString (api == "Vulkan") - "export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d"} - NVIDIA_JSON=(${nvidiaLibsOnly}/share/glvnd/egl_vendor.d/*nvidia.json) - ${lib.optionalString enable32bits "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"} - - ${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${ - lib.optionalString enable32bits - '':''${NVIDIA_JSON32[*]}'' - }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"'' - } - - ${ - lib.optionalString (api == "Vulkan") - ''export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.json${ - lib.optionalString enable32bits - ":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.json" - }"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"'' - } - export LD_LIBRARY_PATH=${ - lib.makeLibraryPath ([ libglvnd nvidiaLibsOnly ] - ++ lib.optional (api == "Vulkan") vulkan-validation-layers - ++ lib.optionals enable32bits [ - nvidiaLibsOnly.lib32 - pkgsi686Linux.libglvnd - ]) - }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - exec "$@" - ''; - }; - in - { - inherit nvidiaDrivers nvidiaLibsOnly; - - nixGLNvidiaBumblebee = writeExecutable { - name = "nixGLNvidiaBumblebee-${version}"; + nvidiaPackages = { + version, + sha256 ? fetch_db."${version}".sha256, + }: let + nvidiaDrivers = + (linuxPackages.nvidia_x11.override {}).overrideAttrs + (oldAttrs: { + pname = "nvidia"; + name = "nvidia-x11-${version}-nixGL"; + inherit version; + src = let + url = "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run"; + in + fetchurl {inherit url sha256;}; + useGLVND = true; + }); + nvidiaLibsOnly = nvidiaDrivers.override { + libsOnly = true; + kernel = null; + }; + nixNvidiaWrapper = api: + writeExecutable { + name = "nix${api}Nvidia-${version}"; text = '' #!${runtimeShell} - export LD_LIBRARY_PATH=${ - lib.makeLibraryPath [ nvidiaDrivers ] - }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - ${ - bumblebee.override { - nvidia_x11 = nvidiaDrivers; - nvidia_x11_i686 = nvidiaDrivers.lib32; - } - }/bin/optirun --ldpath ${ - lib.makeLibraryPath ([ libglvnd nvidiaDrivers ] + ${lib.optionalString (api == "Vulkan") + "export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d"} + NVIDIA_JSON=(${nvidiaLibsOnly}/share/glvnd/egl_vendor.d/*nvidia.json) + ${lib.optionalString enable32bits "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"} + + ${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${ + lib.optionalString enable32bits + '':''${NVIDIA_JSON32[*]}'' + }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} + + ${ + lib.optionalString (api == "Vulkan") + ''export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.json${ + lib.optionalString enable32bits + ":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.json" + }"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"'' + } + export LD_LIBRARY_PATH=${ + lib.makeLibraryPath ([libglvnd nvidiaLibsOnly] + ++ lib.optional (api == "Vulkan") vulkan-validation-layers ++ lib.optionals enable32bits [ - nvidiaDrivers.lib32 + nvidiaLibsOnly.lib32 pkgsi686Linux.libglvnd ]) - } "$@" + }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + exec "$@" ''; }; + in { + inherit nvidiaDrivers nvidiaLibsOnly; - # TODO: 32bit version? Not tested. - inherit nixNvidiaWrapper; - - # TODO: 32bit version? Not tested. - nixGLNvidia = nixNvidiaWrapper "GL"; - - # TODO: 32bit version? Not tested. - nixVulkanNvidia = nixNvidiaWrapper "Vulkan"; + nixGLNvidiaBumblebee = writeExecutable { + name = "nixGLNvidiaBumblebee-${version}"; + text = '' + #!${runtimeShell} + export LD_LIBRARY_PATH=${ + lib.makeLibraryPath [nvidiaDrivers] + }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + ${ + bumblebee.override { + nvidia_x11 = nvidiaDrivers; + nvidia_x11_i686 = nvidiaDrivers.lib32; + } + }/bin/optirun --ldpath ${ + lib.makeLibraryPath ([libglvnd nvidiaDrivers] + ++ lib.optionals enable32bits [ + nvidiaDrivers.lib32 + pkgsi686Linux.libglvnd + ]) + } "$@" + ''; }; + # TODO: 32bit version? Not tested. + inherit nixNvidiaWrapper; + + # TODO: 32bit version? Not tested. + nixGLNvidia = nixNvidiaWrapper "GL"; + + # TODO: 32bit version? Not tested. + nixVulkanNvidia = nixNvidiaWrapper "Vulkan"; + }; + nixGLIntel = writeExecutable { name = "nixGLIntel"; # add the 32 bits drivers if needed - text = - let - mesa-drivers = [ mesa.drivers ] - ++ lib.optional enable32bits pkgsi686Linux.mesa.drivers; - intel-driver = [ intel-media-driver vaapiIntel ] - # Note: intel-media-driver is disabled for i686 until https://github.com/NixOS/nixpkgs/issues/140471 is fixed - ++ lib.optionals enable32bits [ /* pkgsi686Linux.intel-media-driver */ driversi686Linux.vaapiIntel ]; - libvdpau = [ libvdpau-va-gl ] - ++ lib.optional enable32bits pkgsi686Linux.libvdpau-va-gl; - glxindirect = runCommand "mesa_glxindirect" { } ( - '' - mkdir -p $out/lib - ln -s ${mesa.drivers}/lib/libGLX_mesa.so.0 $out/lib/libGLX_indirect.so.0 - '' - ); - in - '' - #!${runtimeShell} - export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers} - export LIBVA_DRIVERS_PATH=${lib.makeSearchPathOutput "out" "lib/dri" intel-driver} - ${''export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${ + text = let + mesa-drivers = + [mesa.drivers] + ++ lib.optional enable32bits pkgsi686Linux.mesa.drivers; + intel-driver = + [intel-media-driver vaapiIntel] + # Note: intel-media-driver is disabled for i686 until https://github.com/NixOS/nixpkgs/issues/140471 is fixed + ++ lib.optionals enable32bits [ + /* + pkgsi686Linux.intel-media-driver + */ + driversi686Linux.vaapiIntel + ]; + libvdpau = + [libvdpau-va-gl] + ++ lib.optional enable32bits pkgsi686Linux.libvdpau-va-gl; + glxindirect = runCommand "mesa_glxindirect" {} '' + mkdir -p $out/lib + ln -s ${mesa.drivers}/lib/libGLX_mesa.so.0 $out/lib/libGLX_indirect.so.0 + ''; + in '' + #!${runtimeShell} + export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers} + export LIBVA_DRIVERS_PATH=${lib.makeSearchPathOutput "out" "lib/dri" intel-driver} + ${''export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${ lib.optionalString enable32bits ":${pkgsi686Linux.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json" - }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"'' - } - export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau}:${glxindirect}/lib:${lib.makeLibraryPath [libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - exec "$@" - ''; + }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} + export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau}:${glxindirect}/lib:${lib.makeLibraryPath [libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + exec "$@" + ''; }; nixVulkanIntel = writeExecutable { name = "nixVulkanIntel"; - text = - let - # generate a file with the listing of all the icd files - icd = runCommand "mesa_icd" { } ( - # 64 bits icd - '' - ls ${mesa.drivers}/share/vulkan/icd.d/*.json > f - '' - # 32 bits ones - + lib.optionalString enable32bits '' - ls ${pkgsi686Linux.mesa.drivers}/share/vulkan/icd.d/*.json >> f - '' - # concat everything as a one line string with ":" as seperator - + ''cat f | xargs | sed "s/ /:/g" > $out'' - ); - in - '' - #!${runtimeShell} - if [ -n "$LD_LIBRARY_PATH" ]; then - echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2 - fi - export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d - ICDS=$(cat ${icd}) - export VK_ICD_FILENAMES=$ICDS"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}" - export LD_LIBRARY_PATH=${ - lib.makeLibraryPath [ - zlib - libdrm - xorg.libX11 - xorg.libxcb - xorg.libxshmfence - wayland - gcc.cc - ] - }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - exec "$@" - ''; + text = let + # generate a file with the listing of all the icd files + icd = runCommand "mesa_icd" {} ( + # 64 bits icd + '' + ls ${mesa.drivers}/share/vulkan/icd.d/*.json > f + '' + # 32 bits ones + + lib.optionalString enable32bits '' + ls ${pkgsi686Linux.mesa.drivers}/share/vulkan/icd.d/*.json >> f + '' + # concat everything as a one line string with ":" as seperator + + ''cat f | xargs | sed "s/ /:/g" > $out'' + ); + in '' + #!${runtimeShell} + if [ -n "$LD_LIBRARY_PATH" ]; then + echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2 + fi + export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d + ICDS=$(cat ${icd}) + export VK_ICD_FILENAMES=$ICDS"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}" + export LD_LIBRARY_PATH=${ + lib.makeLibraryPath [ + zlib + libdrm + xorg.libX11 + xorg.libxcb + xorg.libxshmfence + wayland + gcc.cc + ] + }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + exec "$@" + ''; }; nixGLCommon = nixGL: - runCommand "nixGL" { } '' + runCommand "nixGL" {} '' mkdir -p "$out/bin" # star because nixGLNvidia... have version prefixed name cp ${nixGL}/bin/* "$out/bin/nixGL"; ''; - auto = - let - _nvidiaVersionFile = - if nvidiaVersionFile != null then - nvidiaVersionFile - else + auto = let + _nvidiaVersionFile = + if nvidiaVersionFile != null + then nvidiaVersionFile + else # HACK: Get the version from /proc. It turns out that /proc is mounted # inside of the build sandbox and varies from machine to machine. # # builtins.readFile is not able to read /proc files. See # https://github.com/NixOS/nix/issues/3539. - runCommand "impure-nvidia-version-file" - { - # To avoid sharing the build result over time or between machine, - # Add an impure parameter to force the rebuild on each access. - # time = builtins.currentTime; - preferLocalBuild = true; - allowSubstitutes = false; - } "cp /proc/driver/nvidia/version $out 2> /dev/null || touch $out"; + runCommand "impure-nvidia-version-file" + { + # To avoid sharing the build result over time or between machine, + # Add an impure parameter to force the rebuild on each access. + # time = builtins.currentTime; + preferLocalBuild = true; + allowSubstitutes = false; + } "cp /proc/driver/nvidia/version $out 2> /dev/null || touch $out"; - # The nvidia version. Either fixed by the `nvidiaVersion` argument, or - # auto-detected. Auto-detection is impure. - nvidiaVersionAuto = - if nvidiaVersion != null then - nvidiaVersion - else + # The nvidia version. Either fixed by the `nvidiaVersion` argument, or + # auto-detected. Auto-detection is impure. + nvidiaVersionAuto = + if nvidiaVersion != null + then nvidiaVersion + else # Get if from the nvidiaVersionFile - let - data = builtins.readFile _nvidiaVersionFile; - versionMatch = builtins.match ".*Module ([0-9.]+) .*" data; - in - if versionMatch != null then builtins.head versionMatch else null; + let + data = builtins.readFile _nvidiaVersionFile; + versionMatch = builtins.match ".*Module ([0-9.]+) .*" data; + in + if versionMatch != null + then builtins.head versionMatch + else null; - autoNvidia = nvidiaPackages { version = nvidiaVersionAuto; }; - in + autoNvidia = nvidiaPackages {version = nvidiaVersionAuto;}; + in rec { # The output derivation contains nixGL which point either to # nixGLNvidia or nixGLIntel using an heuristic. nixGLDefault = - if nvidiaVersionAuto != null then - nixGLCommon autoNvidia.nixGLNvidia - else - nixGLCommon nixGLIntel; - } // autoNvidia; + if nvidiaVersionAuto != null + then nixGLCommon autoNvidia.nixGLNvidia + else nixGLCommon nixGLIntel; + } + // autoNvidia; }; in -top // (if nvidiaVersion != null then - top.nvidiaPackages - { - version = nvidiaVersion; - sha256 = nvidiaHash; - } -else - { }) + top + // ( + if nvidiaVersion != null + then + top.nvidiaPackages + { + version = nvidiaVersion; + sha256 = nvidiaHash; + } + else {} + ) diff --git a/out-of-tree/nixGL/nixpkgs.nix b/out-of-tree/nixGL/nixpkgs.nix index a4e1b5b..cb10cbb 100644 --- a/out-of-tree/nixGL/nixpkgs.nix +++ b/out-of-tree/nixGL/nixpkgs.nix @@ -1,7 +1,7 @@ let rev = "4f6d8095fd51"; in -import (fetchTarball { - url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; - sha256 = "14sm0bjjcmi9qmznwy3nkd2vbhj5xcshgm54a5wiprl9ssvxqw53"; -}) + import (fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; + sha256 = "14sm0bjjcmi9qmznwy3nkd2vbhj5xcshgm54a5wiprl9ssvxqw53"; + }) diff --git a/out-of-tree/nixGL/nvidia_versions.json b/out-of-tree/nixGL/nvidia_versions.json index 0241076..97de4f2 100644 --- a/out-of-tree/nixGL/nvidia_versions.json +++ b/out-of-tree/nixGL/nvidia_versions.json @@ -1,3 +1,4 @@ + { "256.25": { "url": "https://download.nvidia.com/XFree86/Linux-x86_64/256.25/NVIDIA-Linux-x86_64-256.25.run", @@ -539,6 +540,10 @@ "url": "https://download.nvidia.com/XFree86/Linux-x86_64/470.161.03/NVIDIA-Linux-x86_64-470.161.03.run", "sha256": "5da82a7f8c76e781e7d7f0be7b798db4d344f26bd4facf9abcf3c71c71fe7640" }, + "470.182.03": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/470.182.03/NVIDIA-Linux-x86_64-470.182.03.run", + "sha256": "3dbc1408fc48b865d3ddacefc45f4a3fc13b90b83a628ee546b0082ab2c3fc79" + }, "510.108.03": { "url": "https://download.nvidia.com/XFree86/Linux-x86_64/510.108.03/NVIDIA-Linux-x86_64-510.108.03.run", "sha256": "410a515e78df29c2cba4ac0b497889ce0ff1b04cfc711ff889e2dfc80f0da0d8" @@ -547,6 +552,10 @@ "url": "https://download.nvidia.com/XFree86/Linux-x86_64/515.86.01/NVIDIA-Linux-x86_64-515.86.01.run", "sha256": "141777e1ca2f11e97d8d33260213f1be327eb73922ae22f4ddab404bb2ef4664" }, + "515.105.01": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/515.105.01/NVIDIA-Linux-x86_64-515.105.01.run", + "sha256": "9dd2221f26c847c864dfe80cc8533f322c5f4dfaa2939cf54a934b8f7a2f6a0d" + }, "525.53": { "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.53/NVIDIA-Linux-x86_64-525.53.run", "sha256": "74bb0971f04f1dddd3c4641c891706fb96e8de52e22f6079e50de76d3a51687f" @@ -563,8 +572,28 @@ "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.78.01/NVIDIA-Linux-x86_64-525.78.01.run", "sha256": "43da42d2bf69bc37ea9c7c0fa02f52db0dcc483c272f52edacad89a5cb495a93" }, + "525.85.05": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.85.05/NVIDIA-Linux-x86_64-525.85.05.run", + "sha256": "ea63b4253403b224bb7313a8977a920dfe9d203d661dd5f6fc26585a70179140" + }, + "525.89.02": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.89.02/NVIDIA-Linux-x86_64-525.89.02.run", + "sha256": "0e412c88c5bd98f842a839a6f64614f20e4c0950ef7cffb12b158a71633593e9" + }, + "525.105.17": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.105.17/NVIDIA-Linux-x86_64-525.105.17.run", + "sha256": "c635a21a282c9b53485f19ebb64a0f4b536a968b94d4d97629e0bc547a58142a" + }, + "530.30.02": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.30.02/NVIDIA-Linux-x86_64-530.30.02.run", + "sha256": "47fddbbd7a22ba661923dbce6e7f51eec54df68050c406cc0490c3bfbede7963" + }, + "530.41.03": { + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.41.03/NVIDIA-Linux-x86_64-530.41.03.run", + "sha256": "ae27a16a968c85503f5d161dda343c1602612b025f4aee15f92e2ea0acb784b1" + }, "latest": { - "url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.78.01/NVIDIA-Linux-x86_64-525.78.01.run", - "sha256": "43da42d2bf69bc37ea9c7c0fa02f52db0dcc483c272f52edacad89a5cb495a93" + "url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.41.03/NVIDIA-Linux-x86_64-530.41.03.run", + "sha256": "ae27a16a968c85503f5d161dda343c1602612b025f4aee15f92e2ea0acb784b1" } } diff --git a/overlays.nix b/overlays.nix index 1c570ce..8b13789 100644 --- a/overlays.nix +++ b/overlays.nix @@ -1,46 +1 @@ -flake_input@{ kpcli-py -, nixgl -, rust-overlay -, neovim-nightly-overlay -, system -, ... -}: let - kpcli-py = (final: prev: { - # use python3.9, which works because of cython somehow? - kpcli-py = final.poetry2nix.mkPoetryApplication { - projectDir = flake_input.kpcli-py; - python = final.python39; - overrides = final.poetry2nix.defaultPoetryOverrides.extend (self: super: { - # tableformatter requires setuptools - tableformatter = super.tableformatter.overridePythonAttrs ( - old: { - buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools super.cython_3 ]; - } - ); - }); - }; - }); - - rust = (final: prev: - let - nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith ( - toolchain: (toolchain.minimal.override { - extensions = exts; - }) - ); - # https://rust-lang.github.io/rustup/concepts/profiles.html - rust-default-components = [ "rust-docs" "rustfmt" "clippy" ]; - rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ]; - in { - rust4devs = nightlyRustWithExts rust-dev-components; - rust4cargo = nightlyRustWithExts [ ]; - rust4normi = nightlyRustWithExts rust-default-components; - }); -in [ - nixgl.overlays.default - rust-overlay.overlays.default - neovim-nightly-overlay.overlay - rust - kpcli-py -] diff --git a/scripts/hm-switch.sh b/scripts/hm-switch.sh index b99a7ac..4e153bc 100755 --- a/scripts/hm-switch.sh +++ b/scripts/hm-switch.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh # NOTE: Untested on case of no home-manager -set -xv +set -xveu # Where this script located SCRIPT_DIR=$(readlink -f $(dirname $0)) echo "SCRIPT_DIR: ${SCRIPT_DIR}" @@ -8,26 +8,39 @@ echo "SCRIPT_DIR: ${SCRIPT_DIR}" HOME_MANAGER_DIR="${SCRIPT_DIR}/../nix-conf/home-manager" # Manage nix.conf. Ideally, this should be done with snapshot-based version -# and with preview on-the-spot, with some timeout +# and with preview on-the-spot, with some timeout (like deploy-rs) if [ -f /etc/nix/nix.conf ]; then # managed nix.conf BACKUP_FILE="/etc/nix/nix.conf.backup" echo "overwriting /etc/nix/nix.conf. Please find latest backup in ${BACKUP_FILE}" sudo cp /etc/nix/nix.conf ${BACKUP_FILE} - sudo cp "${HOME_MANAGER_DIR}/hwtr/nix.conf" /etc/nix/ fi +sudo cp "${HOME_MANAGER_DIR}/nix.conf" /etc/nix/ +sudo cp "${HOME_MANAGER_DIR}/${USER}/nix.conf" /etc/nix/ | echo "no nix.conf for ${USER}. Totally OK." +sudo cp "${SCRIPT_DIR}/upload-to-cache.sh" /etc/nix/ +sudo chmod +x /etc/nix/*.sh +# Reload nix daemon so that new changes are applied. +sudo launchctl stop org.nixos.nix-daemon +sudo launchctl start org.nixos.nix-daemon # Mason is bad: it puts binaries onto xdg.data # let's make mason starts fresh, just in case we introduce RPATH hacks # that injects binary for Mason to use. -rm -rf ~/.local/share/nvim/mason +sudo rm -rf ~/.local/share/nvim/mason +# NOTE: https://discourse.nixos.org/t/relative-path-support-for-nix-flakes/18795 +# nix flake update is required for relative paths to work +nix flake update +nix flake update "${SCRIPT_DIR}/../nix-conf/home-manager" # test if we have home-manager, if not, attempt to use nix to put home-manager to # our environment if ! command -v home-manager ; then - nix-shell -p home-manager --run "home-manager switch --flake $HOME_MANAGER_DIR $@" + nix-shell -p home-manager --run "home-manager switch -b backup --flake $HOME_MANAGER_DIR $@" else home-manager switch -b backup --flake "$HOME_MANAGER_DIR" $@ fi +# Attempt to reload running instances +tmux source-file ~/.config/tmux/tmux.conf + diff --git a/scripts/upload-to-cache.sh b/scripts/upload-to-cache.sh new file mode 100755 index 0000000..1567ea1 --- /dev/null +++ b/scripts/upload-to-cache.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +# set -eux +# set -f # disable globbing (/nix/store may contain glob chars) +# export IFS=' ' +# PATH=/nix/var/nix/profiles/default/bin:$PATH +# +# # $OUT_PATHS when invoked by nix.settings.post-build-hook will be +# # space-separated paths to /nix/store/ +# echo "Uploading paths" $OUT_PATHS +# nix copy --to "ssh-ng://10.100.200.230" $OUT_PATHS + diff --git a/scripts/vim_dsl.py b/scripts/vim_dsl.py new file mode 100755 index 0000000..3484181 --- /dev/null +++ b/scripts/vim_dsl.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 # A simple playground to explore vim plugins that are available in nixpkgs + +import csv +import urllib.request +from io import StringIO +import sqlite3 + +UPSTREAM_CSV = "https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vim/plugins/vim-plugin-names" + + +def load_csv(url): + with urllib.request.urlopen(url) as response: + data = response.read().decode() + return csv.DictReader(StringIO(data)) + + +class VimPlugins: + def __init__(self, url: str, sqlite: str = ":memory:"): + self.conn = sqlite3.connect(sqlite) + csv_data = load_csv(url) + fieldnames = csv_data.fieldnames or ["repo", "branch", "alias"] + + cur = self.create_table() + for row in csv_data: + fields = ", ".join(f'"{row[field]}"' for field in fieldnames) + cur.execute(f"INSERT INTO {self.table_name()} VALUES ({fields})") + + self.conn.commit() + + def create_table(self, cursor=None): + cur = self.conn.cursor() if not cursor else cursor + cur.execute(f''' + CREATE TABLE {self.table_name()} ( + "repo" TEXT, + "branch" TEXT, + "alias" TEXT + ); + ''') + return cur + + def table_name(self): + return "vim_plugins" + + def query(self, query: str): + return self.conn.cursor().execute(query).fetchall() + + +def vim_plugin_slug(name: str): + return name.replace(".", "-").lower() + + +def name_from_repo(repo: str): + spl = repo.split("/") + return vim_plugin_slug(spl[-1] or spl[-2]) + + +if __name__ == "__main__": + # REPL zone + vp = VimPlugins(UPSTREAM_CSV) + need_install_plugins = """ +tjdevries/nlua.nvim +yioneko/nvim-yati +nathanalderson/yang.vim +numToStr/Comment.nvim +lewis6991/gitsigns.nvim +tpope/vim-fugitive +williamboman/mason.nvim +williamboman/mason-lspconfig.nvim +TimUntersberger/neogit +folke/trouble.nvim +tpope/vim-dispatch +clojure-vim/vim-jack-in +radenling/vim-dispatch-neovim +gennaro-tedesco/nvim-jqx +kylechui/nvim-surround +simrat39/inlay-hints.nvim +gruvbox-community/gruvbox +nvim-lualine/lualine.nvim +lukas-reineke/indent-blankline.nvim +kyazdani42/nvim-web-devicons +m-demare/hlargs.nvim +folke/todo-comments.nvim +nvim-treesitter/playground +saadparwaiz1/cmp_luasnip +L3MON4D3/LuaSnip +arthurxavierx/vim-caser +~/local_repos/ts-ql + """.split() + need_install_plugins = [plugin.strip() for plugin in need_install_plugins if plugin.strip()] + + # Create the GitHub URL list + need_install_plugins_gh = [ + f"https://github.com/{plugin}/".lower() for plugin in need_install_plugins if not plugin.startswith(("~", "."))] + + # Get the values from the database + values = vp.query(f"SELECT LOWER(repo), alias from {vp.table_name()}") + + # Check if the repo is in the list of plugins + need_install = [ + vim_plugin_slug(alias) if alias else name_from_repo(repo) for repo, alias in values if repo in need_install_plugins_gh] + + print("need_install") + print("\n".join(need_install)) + + # Check if the repo is not in the list + repos = [repo for repo, _ in values] + not_in_repo = [name_from_repo(gh) for gh in need_install_plugins_gh if gh not in repos] + print("not in repo", not_in_repo) # nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community + + diff --git a/secrets.nix b/secrets.nix index 04e5d81..7b07703 100644 --- a/secrets.nix +++ b/secrets.nix @@ -1,22 +1,29 @@ +# WARNING: currently not usable anymore let - inherit ((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 = ./.; } - ).defaultNix) secrets; + inherit + (( + 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 = ./.;} + ) + .defaultNix) + secrets + ; inherit (secrets) pubKeys; inherit (pubKeys) users hosts; all = users // hosts; c_ = builtins; -in -{ - "secrets/s3fs.age".publicKeys = c_.attrValues (all); - "secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all); - "secrets/_nhitrl.age".publicKeys = c_.attrValues (all); - "secrets/wifi.env.age".publicKeys = c_.attrValues (all); +in { + "secrets/s3fs.age".publicKeys = c_.attrValues all; + "secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; + "secrets/_nhitrl.age".publicKeys = c_.attrValues all; + "secrets/wifi.env.age".publicKeys = c_.attrValues all; } diff --git a/secrets/default.nix b/secrets/default.nix index 0624482..6763449 100644 --- a/secrets/default.nix +++ b/secrets/default.nix @@ -1,6 +1,5 @@ # TODO: put ssh keys as user/host config -inputs: -let +inputs: let # user-specific (~/.ssh/id_ed25519.pub) users = { "hungtr@bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z"; @@ -12,9 +11,8 @@ let all = users // systems; # stands for calculus c_ = builtins; -in -{ - "system/secrets/s3fs.age".publicKeys = c_.attrValues (all); - "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all); - "system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all); +in { + "system/secrets/s3fs.age".publicKeys = c_.attrValues all; + "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; + "system/secrets/_nhitrl.age".publicKeys = c_.attrValues all; } diff --git a/shell.nix b/shell.nix index 0995f35..34ba877 100644 --- a/shell.nix +++ b/shell.nix @@ -1,11 +1,14 @@ # This uses the exported devShells from flake.nix # the default or base version of nix-shell can be found in dev-shell.nix instead # This architecture is because we use top-level flake.nix -(import +( + import ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in (import ./c_.nix {src = ./.;}).fetchTree lock.nodes.flake-compat.locked + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + (import ./c_.nix).fetchTree lock.nodes.flake-compat.locked ) - { src = ./.; } -).shellNix + {src = ./.;} +) +.shellNix diff --git a/templates/default.nix b/templates/default.nix index e16c790..c5b6e42 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -1,8 +1,9 @@ # TODO: templates should be able to have initial states like # repo name, author,... -{ pkgs -, lib -, ... +{ + pkgs, + lib, + ... }: { rust = { path = ./rust; diff --git a/templates/py-poetry/README.md b/templates/py-poetry/README.md index 2b1e13a..8d5e3da 100644 --- a/templates/py-poetry/README.md +++ b/templates/py-poetry/README.md @@ -23,6 +23,11 @@ poetry init ### Libraries worth integrating +- [pytest](https://github.com/pytest-dev/pytest) Testing framework for Python + +```sh +poetry add --group dev pytest +``` - [tophat/syrupy](https://github.com/tophat/syrupy) Snapshot testing plugin for (builtin) pytest ```sh diff --git a/templates/py-poetry/default.nix b/templates/py-poetry/default.nix index 89308a3..2346806 100644 --- a/templates/py-poetry/default.nix +++ b/templates/py-poetry/default.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).defaultNix + }) +.defaultNix diff --git a/templates/py-poetry/flake.nix b/templates/py-poetry/flake.nix index 4e454b9..1409639 100644 --- a/templates/py-poetry/flake.nix +++ b/templates/py-poetry/flake.nix @@ -1,24 +1,30 @@ { inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs }: - let - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); - in - { - packages = forAllSystems (system: { - default = pkgs.${system}.poetry2nix.mkPoetryApplication { projectDir = self; }; - }); + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); + in { + packages = forAllSystems (system: { + default = pkgs.${system}.poetry2nix.mkPoetryApplication {projectDir = self;}; + }); - devShells = forAllSystems (system: { - default = pkgs.${system}.mkShellNoCC { - packages = with pkgs.${system}; [ - (poetry2nix.mkPoetryEnv { projectDir = self; }) - poetry - ]; - }; - }); - }; + devShells = forAllSystems (system: { + bootstrap = pkgs.${system}.mkShellNoCC { + packages = [ + pkgs.${system}.poetry + ]; + }; + default = pkgs.${system}.mkShellNoCC { + packages = [ + (pkgs.${system}.poetry2nix.mkPoetryEnv {projectDir = self;}) + pkgs.${system}.poetry + ]; + }; + }); + }; } diff --git a/templates/py-poetry/shell.nix b/templates/py-poetry/shell.nix index 47458ad..3c038e9 100644 --- a/templates/py-poetry/shell.nix +++ b/templates/py-poetry/shell.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).shellNix + }) +.shellNix diff --git a/templates/rust-monorepo/default.nix b/templates/rust-monorepo/default.nix index 89308a3..2346806 100644 --- a/templates/rust-monorepo/default.nix +++ b/templates/rust-monorepo/default.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).defaultNix + }) +.defaultNix diff --git a/templates/rust-monorepo/flake.nix b/templates/rust-monorepo/flake.nix index a75001f..ec12b02 100644 --- a/templates/rust-monorepo/flake.nix +++ b/templates/rust-monorepo/flake.nix @@ -6,23 +6,29 @@ rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { self, nixpkgs, utils, naersk, rust-overlay }: - utils.lib.eachDefaultSystem (system: - let - overlays = [ rust-overlay.overlays.default ]; - pkgs = import nixpkgs { inherit system overlays; }; - rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith - ( - toolchain: + outputs = { + self, + nixpkgs, + utils, + naersk, + rust-overlay, + }: + utils.lib.eachDefaultSystem (system: let + overlays = [rust-overlay.overlays.default]; + pkgs = import nixpkgs {inherit system overlays;}; + rust_pkgs = + pkgs.rust-bin.selectLatestNightlyWith + ( + toolchain: toolchain.default.override { - extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ]; + extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"]; } - )); - naersk-lib = pkgs.callPackage naersk { }; - in - { - defaultPackage = naersk-lib.buildPackage ./.; - devShell = with pkgs; mkShell { + ); + naersk-lib = pkgs.callPackage naersk {}; + in { + defaultPackage = naersk-lib.buildPackage ./.; + devShell = with pkgs; + mkShell { buildInputs = [ rust_pkgs # rust's compiler is quite powerful enough to the point where @@ -37,5 +43,5 @@ # nix flake update # is this even needed? ''; }; - }); + }); } diff --git a/templates/rust-monorepo/shell.nix b/templates/rust-monorepo/shell.nix index 47458ad..3c038e9 100644 --- a/templates/rust-monorepo/shell.nix +++ b/templates/rust-monorepo/shell.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).shellNix + }) +.shellNix diff --git a/templates/rust/default.nix b/templates/rust/default.nix index 89308a3..2346806 100644 --- a/templates/rust/default.nix +++ b/templates/rust/default.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).defaultNix + }) +.defaultNix diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index a75001f..ec12b02 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -6,23 +6,29 @@ rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { self, nixpkgs, utils, naersk, rust-overlay }: - utils.lib.eachDefaultSystem (system: - let - overlays = [ rust-overlay.overlays.default ]; - pkgs = import nixpkgs { inherit system overlays; }; - rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith - ( - toolchain: + outputs = { + self, + nixpkgs, + utils, + naersk, + rust-overlay, + }: + utils.lib.eachDefaultSystem (system: let + overlays = [rust-overlay.overlays.default]; + pkgs = import nixpkgs {inherit system overlays;}; + rust_pkgs = + pkgs.rust-bin.selectLatestNightlyWith + ( + toolchain: toolchain.default.override { - extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ]; + extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"]; } - )); - naersk-lib = pkgs.callPackage naersk { }; - in - { - defaultPackage = naersk-lib.buildPackage ./.; - devShell = with pkgs; mkShell { + ); + naersk-lib = pkgs.callPackage naersk {}; + in { + defaultPackage = naersk-lib.buildPackage ./.; + devShell = with pkgs; + mkShell { buildInputs = [ rust_pkgs # rust's compiler is quite powerful enough to the point where @@ -37,5 +43,5 @@ # nix flake update # is this even needed? ''; }; - }); + }); } diff --git a/templates/rust/shell.nix b/templates/rust/shell.nix index 47458ad..3c038e9 100644 --- a/templates/rust/shell.nix +++ b/templates/rust/shell.nix @@ -7,4 +7,5 @@ ) { src = ./.; - }).shellNix + }) +.shellNix diff --git a/templates/ts/turborepo/flake.nix b/templates/ts/turborepo/flake.nix index 8446117..a9be22e 100644 --- a/templates/ts/turborepo/flake.nix +++ b/templates/ts/turborepo/flake.nix @@ -9,45 +9,52 @@ turbo.url = "github:dlip/turbo"; }; - outputs = { self, turbo, flake-utils, nixpkgs }: - with flake-utils; lib.eachSystem lib.defaultSystems (sys: - let - overlays = [ turbo.overlay ]; - # pkgs is our tweaked nixpkgs - pkgs = import nixpkgs { system = sys; overlays = overlays; }; - shellMsg = '' - echo "Hello from nix ${sys}" - echo "Local development may use our remote planetscale database (pscale login && pnpm dev:infra; pnpm dev)" - echo "Or from the specified docker-compose.yml (pnpm dev:local_infra && pnpm dev)" - echo "See more on CONTRIBUTING.md" - ''; - in - { - devShell = pkgs.mkShell { - nativeBuildInputs = [ pkgs.bashInteractive ]; - buildInputs = [ - pkgs.nodejs-18_x - pkgs.nodePackages.pnpm - pkgs.nodePackages.prisma - pkgs.prisma-engines - pkgs.turbo - # pkgs.turbo-tooling - pkgs.jq - pkgs.pscale - pkgs.act # Github workflow - ]; - shellHook = - # https://github.com/prisma/prisma/issues/3026#issuecomment-927258138 - # nix-direnv is required (impure build?) https://github.com/nix-community/nix-direnv - '' - export PRISMA_MIGRATION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/migration-engine" - export PRISMA_QUERY_ENGINE_BINARY="${pkgs.prisma-engines}/bin/query-engine" - export PRISMA_QUERY_ENGINE_LIBRARY="${pkgs.prisma-engines}/lib/libquery_engine.node" - export PRISMA_INTROSPECTION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/introspection-engine" - export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt" - export TURBO_BINARY_PATH="${pkgs.turbo}/bin/turbo" - pnpm install - '' + shellMsg; - }; - }); + outputs = { + self, + turbo, + flake-utils, + nixpkgs, + }: + with flake-utils; lib.eachSystem lib.defaultSystems (sys: let + overlays = [turbo.overlay]; + # pkgs is our tweaked nixpkgs + pkgs = import nixpkgs { + system = sys; + overlays = overlays; + }; + shellMsg = '' + echo "Hello from nix ${sys}" + echo "Local development may use our remote planetscale database (pscale login && pnpm dev:infra; pnpm dev)" + echo "Or from the specified docker-compose.yml (pnpm dev:local_infra && pnpm dev)" + echo "See more on CONTRIBUTING.md" + ''; + in { + devShell = pkgs.mkShell { + nativeBuildInputs = [pkgs.bashInteractive]; + buildInputs = [ + pkgs.nodejs-18_x + pkgs.nodePackages.pnpm + pkgs.nodePackages.prisma + pkgs.prisma-engines + pkgs.turbo + # pkgs.turbo-tooling + pkgs.jq + pkgs.pscale + pkgs.act # Github workflow + ]; + shellHook = + # https://github.com/prisma/prisma/issues/3026#issuecomment-927258138 + # nix-direnv is required (impure build?) https://github.com/nix-community/nix-direnv + '' + export PRISMA_MIGRATION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/migration-engine" + export PRISMA_QUERY_ENGINE_BINARY="${pkgs.prisma-engines}/bin/query-engine" + export PRISMA_QUERY_ENGINE_LIBRARY="${pkgs.prisma-engines}/lib/libquery_engine.node" + export PRISMA_INTROSPECTION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/introspection-engine" + export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt" + export TURBO_BINARY_PATH="${pkgs.turbo}/bin/turbo" + pnpm install + '' + + shellMsg; + }; + }); } diff --git a/users/default.nix b/users/default.nix index 030b376..5757c4b 100644 --- a/users/default.nix +++ b/users/default.nix @@ -1,13 +1,11 @@ -{ lib, ... }@inputs: -let +{lib, ...} @ inputs: let config = { - hungtr.metadata = { }; + hungtr.metadata = {}; "hungtr@bao".metadata = { ssh_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z"; }; }; -in -{ - homeConfigurations = { }; +in { + homeConfigurations = {}; pubKeys = lib.getPubkey config; }