Compare commits

..

173 Commits

Author SHA1 Message Date
pegasust e62e724c4d Merge pull request 'std works for now' (#18) from std into master
Reviewed-on: #18
2023-06-18 09:17:42 +00:00
pegasust ca73e77561 Merge branch 'master' into std 2023-06-18 09:17:21 +00:00
htran f454e55e80 std actually works now 2023-06-18 02:06:08 -07:00
Hung 3f1f1c8f6f wip: fix some more boneheads; stuck at starshpi not accepting nested list 2023-06-18 00:52:08 -07:00
Hung 820736fc8c wip: more migrations, mostly adding nix-index, kpcli-py, and nix-boost integration 2023-06-17 23:31:47 -07:00
Hung d5d4415d5c ts-ql is useless :) 2023-06-17 20:33:06 -07:00
Hung 6352f821c3 add some more hints on the default settings for neovim; just go with alejandra formatter; add more docs on qa 2023-06-17 20:32:15 -07:00
Hung e7efe1a965 format with alejandra and other things 2023-06-17 17:46:31 -07:00
Hung 1537fea0bd wip: interface-like structure but im sadge on development with no type-safety 2023-06-16 16:12:54 -07:00
Hung e67a18e465 fix: darwin spotlight patch; extra: debugging neovim-cmp type 2023-06-15 12:46:01 -07:00
Hung f04388f562 many neovim changes and vimplugins nightly overlay 2023-06-12 23:58:03 -07:00
Hung 7f0611d186 docs 2023-06-12 12:14:59 -07:00
Hung a6c979c659 feat: add couple more vim plugins via nixpkgs 2023-06-11 23:51:47 -07:00
Hung a5186b204c feat: idempotent installation with WPlug 2023-06-11 21:21:01 -07:00
Hung 63900e1117 docs 2023-06-07 22:04:50 -07:00
Hung fbb8477c19 feat: more ssh targets; darwin spotlight home-manager is broken :( 2023-06-07 21:53:56 -07:00
Hung f546cb6b32 fix: fidget and home-manager should remove existing darwin spotlight if already existed 2023-06-07 08:30:46 -07:00
Hung aef09a32c5 feat(nvim): fidget.nvim 2023-06-06 21:19:13 -07:00
Hung ba993d16f5 feat(nvim): tablines and potential for job management 2023-06-05 09:04:08 -07:00
Hung d58acd7bc2 feat(nvim): add '<leader>fug' for unrestricted live grep (no .gitignore) 2023-06-04 21:40:47 -07:00
Hung 9cd012f2e2 feat: less init.lua, more neovim.nix along with docs on shell setup 2023-06-04 20:17:13 -07:00
Hung 84a69f8638 feat: vi-copy mode now consistent with vim: use 'v' for select mode and 'y' to copy 2023-06-03 20:23:42 -07:00
Hung 9a8ddc42d5 tsql 2023-06-01 08:26:10 -07:00
Hung 632104be69 fix(flakes): minimum to work correctly, along with user shell integration 2023-05-16 09:31:51 -07:00
Hung 8b4cb660c8 fix(neovim): Just pin neovim correctly to its latest working nightly 2023-05-16 09:26:57 -07:00
Hung b50bd9964c feat(nvim): optimize for rust 2023-05-02 10:26:53 -07:00
Hung 3c483aeb89 feat(hm): cpu usage now works on tmux 2023-05-02 09:28:34 -07:00
Hung 1f511b052c nixGL/fetch: single-thread beats future 2023-04-02 11:49:46 -07:00
Hung 17937c2146 nixGL/fetch: cleanup 2023-04-02 01:35:36 -07:00
Hung 335efeb2d9 nixGL: simplify, update, and use builtins only 2023-04-02 01:10:47 -07:00
Hung b7c3707213 ^deps and allow htran home to be built 2023-04-01 23:35:11 -07:00
Hung bbcc5a14b7 wip: error building kpcli-py :/
error: builder for '/nix/store/sacq2mx2i7f4230sy0j2m36av73xsjc7-python3.10-pip-23.0.1.drv' failed with exit code 1;
       last 10 log lines:
       > updateAutotoolsGnuConfigScriptsPhase
       > configuring
       > no configure script, doing nothing
       > building
       > Executing setuptoolsBuildPhase
       > Traceback (most recent call last):
       >   File /private/tmp/nix-build-python3.10-pip-23.0.1.drv-0/pip-23.0.1-source/nix_run_setup, line 3, in <module>
       >     import setuptools
       > ModuleNotFoundError: No module named 'setuptools'
       > /nix/store/mymsi43djixs7aiqfb9gpms4jllszfrg-stdenv-darwin/setup: line 1601: pop_var_context: head of shell_variables not a function context
       For full logs, run 'nix log /nix/store/sacq2mx2i7f4230sy0j2m36av73xsjc7-python3.10-pip-23.0.1.drv'.
2023-03-24 09:39:29 -07:00
Hung b0b8d2cc3a wip: copy to some remote cache 2023-03-23 21:50:49 -07:00
Hung fa4f674853 add upload to cache 2023-03-23 13:49:13 -07:00
Hung 0e91219d9a add some troubleshooting info 2023-03-23 00:56:15 -07:00
Hung 56babf7600 add sops 2023-03-23 00:41:44 -07:00
Hung 4de2b92b25 more parallelism 2023-03-22 18:11:00 -07:00
Hung 516612c36e darwin apps should be put to spotlights 2023-03-22 18:04:29 -07:00
Hung 29d6a06346 nix flake update for first-timers 2023-03-22 17:08:04 -07:00
Pegasust dcc35d45a1 wip: tmux 2023-03-22 16:35:03 -07:00
Pegasust dce680f2a8 yamlls: remove keyOrdering enforcement 2023-03-19 21:25:41 -07:00
Pegasust 0a947801ab flake update for hm 2023-03-11 21:27:34 -08:00
Pegasust c9f22e24ad nix-dev: should be stable now 2023-03-11 15:29:21 -08:00
Pegasust 9f0023c4d6 add work gitlab 2023-03-06 13:11:12 -08:00
Pegasust 33c4acf9ea prefer ed25519 2023-03-06 12:55:55 -08:00
Hung 73da05fc73 credentials: add new user; add postman to work darwin 2023-02-28 12:04:25 -07:00
Hung 9a4e80ba6e +ssh 2023-02-27 10:32:48 -07:00
Hung fd82956c33 add ci user for dev1 2023-02-24 10:54:28 -07:00
Hung bdd7ea92d1 just bare minimum for convenience of sops and access to credentials.yml 2023-02-22 13:18:44 -07:00
Hung ac131e1389 cred: allow private key access for bao 2023-02-22 11:19:28 -07:00
Pegasust a9456019ad cred: add bao machine 2023-02-22 11:17:36 -07:00
Pegasust 79e3c20b39 before nuking top-level-wip again 2023-02-22 11:08:07 -07:00
Hung 1d39c05834 more credentials 2023-02-22 11:05:10 -07:00
Hung 7150eb19c1 misc changes for credentials, updates on py-poetry template 2023-02-21 08:40:14 -08:00
Hung 20d3325ae9 add work gitlab runner deploy key 2023-02-14 11:27:22 -07:00
Hung 7a37c135ee add credentials encrypted with sops 2023-02-14 11:19:44 -07:00
Hung 78b22d31fc add nickel lang 2023-02-14 10:06:39 -07:00
Hung ed84a5a871 clean c_ 2023-02-14 01:56:48 -07:00
Hung bf22c75270 add sops 2023-02-14 01:34:17 -07:00
Hung 267d7f829a add yang syntax highlight 2023-02-13 17:04:48 -07:00
Hung 34982b3079 fix ssh and use yq-go instead of yq 2023-02-12 12:02:27 -07:00
Hung 4283dba315 ssh: +id_ed25519 2023-02-09 21:54:08 -07:00
Hung 27ed93d41e htran work mbp: +slack :D 2023-02-04 14:48:08 -07:00
Hung c6a69029d7 internal stuffs 2023-02-02 01:51:09 -07:00
Hung d74280a44c nvim: gopls 2023-01-25 10:44:16 -08:00
Hung 150534c512 add bootstrapping profile for py-poetry 2023-01-20 14:58:02 -08:00
pegasust 98e8c003e6 Merge pull request 'top-level configuration is still broken. Maybe merging configurations is not really a good idea.' (#10) from top-level-wip into master
Reviewed-on: #10
2023-01-20 22:47:23 +00:00
Hung 7bddd37b48 another bonehead on networking interfaces should be plural 2023-01-20 13:19:59 -08:00
Hung 6f21b98c0e conf-sysnix.sh use that nix-conf/system for now 2023-01-20 13:16:52 -08:00
Hung 4ab83570aa while top-level nixosConfiguration is broken, bring back nix-conf/system 2023-01-20 13:13:14 -08:00
Hung b63f75815c bonehead on nix flake's fetch git convention 2023-01-20 10:59:07 -08:00
Hung eaee170085 forgot .envrc :/ 2023-01-20 10:48:41 -08:00
pegasust 2796a3720e Merge pull request 'templates: built with Nix' (#8) from top-level-wip into master
Reviewed-on: #8
2023-01-20 18:46:47 +00:00
Hung 9c4aa2799b more robust nix templates 2023-01-20 10:44:01 -08:00
Hung 1726597501 nvim: ansible is pretty much a finger away from all IT ops 2023-01-19 15:06:25 -08:00
pegasust 4f13c01728 Merge pull request 'py-poetry template + pyright instead of pylsp' (#7) from top-level-wip into master
Reviewed-on: #7
2023-01-19 22:23:46 +00:00
Hung 651806c0e4 add py-poetry template 2023-01-19 14:02:39 -08:00
Hung f9387aafc0 ow 2023-01-19 13:38:06 -08:00
Hung ec1afc4fe0 guess who got a job? 2023-01-19 13:32:03 -08:00
Pegasust 81fa580d0c nvim: remove pylsp for pyright 2023-01-19 13:30:25 -08:00
Pegasust 295166292a top-level configurations not working to start with :/ 2023-01-19 10:24:53 -08:00
Pegasust ca63340a3e cross-platform failing 2023-01-19 10:24:12 -08:00
pegasust 6eb4af3491 Merge pull request 'nixops, nix-index-database, out-of-tree flake-compat' (#6) from top-level-wip into master
Reviewed-on: #6
2023-01-15 17:24:07 +00:00
pegasust d4f6cf27a9 Merge branch 'master' into top-level-wip 2023-01-15 17:23:34 +00:00
Pegasust 97fd1543df nixops ok now 2023-01-15 04:48:11 -08:00
Pegasust a0dae5b3a0 add nix-index-database 2023-01-15 01:54:53 -08:00
Pegasust 8734707ab6 hungtran: another darwin that's more open to hardware mods 2023-01-15 00:45:51 -08:00
Pegasust ecfc6bf1fa onboard htran 2023-01-14 06:38:36 -08:00
pegasust 820ac199d8 add flake-compat for out-of-tree bc maintainer seems ded 2023-01-14 06:50:50 -07:00
pegasust ab3e8c6a9e Merge pull request 'Pure NVIDIA autodetection for NixGL' (#5) from top-level-wip into master
Reviewed-on: #5
2023-01-14 13:10:27 +00:00
pegasust 652854db20 resolve hosts/default.nix 2023-01-14 06:04:43 -07:00
pegasust 2fe6f6ce97 templates: rust-monorepo: no vcs on `cargo new` 2023-01-14 05:42:40 -07:00
pegasust d3c0db3363 bao: explicitly use nixGL 2023-01-13 00:24:32 -07:00
pegasust 22acf5787e hm: stricter graphics enable 2023-01-12 23:56:58 -07:00
pegasust f06509d74a logseq not available on x64-darwin 2023-01-12 23:51:50 -07:00
pegasust 7a3eee8647 htran 2023-01-12 23:47:43 -07:00
pegasust 2176df3047 nix-fmt 2023-01-12 23:42:21 -07:00
pegasust 3a3683baa9 hm-switch: home-manager only returns 0 if help is provided 2023-01-12 23:16:36 -07:00
pegasust 8b1503c4bd hm-switch: also aggressively manage nix.conf for non-nixos installs 2023-01-12 23:08:31 -07:00
pegasust 19b9a0713e bao: configure keepass db path 2023-01-12 17:33:53 -07:00
Pegasust d7c499dde1 nixGL: remove some rec for better error message 2023-01-12 17:27:32 -07:00
Pegasust 1c36b5c957 nixGL: throw if no sha-256; hm-switch: allow passthru 2023-01-12 17:24:20 -07:00
pegasust aa96b9e6ab nixgl: auto should be less impure now 2023-01-12 17:22:56 -07:00
pegasust 9abddeea3c nixgl: add fetch database for purity 2023-01-12 17:08:55 -07:00
pegasust 8b1ba34164 prohibit sha-less nixgl 2023-01-12 13:01:11 -07:00
pegasust 4a5981d050 add sha256 to pinned nixpkgs to support nix config monorepo 2023-01-12 12:34:30 -07:00
pegasust 3e9ba75329 more top-level bonehead 2023-01-12 11:42:20 -07:00
pegasust 313a5e7f3e top-level should direnv fine now (hwtr) 2023-01-12 11:04:56 -07:00
Pegasust c691bae4f3 rekey 2023-01-12 10:55:56 -07:00
Pegasust 6501c80e8d merge various changes 2023-01-12 10:50:46 -07:00
pegasust c6d74c6b3e shortcuts for rust 2023-01-12 10:41:58 -07:00
pegasust 6546a0e7fa neovim nightly 0.9 2023-01-11 18:55:28 -07:00
pegasust b0026dff5e flake update 2023-01-10 08:30:52 -07:00
pegasust 98da9eec26 readme to rust-monorepo 2023-01-06 11:07:05 -07:00
pegasust 34ef52d5b4 Merge pull request 'turborepo, neovim: rust-analyzer pushed to devShell' (#4) from top-level-wip into master
Reviewed-on: #4
2023-01-03 22:37:11 +00:00
pegasust bd62ef48c2 rust-monorepo: rust-analyzer fresh from rustup 2023-01-03 15:34:51 -07:00
pegasust 077eba7ec0 relative flake done right 2023-01-03 13:10:04 -07:00
pegasust 2b4b2a901f hm-switch should now updates neovim and some of its plugins 2023-01-02 22:49:04 -07:00
pegasust 0b3403877f Merge pull request 'Add kpcli & fix template rust-monorepo bootstrap: corelib instead of core' (#3) from top-level-wip into master
Reviewed-on: #3
2022-12-31 10:23:15 +00:00
pegasust 7000b86d38 framework on devShells? 2022-12-31 01:40:26 -07:00
pegasust 4d5e06667b commented code is deadcode - the fix 2022-12-30 07:14:33 -07:00
pegasust 1b4b0fc5ff add kpcli-py, with support for kdbx files and intuitive cli 2022-12-30 07:10:55 -07:00
pegasust 72d3beb39a add kpcli, now 2022-12-30 03:40:05 -07:00
pegasust 714c25f5ea gamer moves for zsh-vi-mode; funny: nix mono-repo is not really a thing.
That's because nix flake uses the git hash as /nix/store/ lol.
2022-12-30 03:36:29 -07:00
pegasust 820b0ddbc9 nvim: Alt-M for vim normal mode on zsh 2022-12-30 03:08:04 -07:00
pegasust 994d704070 Merge remote-tracking branch 'gitea/top-level-wip' into top-level-wip 2022-12-30 02:26:56 -07:00
pegasust 4b42202ede change to zsh-vi-mode; in vim terminal emu, just use <C-[> lol 2022-12-30 02:21:59 -07:00
pegasust b84ad23b42 out-of-tree nixGL without impurity 2022-12-30 01:45:15 -07:00
pegasust 5b2b04ee0b more devex in neovim: named terminals 2022-12-29 21:34:19 -07:00
pegasust 93ef9d9a8b zsh vi-mode is ok. multiline command editing only possible once it hits history, though 2022-12-29 20:43:17 -07:00
pegasust 191919bc47 zsh vi-mode is ok. multiline command editing only possible once it hits history, though 2022-12-29 20:19:02 -07:00
pegasust 563c7e8da5 unnamed terminals 2022-12-29 16:22:25 -07:00
pegasust 477fe0334a nvim: temrinals as second-class window 2022-12-29 16:22:16 -07:00
pegasust 666ef30c15 reuse modules instead + linux and windows alacritty fullscreen 2022-12-29 15:13:35 -07:00
pegasust 0db6769717 Merge branch 'top-level-nix' into top-level-wip 2022-12-28 23:46:45 -07:00
pegasust 9fac3ee1c3 nit? why is there even a diff? 2022-12-28 06:12:53 -07:00
Pegasust 7ec3d37e60 nvim: add dependencies onto environment to test bad type inference from evcxr 2022-12-28 02:18:45 -07:00
Pegasust f98622e269 rust repl for neovim 2022-12-27 21:19:56 -07:00
Pegasust 225238405a rust-monorepo: .gitignore and bacon 2022-12-27 19:42:06 -07:00
pegasust a04ffb87ba Merge pull request 'hotfix: nit on templates' (#2) from top-level-wip into master
Reviewed-on: #2
2022-12-28 02:15:14 +00:00
Pegasust fb30c67188 hotfix: nit on templates 2022-12-27 19:14:29 -07:00
pegasust 1ed57bdf87 Merge pull request 'begin migrating to top-level nix-config; LSP stuffs working!' (#1) from top-level-wip into master
Reviewed-on: #1
2022-12-28 02:10:02 +00:00
Pegasust b22ef28604 just make nix-conf works for now 2022-12-27 19:08:07 -07:00
Pegasust 43942e2fe0 copy hardware-configurations 2022-12-26 23:18:09 -07:00
Pegasust 4df865676b before pattern-copy 2022-12-26 22:58:24 -07:00
Pegasust 85dda3dbd3 add some rust templates 2022-12-26 21:51:32 -07:00
Pegasust 3e22f2c3e7 add some more modules 2022-12-26 21:22:07 -07:00
Pegasust 1cab6d3430 neovim: the default theme for file picker was better 2022-12-26 05:33:01 -07:00
Pegasust 66f13ffb37 neovim: lua-lsp good now 2022-12-26 04:34:17 -07:00
Pegasust 2dcd1b7956 rust-analyzer: linker cc not found resolved 2022-12-26 04:08:26 -07:00
Pegasust c94520edbe neovim with runtime path success. check: `:tree-sittersitter` vs tree-sitter on shell 2022-12-26 04:03:56 -07:00
Pegasust 9944604a38 old nix-conf: update proj_root + failure on hungtr-neovim 2022-12-26 03:42:14 -07:00
Pegasust 416f0d0c60 wip: add opinionated setups, which is enabled in module import 2022-12-25 16:15:15 -07:00
Pegasust 93e5306ce3 even more stuffs for top-level nix-flake 2022-12-25 03:54:10 -07:00
Pegasust 9b0a54e534 re-order stuffs around 2022-12-25 02:55:30 -07:00
Pegasust 828d7ee2c1 inspecting source code at nixpkgs, libForQt5 is horrible name for plasma5Package 2022-12-24 03:12:56 -07:00
Pegasust 21bccdb664 remove annoying ksshaskpass 2022-12-24 02:28:51 -07:00
Pegasust 8bd3eb914e e2@phoenix is broken, use e2@LA instead 2022-12-24 02:19:24 -07:00
Pegasust e3a0eb7c3f add nix-index 2022-12-23 21:11:56 -07:00
Pegasust 7122cf0cf8 add felia mount 2022-12-23 16:29:10 -07:00
Pegasust 1e218c9269 bao: access /perso/hot for idrive e2 storage :) 2022-12-23 06:04:33 -07:00
Pegasust 5d49888ac7 rekey + properly put <access>:<secret> 2022-12-23 03:28:19 -07:00
Pegasust 4c1e532876 agenix 2022-12-23 02:20:17 -07:00
Pegasust 4c28cd8b08 nvim: smart case search; zk: updated date cmd 2022-12-23 00:46:08 -07:00
Pegasust 1121af6759 add sops; bao: builtins.readFile requries git-controlled file 2022-12-22 18:57:21 -07:00
Pegasust 1bee9c3368 bao: s3fs + autofs for personal cloud drive: s3fs command not found 2022-12-22 17:40:35 -07:00
Pegasust e10fb596a7 conf-sys: onboard also ssh 2022-12-22 16:04:04 -07:00
Pegasust 8f8afd8563 bao: keyboard and mouse works better (by switching to USB 3). no audio though 2022-12-22 02:18:11 -07:00
Pegasust 7cdfe03e31 sys: bao: correct timezone 2022-12-21 17:44:16 -07:00
Pegasust e827efcedf home-manager font-config gets backed up every time. Is this because of KDE? 2022-12-21 23:42:59 +00:00
Pegasust 89a41c6ad7 hungtr@bao: ungoogled vimium 2022-12-21 22:49:03 +00:00
Pegasust b2412b25dd hungtr@bao 2022-12-21 11:18:01 +00:00
pegasust 49535655b6 add bao: workstation 2022-12-21 10:37:03 +00:00
181 changed files with 12438 additions and 2357 deletions

16
.envrc Normal file
View File

@ -0,0 +1,16 @@
#! /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}"

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
result
.direnv

View File

@ -1,4 +1,7 @@
{ {
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.globals": [
"vim",
],
"Lua.workspace.checkThirdParty": false "Lua.workspace.checkThirdParty": false
} }

16
.sops.yaml Normal file
View File

@ -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

View File

@ -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 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. 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 ## Nix
Monorepo that contains my commonly used personal environments. 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 ## How do I apply these config
- I will always first clone this repository, preferably from local source before - Clone and nixify
going from the github. `git clone https://github.com/pegasust/dotfiles`
### neovim ### neovim
@ -26,7 +29,6 @@ My main text editor. It's based on `vim`, but stays loyal to `lua` ecosystem
#### Notes #### Notes
- Ensure that neovim is installed and invocable by `nvim`. - 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) - For information on installing neovim, visit their [github page](https://github.com/neovim/neovim/wiki/Installing-Neovim)
### tmux ### tmux
@ -40,7 +42,7 @@ from one terminal.
#### Notes #### 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. that does not respond well to one of the config lines.
### zk ### zk
@ -57,4 +59,23 @@ text-editor agnostically.
- Templates: `zk/templates/` - Templates: `zk/templates/`
- Command: `ln -s $PWD/zk/templates ~/.config/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)

97
credentials.yml Normal file
View File

@ -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

13
default.nix Normal file
View File

@ -0,0 +1,13 @@
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
c_ = import ./c_.nix;
in
c_.fetchTree lock.nodes.flake-compat.locked
)
{src = ./.;}
)
.defaultNix

30
dev-shell.nix Normal file
View File

@ -0,0 +1,30 @@
# 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 <nixpkgs> {},
lib,
...
}:
pkgs.mkShell {
# mkShell doesn't care about the differences across nativeBuildInputs,
# buildInputs, or packages
buildInputs = [
# shell scripts
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";
}

36
docs/DEV.md Normal file
View File

@ -0,0 +1,36 @@
# Journal on development
This contains information dump to record thoughts as I design this repo
## Nix as first-class citizen instead of native config
- Nix can export JSON and other object serialization formats
- Still allows native config, so that Neovim, for example, which uses Turing-complete
config language, to make full use of its native LSP.
## Design pattern emerges from unstructured code
### Modules
- Main thing for the first big refactor of codebase
- nixpkgs and home-manager has their own interface for modules
- The main benefit is to provide (runtime) type-safety on options, along with
documentations and defaults
## Nitpicky details
### `nativeBuildInputs` vs `buildInputs`
- `nativeBuildInputs` is available **before** `buildInputs`.
- `nativeBuildInputs` is supposed to be built by a deployment machine (not target)
- `buildInputs` gives you access during runtime (if the package goes path build filter)
- `nativeBulidInputs` gives you access to packages during build time
- `mkShell` doesn't care about `packages`, `nativeBuildInputs`, `buildInputs`

View File

@ -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.

169
docs/vim-plugins.md Normal file
View File

@ -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

2012
flake.lock Normal file

File diff suppressed because it is too large Load Diff

70
flake.nix Normal file
View File

@ -0,0 +1,70 @@
{
nixConfig = {
accept-flake-config = true;
experimental-features = "nix-command flakes";
max-jobs = 12;
};
description = "My personal configuration in Nix (and some native configurations)";
inputs = {
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";
};
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;
};
nix-index-database = {
url = "github:mic92/nix-index-database";
# Should show the latest nixpkgs whenever possible
inputs.nixpkgs.follows = "nixpkgs-latest";
};
};
outputs = {self, std, ...} @ inputs:
std.growOn
{
# boilerplate
inherit inputs;
# All cell blocks are under ./nix/cells/<cell>/<cellblock> as `<cellblock>.nix`
# or `<cellblock/default.nix`
cellsFrom = ./nix/cells;
# modules = ./nix/modules;
cellBlocks = let
inherit (std.blockTypes) devshells functions anything installables;
in [
(devshells "devshells")
(devshells "userShells")
(functions "home-profiles")
(functions "home-modules")
(anything "home-configs")
(installables "packages")
(anything "lib")
];
}
{
devShells = std.harvest self [["dotfiles" "devshells"]];
# nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ];
# homeConfigurations = std.pick [ [ "dotfiles" "home" ] ];
homeModules = std.pick self [["repo" "home-modules"]];
packages = std.harvest self [["repo" "packages"]];
legacyPackages = std.harvest self [["repo" "home-configs"]];
lib = std.pick self [["repo" "lib"]];
# TODO: Debug only
homeProfiles = std.pick self [["repo" "home-profiles"]];
};
}

View File

@ -0,0 +1,81 @@
# 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 = [];
boot.initrd.availableKernelModules = [];
boot.initrd.kernelModules = [];
boot.kernelModules = [];
boot.extraModulePackages = [];
## NOTE: These filesystems are mounted by a wrapper script from nix-wsl
# fileSystems."/" =
# {
# device = "/dev/sdc";
# fsType = "ext4";
# };
#
# fileSystems."/mnt/wsl" =
# {
# device = "tmpfs";
# fsType = "tmpfs";
# };
#
# fileSystems."/mnt/wsl/docker-desktop/shared-sockets/guest-services" =
# {
# device = "none";
# fsType = "tmpfs";
# };
#
# fileSystems."/usr/lib/wsl/drivers" =
# {
# device = "drivers";
# fsType = "drvfs";
# };
#
# fileSystems."/usr/lib/wsl/lib" =
# {
# device = "lib";
# fsType = "drvfs";
# };
fileSystems."/mnt/c" = {
device = "C:";
fsType = "drvfs";
};
fileSystems."/mnt/d" = {
device = "D:";
fsType = "drvfs";
};
fileSystems."/mnt/f" = {
device = "F:";
fsType = "drvfs";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.bond0.useDHCP = lib.mkDefault true;
# networking.interfaces.bonding_masters.useDHCP = lib.mkDefault true;
# networking.interfaces.dummy0.useDHCP = lib.mkDefault true;
# networking.interfaces.eth0.useDHCP = lib.mkDefault true;
# networking.interfaces.sit0.useDHCP = lib.mkDefault true;
# networking.interfaces.tunl0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

12
hosts/bao/default.nix Normal file
View File

@ -0,0 +1,12 @@
{
nixpkgs,
agenix,
home-manager,
flake-utils,
nixgl,
rust-overlay,
flake-compat,
pkgs,
lib,
proj_root,
}: {}

View File

@ -0,0 +1,48 @@
# 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")
];
boot.loader.systemd-boot.enable = true;
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 = [];
fileSystems."/" =
# Might be wise to use /dev/nvme0p1 instead
{
device = "/dev/disk/by-uuid/27fc09b3-e3b7-4883-94a0-c313a0e0abe2";
fsType = "ext4";
};
fileSystems."/boot" =
# Might be wise to use /dev/nvme0p2 instead
{
device = "/dev/disk/by-uuid/EBA6-394D";
fsType = "vfat";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

91
hosts/default.nix Normal file
View File

@ -0,0 +1,91 @@
{
nixpkgs,
agenix,
home-manager,
flake-utils,
nixgl,
rust-overlay,
flake-compat,
pkgs,
lib,
proj_root,
nixosDefaultVersion ? "22.05",
defaultSystem ? "x86_64-linux",
...
} @ finalInputs: let
config = {
bao.metadata = {
# req
hostName = "bao";
# opts
ssh_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIBuAaAE7TiQmMH300VRj/pYCri1qPmHjd+y9aX2J0Fs";
nixosVersion = "22.11";
system = "x86_64-linux";
preset = "base";
};
# TODO: add override so that we can add wsl config on top
bao.nixosConfig = {
modules = [
(import ../modules/nvgpu.sys.nix)
(import ../modules/kde.sys.nix)
(import ../modules/pulseaudio.sys.nix)
(import ../modules/storage.perso.sys.nix)
];
};
};
propagate = hostConfig @ {
metadata,
nixosConfig,
}: let
# req
inherit (metadata) hostName;
# opts
ssh_pubkey = lib.attrByPath ["ssh_pubkey"] null metadata; # metadata.ssh_pubkey??undefined
users = lib.attrByPath ["users"] {} metadata;
nixosVersion = lib.attrByPath ["nixosVersion"] nixosDefaultVersion metadata;
system = lib.attrByPath ["system"] defaultSystem metadata;
preset = lib.attrByPath ["preset"] "base" metadata;
# infer
hardwareConfig = import "${proj_root.hosts.path}/${hostName}/hardware-configuration.nix";
# alias to prevent infinite recursion
_nixosConfig = nixosConfig;
in {
inherit hostName ssh_pubkey users nixosVersion system preset hardwareConfig;
nixosConfig =
_nixosConfig
// {
inherit system;
modules =
[
{
config._module.args = {
inherit proj_root;
my-lib = finalInputs.lib;
};
}
hardwareConfig
{
system.stateVersion = nixosVersion;
networking.hostName = hostName;
users.users = users;
}
{
imports = [agenix.nixosModule];
environment.systemPackages = [agenix.defaultPackage.x86_64-linux];
}
(import "${proj_root.modules.path}/secrets.nix")
(import "${proj_root.modules.path}/${preset}.sys.nix")
]
++ _nixosConfig.modules;
};
};
# we are blessed by the fact that we engulfed nixpkgs.lib.* at top level
mkHostFromPropagated = propagatedHostConfig @ {nixosConfig, ...}: nixpkgs.lib.nixosSystem nixosConfig;
mkHost = hostConfig: (lib.pipe [propagate mkHostFromPropagated] hostConfig);
trimNull = lib.filterAttrsRecursive (name: value: value != null);
flattenPubkey = lib.mapAttrs (hostName: meta_config: meta_config.metadata.ssh_pubkey);
in {
nixosConfigurations = lib.mapAttrs (name: hostConfig: mkHost hostConfig) config;
# {bao = "ssh-ed25519 ..."; another_host = "ssh-rsa ...";}
pubKeys = lib.getPubkey config;
}

View File

@ -0,0 +1,44 @@
# 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")
];
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;
terminal_output serial
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
boot.kernelModules = [];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "/dev/sda";
fsType = "ext4";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1,44 @@
# 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")
];
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;
terminal_output serial
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
boot.kernelModules = [];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "/dev/sda";
fsType = "ext4";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

12
hosts/lizzi/default.nix Normal file
View File

@ -0,0 +1,12 @@
{
nixpkgs,
agenix,
home-manager,
flake-utils,
nixgl,
rust-overlay,
flake-compat,
pkgs,
lib,
proj_root,
}: {}

View File

@ -0,0 +1,51 @@
# 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")
];
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;
terminal_output serial
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
boot.kernelModules = [];
boot.extraModulePackages = [];
fileSystems = {
"/" = {
device = "/dev/sda";
fsType = "ext4";
};
# Assume Linode volume "gitea" exists, mount it to '/gitea"'
"/gitea" = {
device = "/dev/disk/by-id/scsi-0Linode_Volume_gitea";
fsType = "ext4";
};
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1,44 @@
# 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")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = [];
boot.extraModulePackages = [];
boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial;
terminal_output serial;
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
fileSystems."/" = {
device = "/dev/sda";
fsType = "ext4";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1 @@

6
modules/amdgpu.sys.nix Normal file
View File

@ -0,0 +1,6 @@
{
imports = [./gpu.sys.nix];
boot.initrd.kernelModules = ["amdgpu"];
services.xserver.enable = true;
services.xserver.videoDrivers = ["amdgpu"];
}

15
modules/base.sys.nix Normal file
View File

@ -0,0 +1,15 @@
{
pkgs,
lib,
proj_root,
...
}: {
imports = [
./minimal.sys.nix
./mosh.sys.nix
./tailscale.sys.nix
./ssh.sys.nix
];
environment.systemPackages = [pkgs.lm_sensors];
time.timeZone = "America/Phoenix";
}

1
modules/default.nix Normal file
View File

@ -0,0 +1 @@
inputs: {}

12
modules/gpu.sys.nix Normal file
View File

@ -0,0 +1,12 @@
{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];
# Vulkan
driSupport = true;
driSupport32Bit = true;
package = pkgs.mesa.drivers;
package32 = pkgs.pkgsi686Linux.mesa.drivers;
};
}

30
modules/kde.sys.nix Normal file
View File

@ -0,0 +1,30 @@
{
pkgs,
my-lib,
...
}: {
environment.noXlibs = my-lib.mkForce false;
# TODO: wireless networking
# 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
];
};
# disables KDE's setting of askpassword
programs.ssh.askPassword = "";
programs.ssh.enableAskPassword = false;
}

31
modules/minimal.sys.nix Normal file
View File

@ -0,0 +1,31 @@
{
pkgs,
lib,
proj_root,
modulesPath,
...
}: {
imports = ["${modulesPath}/profiles/minimal.nix"];
# prune old builds after a while
nix.settings.auto-optimise-store = true;
nix.package = pkgs.nixFlakes; # nix flakes
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
programs.neovim = {
enable = true;
defaultEditor = true;
};
programs.git.enable = true;
environment.systemPackages = [
pkgs.gnumake
pkgs.wget
pkgs.inetutils # network diag
pkgs.mtr # network diag
pkgs.sysstat # sys diag
];
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.configs.path}/ssh/authorized_keys");
};
}

28
modules/mosh.sys.nix Normal file
View File

@ -0,0 +1,28 @@
{
pkgs,
lib,
config,
...
}: let
cfg = config.mod.mosh;
in {
options.mod.mosh = {
enable = lib.mkOption {
type = lib.types.bool;
description = "enable mosh";
default = true;
example = false;
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [pkgs.mosh];
networking.firewall = lib.mkIf config.networking.firewall.enable {
allowedUDPPortRanges = [
{
from = 60000;
to = 61000;
} # mosh
];
};
};
}

7
modules/nvgpu.sys.nix Normal file
View File

@ -0,0 +1,7 @@
{config, ...}: {
imports = [./gpu.sys.nix];
nixpkgs.config.allowUnfree = true;
services.xserver.enable = true;
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
}

23
modules/opengl.sys.nix Normal file
View File

@ -0,0 +1,23 @@
{
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;
};
environment.systemPackages = gpu_pkgs;
};
in
gpu_conf

View File

@ -0,0 +1,15 @@
{
# 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;
}

View File

@ -0,0 +1,9 @@
{
# 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";
}

18
modules/secrets.nix Normal file
View File

@ -0,0 +1,18 @@
{proj_root, ...}: {
age.secrets.s3fs = {
file = "${proj_root.secrets.path}/s3fs.age";
# mode = "600"; # owner + group only
# owner = "hungtr";
# group = "users";
};
age.secrets."s3fs.digital-garden" = {
file = "${proj_root.secrets.path}/s3fs.digital-garden.age";
};
age.secrets._nhitrl_cred = {
file = "${proj_root.secrets.path}/_nhitrl.age";
};
age.secrets."wifi.env" = {
file = "${proj_root.secrets.path}/wifi.env.age";
};
# environment.systemPackages = [agenix.defaultPackage.x86_64-linux];
}

6
modules/ssh.sys.nix Normal file
View File

@ -0,0 +1,6 @@
{
services.openssh = {
enable = true;
permitRootLogin = "no";
};
}

View File

@ -0,0 +1,94 @@
# Personal configuration on storage solution
{
pkgs,
config,
lib,
...
}: {
environment.systemPackages = [
pkgs.s3fs
pkgs.cifs-utils
];
# Sadly, autofs uses systemd, so we can't put it in home-manager
# 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));
# 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
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
};
}

57
modules/tailscale.sys.nix Normal file
View File

@ -0,0 +1,57 @@
{
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];
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"];
# set this service as a oneshot job
serviceConfig.Type = "oneshot";
# have the job run this shell script
script = ''
# wait for tailscaled to settle
sleep 2
# check if we are already authenticated to tailscale
status="$(${pkgs.tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing
exit 0
fi
# ${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
${pkgs.tailscale}/bin/tailscale up -authkey tskey-auth-kJcgTG5CNTRL-PUVFkk31z1bThHpfq3FC5b1jcMmkW2EYW
'';
};
networking.firewall = lib.mkIf config.networking.firewall.enable {
trustedInterfaces = [
"tailscale0"
];
allowedUDPPorts = [
config.services.tailscale.port
];
allowedTCPPorts = [
22
];
checkReversePath = "loose";
};
};
}

8
modules/wifi.sys.nix Normal file
View File

@ -0,0 +1,8 @@
{config, ...}: {
networking.wireless.enable = true;
networking.wireless.environmentFile = config.age.secrets."wifi.env";
networking.wireless.networks = {
"Hoang Sa".psk = "@DESERT_PSK@";
"Truong Sa".psk = "@DESERT_PSK@";
};
}

17
native_configs/README.md Normal file
View File

@ -0,0 +1,17 @@
# Native configs
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

View File

@ -836,6 +836,7 @@ key_bindings:
# (Windows, Linux, and BSD only) # (Windows, Linux, and BSD only)
- { key: V, mods: Control|Shift, mode: ~Vi, action: Paste } - { key: V, mods: Control|Shift, mode: ~Vi, action: Paste }
- { key: C, mods: Control|Shift, action: Copy } - { key: C, mods: Control|Shift, action: Copy }
- { key: Return, mods: Alt, action: ToggleFullscreen }
#- { key: F, mods: Control|Shift, mode: ~Search, action: SearchForward } #- { key: F, mods: Control|Shift, mode: ~Search, action: SearchForward }
#- { key: B, mods: Control|Shift, mode: ~Search, action: SearchBackward } #- { key: B, mods: Control|Shift, mode: ~Search, action: SearchBackward }
#- { key: C, mods: Control|Shift, mode: Vi|~Search, action: ClearSelection } #- { key: C, mods: Control|Shift, mode: Vi|~Search, action: ClearSelection }
@ -847,9 +848,6 @@ key_bindings:
#- { key: Minus, mods: Control, action: DecreaseFontSize } #- { key: Minus, mods: Control, action: DecreaseFontSize }
#- { key: NumpadSubtract, mods: Control, action: DecreaseFontSize } #- { key: NumpadSubtract, mods: Control, action: DecreaseFontSize }
# (Windows only)
#- { key: Return, mods: Alt, action: ToggleFullscreen }
# (macOS only) # (macOS only)
#- { key: K, mods: Command, mode: ~Vi|~Search, chars: "\x0c" } #- { key: K, mods: Command, mode: ~Vi|~Search, chars: "\x0c" }
#- { key: K, mods: Command, mode: ~Vi|~Search, action: ClearHistory } #- { key: K, mods: Command, mode: ~Vi|~Search, action: ClearHistory }
@ -868,7 +866,7 @@ key_bindings:
#- { key: Q, mods: Command, action: Quit } #- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit } #- { key: W, mods: Command, action: Quit }
#- { key: N, mods: Command, action: SpawnNewInstance } #- { key: N, mods: Command, action: SpawnNewInstance }
#- { key: F, mods: Command|Control, action: ToggleFullscreen } - { key: Return, mods: Command, action: ToggleFullscreen }
#- { key: F, mods: Command, mode: ~Search, action: SearchForward } #- { key: F, mods: Command, mode: ~Search, action: SearchForward }
#- { key: B, mods: Command, mode: ~Search, action: SearchBackward } #- { key: B, mods: Command, mode: ~Search, action: SearchBackward }

View File

@ -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] :<Space> :<Nop> {:silent true})
(vim.keymap.set :t :<Esc> "<C-\\><C-n>)")
(vim.keymap.set [:n :i :v] :<c-l> :<Cmd>mode<Cr> {:desc ""})
(vim.keymap.set :n "[d" vim.diagnostic.goto_prev)
(vim.keymap.set :n "]d" vim.diagnostic.goto_next)
(vim.keymap.set :n :<leader>e vim.diagnostic.open_float)
(vim.keymap.set :n :<leader>q "<cmd>TroubleToggle loclist<cr>")
(vim.keymap.set :n :<leader>wq "<cmd>TroubleToggle workspace_diagnostics<cr>")
(vim.keymap.set :n :<leader>gg :<cmd>GuessIndent<cr>)
(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 {:<C-d> false
:<C-u> 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 :<C-p> :<cmd>Telescope<cr> {:desc "Open Telescope general search"})
(remap :n :<leader>fm (fn []
((. (. (. (require :telescope) :extensions)
:file_browser)
:file_browser) {}))
{:desc "[F]ile [M]utation"})
(remap :n :<leader>ff
(fn []
((. (require :telescope.builtin) :find_files) {:follow false
:hidden false
:no_ignore false}))
{:desc "[F]ind [F]ile"})
(remap :n :<leader>fa
(fn []
((. (require :telescope.builtin) :find_files) {:follow true
:hidden true
:no_ignore true}))
{:desc "[F]ind [A]ll files"})
(remap :n :<leader>fg
(fn []
((. (require :telescope.builtin) :live_grep)))
{:desc "[F]ind by [G]rep"})
(remap :n :<leader>fug
(fn []
((. (require :telescope.builtin) :live_grep) {:glob_pattern "**/*"}))
{:desc "[F]ind by [u]nrestricted [G]rep"})
(remap :n :<leader>fb
(fn []
((. (require :telescope.builtin) :buffers)))
{:desc "[F]ind existing [B]uffers"})
(remap :n :<leader>fh
(fn []
((. (require :telescope.builtin) :help_tags)))
{:desc "[F]ind [H]elp"})
(remap :n :<leader>fd
(fn []
((. (require :telescope.builtin) :diagnostics)))
{:desc "[F]ind [D]iagnostics"})
(remap :n :<leader>zf
(fn []
((. (require :zk) :edit) {} {:multi_select false}))
{:desc "[Z]ettelkasten [F]iles"})
(remap :n :<leader>zg (fn [] (vim.cmd ":ZkGrep"))
{:desc "[Z]ettelkasten [G]rep"})
(for [i 1 9]
(vim.api.nvim_set_keymap :n (.. :<C-t> i) (.. ":tabn " i :<CR>)
{: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 :<unknown>)
(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 :<C-t>x
":tabdo if tabpagenr() > 1 | tabclose | endif<CR>"
{: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 :<C-space>
:node_decremental :<C-backspace>
:node_incremental :<C-space>
:pscope_incremental :<C-S>}}
: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 :<leader>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 :<leader>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 :<leader>hh
(fn []
((. (require :harpoon.ui) :toggle_quick_menu))))
(for [i 1 10]
(harpoon-nav (tostring (% i 10)) i)
(remap :n (.. :<leader>t (tostring (% i 10)))
(fn []
((. (require :harpoon.term) :gotoTerminal) i))))
((. (require :neogit) :setup) {})
(remap :n :<leader>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 :<leader>rn vim.lsp.buf.rename "[R]e[n]ame")
(nmap :<leader>ca vim.lsp.buf.code_action "[C]ode [A]ction")
(vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc")
(nmap :<leader>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 :<leader>ds (. (require :telescope.builtin) :lsp_document_symbols)
"[D]ocument [S]ymbols")
(nmap :<leader>ws (. (require :telescope.builtin)
:lsp_dynamic_workspace_symbols)
"[W]orkspace [S]ymbols")
(nmap :K vim.lsp.buf.hover "Hover Documentation")
(nmap :<C-k> 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 :<leader>D vim.lsp.buf.type_definition "Type [D]efinition")
(nmap :<leader>wa vim.lsp.buf.add_workspace_folder "[W]orkspace [A]dd Folder")
(nmap :<leader>wr vim.lsp.buf.remove_workspace_folder
"[W]orkspace [R]emove Folder")
(nmap :<leader>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 {:<C-d> (cmp.mapping.scroll_docs 4)
:<C-space> (cmp.mapping.complete)
:<C-u> (cmp.mapping.scroll_docs (- 4))
:<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
:select true})
:<S-Tab> (cmp.mapping (fn [fallback]
(if (cmp.visible)
(cmp.select_prev_item)
(luasnip.jumpable (- 1))
(luasnip.jump (- 1))
(fallback)))
[:i :s])
:<Tab> (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}})

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
sh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgmng5xL/auvI2F8ufFAfId2Ey55ONHjgnKKSEWLVWkPMutXT3BCnSglNAuEVRLX2zfzg3beQd80AHTow+qro5QWI/rYfeL1QPNEwoThbRFcvtWLTlgzBGA4ejjpIF9sCPNp0sXrrQRfxRP7w4b23BcRJQcsDoaEtKGKJZ2GQIoOafkYypwcunANb54EAouZTfHEPKDr26Gfw8usc2Sae32G/80QLBF2jGabyexJjNE3F6hdJTwq5iiqIVdSr4ue82zo3M8jBdtCMDGaOliI5RWSa9iuX9o2scCGDU69Gkw7ma+JHOP/e9Z8sUz03TkjPbEnGi3EC3YAHEoDzmwqTi07hppCuzacLB5NZ9UZ1g5PzBIZR8TJTONngT08EQyGrkNv2sUnn0dtBqve5tHR04NuXy65ym7Iwl2DDVbAL0NlM4gKWzOGZ2CnSLT0WmkG2sQKU37NmS2pBJ8RXJBatUFe4vQVzqlFj39iRGIBV5XR0I9xcxDfCxBHFs3aIqAqE= hwtr@hwtr-prince
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAW4E8L/zGkcqixJo1102ddqeexoBMHIhXRXpWR3dTmJtbaaVbo4+rHRsjHPvHif9CRfi+BQ8CHG3zmBjH7DZPZIRCVtkms1EDe1k/G3fEnfgYc6gboJfoTdLkVjNOtdStTi03dCA/riQqUKc7/v16R5ZXIAmNCnmMHelObCSDPzYg8psZAUk1ZZY//pnhp9JRPsC2JxsshN7HCNIED9aFgrJkvUt+wUVGjVHzyQwyR6J7m1yyoivTwdmYdulG7OriLeeNq8vkoDmLGgLSC+zKehzJYOZsH3EKuxuZjQ3J9tK/NseQOhsQglRHE/OvphMwT/J96gl9dZR/LQXp4S6hwLccTzFfs8rLaTOIK6CEpqBUuBonot/1vJP5j5E73hfkHwZO7TQKwfXtpRCxCl5Nm3cB2Y3kz5mArDiwWioVsX4qd0XR0F9MFtuTVTn2f4K/Gwr9P3XMkLWXU1+1KbQiWIg+Zf5DpQgBW5HWryZzsMcjyMC2I2BJCl6Q+V8ofSM= nixos@Felia
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD49VHCU8S6zqNsaS0SFiVqULmOWtyVOIeteYSOznzTHJ0dVjXnamuj/uVsSXRkYIIdAkABWQm9WKELUC2SBBE7DgDj+Izv3cO7QkAJ9v1cxV1P1efrTytz8XtyX++XYygxXCwZ5zyqxhSF5ZW+FO0CNRx1cNisAhF6AMzoXRsyF1dqNioitXTN0xh0xx2mR0Bb3zy1kYNZVwn1uBYyd4Hz6CBgJ7Xi6d/STXWcmc0XnEJTllNSQNEpI6vJjL62JmUPubqDjVKh4awiPRPiw9By1FGaGVtHhOZ+8AvVMTps07GNVJ+XZi1DJLmeItpiCwYsWh96HCp3lup0onLzubpP pi@raspberrypi
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClSDhyOeehUOIMdRonTDD9h7kBbzC3c/QG650S7vfhLE67UNt5tuUjazQg7pFj3O/5WnyqCpBOMJoPaSZ0S5gGdo4h4xatPUBAGDjMygKhg4VA0x7Lr3Tbc1CF8dyuRKVlB+aIWLIyLHHPL5wDao7tnvmuCGKDyaV8XFaKpzRZqAlpfn8svR90Y4wNFYr1V+F+Y6r8reB1Rph6A9BY4niDKY0MbFhvTj6VJQf++1ji0FziACVpYI9aqAcZ4ngReUtgWiIsnq5UMfrEk0vYBG/3KsYElaRig76Bucz1fBA16iAgQua1hthPifsw8vmaK5k6Q3c2SOdc5PGF6IlTfSGJ root@Fel
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0Z5noQn3mHy5yiN3n6YyOKRhlQT6fx4NLmI/3d4vY6 root@Fel ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0Z5noQn3mHy5yiN3n6YyOKRhlQT6fx4NLmI/3d4vY6 root@Fel
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClSDhyOeehUOIMdRonTDD9h7kBbzC3c/QG650S7vfhLE67UNt5tuUjazQg7pFj3O/5WnyqCpBOMJoPaSZ0S5gGdo4h4xatPUBAGDjMygKhg4VA0x7Lr3Tbc1CF8dyuRKVlB+aIWLIyLHHPL5wDao7tnvmuCGKDyaV8XFaKpzRZqAlpfn8svR90Y4wNFYr1V+F+Y6r8reB1Rph6A9BY4niDKY0MbFhvTj6VJQf++1ji0FziACVpYI9aqAcZ4ngReUtgWiIsnq5UMfrEk0vYBG/3KsYElaRig76Bucz1fBA16iAgQua1hthPifsw8vmaK5k6Q3c2SOdc5PGF6IlTfSGJ root@Fel
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD49VHCU8S6zqNsaS0SFiVqULmOWtyVOIeteYSOznzTHJ0dVjXnamuj/uVsSXRkYIIdAkABWQm9WKELUC2SBBE7DgDj+Izv3cO7QkAJ9v1cxV1P1efrTytz8XtyX++XYygxXCwZ5zyqxhSF5ZW+FO0CNRx1cNisAhF6AMzoXRsyF1dqNioitXTN0xh0xx2mR0Bb3zy1kYNZVwn1uBYyd4Hz6CBgJ7Xi6d/STXWcmc0XnEJTllNSQNEpI6vJjL62JmUPubqDjVKh4awiPRPiw9By1FGaGVtHhOZ+8AvVMTps07GNVJ+XZi1DJLmeItpiCwYsWh96HCp3lup0onLzubpP pi@raspberrypi
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFQN5Ia8rTalnQgcvdxH2n7UNNT1Tq9UvNdJeg9ziJtUkKaC6H4NM4ArOEZ60izANOQX1crAD8hmBmz1Go8/4P3VXTYlTb7eDyZqLyncOe/shBXeVVLxJWzhEj60RTgecnmNYdtRAm+9INbPW/Bvcj8U2KyaykIXZGdjIuZ7TPruHjITxZYR+dkDOoVkJuYJMdYzxyHZpylPh+HjgDDvUG3oNJtj4ri5JKwLAMyq5t5S1JcLx4rXivrKREizUMMG8LzWSfjeByTzF8+lHtUdP94ygG02v/6Jod/g6taUQS9Yu+NDFqkKjRH3H9jgyd/DVGsRw5akBWbR81DATtTprx ssh-key-2022-12-15 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFQN5Ia8rTalnQgcvdxH2n7UNNT1Tq9UvNdJeg9ziJtUkKaC6H4NM4ArOEZ60izANOQX1crAD8hmBmz1Go8/4P3VXTYlTb7eDyZqLyncOe/shBXeVVLxJWzhEj60RTgecnmNYdtRAm+9INbPW/Bvcj8U2KyaykIXZGdjIuZ7TPruHjITxZYR+dkDOoVkJuYJMdYzxyHZpylPh+HjgDDvUG3oNJtj4ri5JKwLAMyq5t5S1JcLx4rXivrKREizUMMG8LzWSfjeByTzF8+lHtUdP94ygG02v/6Jod/g6taUQS9Yu+NDFqkKjRH3H9jgyd/DVGsRw5akBWbR81DATtTprx ssh-key-2022-12-15
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgmng5xL/auvI2F8ufFAfId2Ey55ONHjgnKKSEWLVWkPMutXT3BCnSglNAuEVRLX2zfzg3beQd80AHTow+qro5QWI/rYfeL1QPNEwoThbRFcvtWLTlgzBGA4ejjpIF9sCPNp0sXrrQRfxRP7w4b23BcRJQcsDoaEtKGKJZ2GQIoOafkYypwcunANb54EAouZTfHEPKDr26Gfw8usc2Sae32G/80QLBF2jGabyexJjNE3F6hdJTwq5iiqIVdSr4ue82zo3M8jBdtCMDGaOliI5RWSa9iuX9o2scCGDU69Gkw7ma+JHOP/e9Z8sUz03TkjPbEnGi3EC3YAHEoDzmwqTi07hppCuzacLB5NZ9UZ1g5PzBIZR8TJTONngT08EQyGrkNv2sUnn0dtBqve5tHR04NuXy65ym7Iwl2DDVbAL0NlM4gKWzOGZ2CnSLT0WmkG2sQKU37NmS2pBJ8RXJBatUFe4vQVzqlFj39iRGIBV5XR0I9xcxDfCxBHFs3aIqAqE= hwtr@hwtr-prince
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC/UzKwmFsAlLoCXvOq2lsC1sr1BRDW5uPkdcYUfQ7z4JowL/pscoTV9zjfJd1hPBvHLBvn7gs7gWt0wNnJfD1Oor26VreHjhi1PZE2kovrEzjmPoz+GqMPciV+HF9XNIRwDiHlUNFPt9qJjAJXJCFhzcmT9q0JQuPlNgJtQ6+By7RgPuJczpf17IbxpheLcXqtOFcTHyRT01KijIPhAtWRlmG5dahVuu50EfpmHRYZ8nCJJqkuJ6uRbFaPE6mYLnXLSzJUdyakYnzWbCd5phpoGAuFyQZnS503CFZUOFCnNEN8QfO2DXihp7lvrzzpI6PgcpvpotSo9kYFiEuB+DRlBQcVMWL0lUk2J1JHJH83y3CxwH0pUc7E1k6FAZE4pv4x0KEvbZSvmb8jAGWZkn4HvZCwXR5wGVi22s6RCdIHvR2PCpAy+ZSjpM+2FJIqDHpxY/vo3ktM9rpeCSwp14F/iiw6nanVq/KZBpCZ2paMcAU4WreCFZiPdGsdiixYlts= hungtr@bao
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAW4E8L/zGkcqixJo1102ddqeexoBMHIhXRXpWR3dTmJtbaaVbo4+rHRsjHPvHif9CRfi+BQ8CHG3zmBjH7DZPZIRCVtkms1EDe1k/G3fEnfgYc6gboJfoTdLkVjNOtdStTi03dCA/riQqUKc7/v16R5ZXIAmNCnmMHelObCSDPzYg8psZAUk1ZZY//pnhp9JRPsC2JxsshN7HCNIED9aFgrJkvUt+wUVGjVHzyQwyR6J7m1yyoivTwdmYdulG7OriLeeNq8vkoDmLGgLSC+zKehzJYOZsH3EKuxuZjQ3J9tK/NseQOhsQglRHE/OvphMwT/J96gl9dZR/LQXp4S6hwLccTzFfs8rLaTOIK6CEpqBUuBonot/1vJP5j5E73hfkHwZO7TQKwfXtpRCxCl5Nm3cB2Y3kz5mArDiwWioVsX4qd0XR0F9MFtuTVTn2f4K/Gwr9P3XMkLWXU1+1KbQiWIg+Zf5DpQgBW5HWryZzsMcjyMC2I2BJCl6Q+V8ofSM= nixos@Felia

142
native_configs/ssh/config Normal file
View File

@ -0,0 +1,142 @@
# felia mirror on windows
Host felia-win
HostName felia.coati-celsius.ts.net
Port 2222
User _nhitrl
# Ubuntu 12c 32G-RAM
Host felia
HostName felia.coati-celsius.ts.net
User ubuntu_admin
Port 22
# 2c 16G-RAM 200G drive
Host fel
HostName fel.coati-celsius.ts.net
User user
Port 22
# AMZ Linux aarch64 hungtr@AMZ
Host nioma
HostName ec2.pegasust.com
User ec2-user
IdentityFile ~/.ssh/free-aws.pem
Port 22
# NixOS Pegasust-gh@Linode
Host nyx
HostName nyx.pegasust.com
User hungtr
Port 22
Host lizzi
HostName 172.105.135.218
User hungtr
Port 22
Host pixi
HostName 139.144.60.254
User hungtr
Port 22
Host mokoi
HostName 129.146.98.121
User ubuntu_admin
Port 22
Host noami
HostName 10.100.200.230
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

View File

@ -3,6 +3,11 @@
[aws] [aws]
symbol = " " symbol = " "
[c]
disabled = false
# commands = [ [ 'cc', '--version' ], [ 'gcc', '--version' ], [ 'clang', '--version' ] ]
detect_extensions = ["c", "h", "cc", "cpp", "hh", "hpp"]
[conda] [conda]
symbol = " " symbol = " "

View File

@ -14,7 +14,19 @@ setw -g pane-base-index 1
set-option -g renumber-windows on set-option -g renumber-windows on
# status bar # 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 # 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 set-window-option -g mode-keys vi
# # Log
# set-option -g history-file /tmp/.tmux.log

View File

@ -1,7 +1,7 @@
[note] # Settings that reflect the creation of a new note [note] # Settings that reflect the creation of a new note
language = "en" language = "en"
default-title = "Untitled" default-title = "Untitled"
filename = "{{date now 'timestamp'}}" # Loyal to my current style: 202208201345 filename = "{{format-date now 'timestamp'}}" # Loyal to my current style: 202208201345
extension = "md" # might switch to mdx extension = "md" # might switch to mdx
[extra] [extra]

View File

@ -1,943 +0,0 @@
-- 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)
-- - <leader>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
local data_dir = vim.fn.stdpath('data')
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
]])
-- vim-plug
local Plug = vim.fn['plug#']
vim.call('plug#begin')
-- libs and dependencies
Plug('nvim-lua/plenary.nvim')
-- 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
Plug('nvim-telescope/telescope-fzf-native.nvim',
{ ['do'] = 'make >> /tmp/log 2>&1' })
Plug('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' })
-- DevExp
Plug('windwp/nvim-autopairs') -- matches pairs like [] (),...
Plug('windwp/nvim-ts-autotag') -- matches tags <body>hello</body>
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
Plug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts
-- UI & colorscheme
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
-- 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
---------
vim.call('plug#end')
vim.cmd([[
if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
PlugInstall --sync | autocmd VimEnter * so $MYVIMRC
endif
]])
vim.cmd([[
set number relativenumber
set tabstop=4 softtabstop=4
set autoindent
set smartindent
set expandtab
set shiftwidth=4
set exrc
set incsearch
set scrolloff=30
set signcolumn=yes
set colorcolumn=80
set background=light
]])
vim.opt.lazyredraw = true
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- some plugins misbehave when we do swap files
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.completeopt = 'menuone,noselect'
-- vim.opt.clipboard = "unnamedplus"
-- more aggressive swap file writing. ThePrimeagen believes higher number
-- leads to low DX
vim.opt.updatetime = 50
vim.g.mapleader = ' '
vim.g.maplocalleader = ','
-- basic keymaps
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) -- since we're using space for leader
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>)') -- make :terminal escape out
vim.keymap.set({ 'n', 'i', 'v' }, '<c-l>', '<Cmd>:mode<Cr>') -- redraw on every mode
-- diagnostics (errors/warnings to be shown)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float) -- opens diag in box (floating)
-- vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist) -- opens list of diags
-- vim.keymap.set('n', '<leader>wq', vim.diagnostic.setqflist) -- workspace diags
vim.keymap.set('n', '<leader>q', '<cmd>TroubleToggle loclist<cr>')
vim.keymap.set('n', '<leader>wq', '<cmd>TroubleToggle workspace_diagnostics<cr>')
-- color, highlighting, UI stuffs
vim.cmd([[
colorscheme gruvbox
]])
require('hlargs').setup()
require('nvim-web-devicons').setup()
require('trouble').setup()
-- TODO: Any way to collect all the TODOs and its variants?
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)
end
-- Comment.nvim
require('Comment').setup()
-- lukas-reineke/indent-blankline.nvim
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 = " ",
}
-- 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 }
)
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 }
)
-- telescope
local fb_actions = require "telescope".extensions.file_browser.actions
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = false,
},
},
},
extensions = {
fzf = {
fuzzy = true, -- allow fuzzy matches
override_generic_sorter = true,
override_file_sorter = true,
case_mode = 'smart_case'
},
file_browser = {
theme = "ivy",
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
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'file_browser')
remap('n', '<C-p>', '<cmd>Telescope<cr>', { desc = 'Open Telescope general search' })
remap('n', '<leader>fm', function()
require("telescope").extensions.file_browser.file_browser()
end, { desc = '[F]ile [M]utation' })
remap('n', '<leader>ff', function()
require('telescope.builtin').find_files({
hidden = false,
no_ignore = false,
follow = false,
})
end, { desc = '[F]ind [F]ile' })
remap('n', '<leader>fa', function()
require('telescope.builtin').find_files({
hidden = true,
no_ignore = true,
follow = true,
})
end, { desc = '[F]ind [A]ll files' })
remap('n', '<leader>fg', function()
require('telescope.builtin').live_grep()
end, { desc = '[F]ind by [G]rep' })
remap('n', '<leader>fb', function()
require('telescope.builtin').buffers()
end, { desc = '[F]ind existing [B]uffers' })
remap('n', '<leader>fh', function()
require('telescope.builtin').help_tags()
end, { desc = '[F]ind [H]elp' })
remap('n', '<leader>fd', function()
require('telescope.builtin').diagnostics()
end, { desc = '[F]ind [D]iagnostics' })
-- ZK remap stuffs
remap('n', '<leader>zf', function()
-- vim.cmd([[:ZkNotes]])
require('zk').edit({}, {multi_select = false})
end, { desc = '[Z]ettelkasten [F]iles' })
remap('n', '<leader>zg', function()
vim.cmd([[:ZkGrep]])
end, { desc = '[Z]ettelkasten [G]rep' })
-- treesitter
require 'treesitter-context'
require('nvim-treesitter.configs').setup {
yati = {
enable = true, default_lazy = true, default_fallback = "auto",
disable = { "nix" }
},
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 = '<C-space>',
node_incremental = '<C-space>',
node_decremental = '<C-backspace>',
pscope_incremental = '<C-S>'
},
},
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,
}
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", "astro" }
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",
},
buftype_exclude = { -- A list of buffer types for which the auto command gets disabled
"help",
"nofile",
"terminal",
-- "prompt",
},
}
-- harpoon: mark significant files & switch between them
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end)
local function harpoon_nav(key, nav_file_index, lead_keybind)
lead_keybind = lead_keybind or '<leader>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)
end
-- remap letters to index. Inspired by alternating number of Dvorak programmer
-- best practices: try to keep marked files to be around 4
harpoon_nav('f', 1)
harpoon_nav('j', 2)
harpoon_nav('d', 3)
harpoon_nav('k', 4)
remap('n', '<leader>hh', function() require('harpoon.ui').toggle_quick_menu() end)
-- harpoon: navigate by numbers
harpoon_nav('1', 1)
harpoon_nav('2', 2)
harpoon_nav('3', 3)
harpoon_nav('4', 4)
harpoon_nav('5', 5)
harpoon_nav('6', 6)
harpoon_nav('7', 7)
harpoon_nav('8', 8)
harpoon_nav('9', 9)
harpoon_nav('0', 10)
-- neogit: easy-to-see git status. Provides only productivity on staging/unstage
require('neogit').setup {}
remap('n', '<leader>gs', function() require('neogit').open({}) end);
-- 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
vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
nmap('<leader>df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat')
-- 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('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- documentations. See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- 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('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>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]',
}
cmp.event:on(
"confirm_done",
require('nvim-autopairs.completion.cmp').on_confirm_done()
)
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = 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,
},
sources = cmp.config.sources {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = "conjure" },
-- { name = 'cmp_tabnine' },
},
}
-- 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,
-- })
-- 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', "pylsp",
"jsonls", "denols"
}
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
},
check_outdated_packages_on_open = true,
},
-- 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
})
local inlay_hint_tsjs = {
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,
}
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
})
require("rust-tools").setup {
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",
},
},
},
-- 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",
},
},
}
require('zk').setup({
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)" })
end)
--
-- ZkGrep: opens file picker
-- In the case where `match_ctor` is falsy, create a prompt.
-- This is so that we distinguish between ZkGrep and ZkNotes
-- 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})
end)
-- Gitsigns
require('gitsigns').setup {
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]',
},
},
},
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 {}

View File

@ -1,16 +1,14 @@
{ config
, proj_root
, myLib
, ...
}:
let
inherit (myLib) fromYaml;
actualConfig = fromYaml (builtins.readFile "${proj_root}//alacritty/alacritty.yml");
cfg = config.base.alacritty;
in
{ {
options.base.alacritty = 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 { font.family = myLib.mkOption {
type = myLib.types.singleLineStr; type = myLib.types.singleLineStr;
default = actualConfig.font.normal.family; default = actualConfig.font.normal.family;
@ -19,6 +17,14 @@ in
''; '';
example = "DroidSansMono NF"; 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 { enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
default = true; default = true;
@ -45,6 +51,7 @@ in
enable = cfg.enable; enable = cfg.enable;
settings = myLib.recursiveUpdate actualConfig { settings = myLib.recursiveUpdate actualConfig {
font.normal.family = cfg.font.family; font.normal.family = cfg.font.family;
font.size = cfg.font.size;
}; };
}; };
} }

View File

@ -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 "";
}

View File

@ -1,4 +1,4 @@
{ {nix-index-database, ...} @ inputs: {
mkModuleArgs = import ./mkModuleArgs.nix; mkModuleArgs = import ./mkModuleArgs.nix;
modules = [ modules = [
./alacritty.nix ./alacritty.nix
@ -8,5 +8,6 @@
{ {
config.programs.home-manager.enable = true; config.programs.home-manager.enable = true;
} }
nix-index-database.hmModules.nix-index
]; ];
} }

View File

@ -1,8 +1,8 @@
{ config {
, myLib config,
, ... myLib,
}: ...
let }: let
cfg = config.base.git; cfg = config.base.git;
baseAliases = { baseAliases = {
a = "add"; a = "add";
@ -15,12 +15,11 @@ let
co = "checkout"; co = "checkout";
b = "branch"; b = "branch";
}; };
in in {
{
options.base.git = { options.base.git = {
aliases = myLib.mkOption { aliases = myLib.mkOption {
type = myLib.types.attrs; type = myLib.types.attrs;
default = { }; default = {};
example = baseAliases; example = baseAliases;
description = '' description = ''
Additional git aliases. This settings comes with base configuration. Additional git aliases. This settings comes with base configuration.
@ -44,12 +43,13 @@ in
default = [ default = [
".vscode" # vscode settings ".vscode" # vscode settings
".direnv" # .envrc cached outputs ".direnv" # .envrc cached outputs
".DS_Store" # MacOS users, amrite
]; ];
description = '' description = ''
.gitignore patterns that are applied in every repository. .gitignore patterns that are applied in every repository.
This is useful for IDE-specific settings. This is useful for IDE-specific settings.
''; '';
example = [ ".direnv" "node_modules" ]; example = [".direnv" "node_modules"];
}; };
enable = myLib.mkOption { enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
@ -66,7 +66,7 @@ in
example = 3000; example = 3000;
}; };
}; };
# TODO : anyway to override configuration? # TODO : anyway to override configuration?
config.programs.git = { config.programs.git = {
inherit (cfg) enable ignores; inherit (cfg) enable ignores;
userName = cfg.name; userName = cfg.name;

View File

@ -0,0 +1,49 @@
{
pkgs,
config,
lib,
...
}: let
cfg = config.base.graphics;
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
types = lib.types;
in {
imports = [./shells.nix];
options.base.graphics = {
enable = lib.mkEnableOption "graphics";
_enable = lib.mkOption {
type = types.bool;
description = "Whether the graphics is implicitly enabled (final)";
# internal = true;
default = false;
};
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.base.shells.enable`
# generally, we want the behavior: import means enable
config = lib.mkIf cfgEnable {
base.graphics._enable = lib.mkForce true;
base.shells = {
shellAliases = lib.mkIf (cfg.useNixGL.defaultPackage != null) {
nixGL = cfg.useNixGL.defaultPackage;
};
};
home.packages = [cfg.useNixGL.package];
};
}

View File

@ -0,0 +1,70 @@
{
config,
proj_root,
pkgs,
lib,
...
}: let
cfg = config.base.keepass;
trimNull = lib.filterAttrsRecursive (name: value: value != null);
in {
imports = [./graphics.nix];
options.base.keepass = {
enable = lib.mkEnableOption "keepass";
use_gui = lib.mkOption {
type = lib.types.bool;
description = "wheter to enable keepass GUI (the original one)";
default = false;
example = "true";
};
path = lib.mkOption {
type = lib.types.path;
description = "Path to kdbx file";
default = null;
example = "/media/homelab/f/PersistentHotStorage/keepass.kdbx";
};
keyfile_path = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = ''
Path to key file for the database
If null, then the field is unset
'';
default = null;
example = "/path/to/mykeyfile.key";
};
store_encrypted_password = lib.mkOption {
type = lib.types.bool;
description = "Whether to store encrypted password for 24 hrs before re-prompt";
default = true;
example = "false";
};
copy_timeout_secs = lib.mkOption {
type = lib.types.int;
description = "Timeout (seconds) before the password is expired from clipboard";
default = 12;
example = "60";
};
};
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 {
default = {
KEEPASSDB = cfg.path;
KEEPASSDB_KEYFILE = cfg.keyfile_path;
STORE_ENCRYPTED_PASSWORD = cfg.store_encrypted_password;
KEEPASSDB_PASSWORD = null; # No good way yet to store the password
KEEPASSDB_TIMEOUT = cfg.copy_timeout_secs;
};
});
};
}

View File

@ -1,13 +1,20 @@
{ pkgs # Turns given inputs into the standardized shape of the inputs to configure
, lib ? pkgs.lib # custom base modules in this directory.
, ... {
}@inputs: pkgs,
let lib ? pkgs.lib,
...
} @ inputs: let
recursiveUpdate = lib.recursiveUpdate; recursiveUpdate = lib.recursiveUpdate;
_lib = recursiveUpdate lib (import ../../lib { inherit pkgs lib; }); _lib = recursiveUpdate lib (import ../../lib {inherit pkgs lib;});
in
# TODO: Unpollute inputs
recursiveUpdate inputs {
proj_root = builtins.toString ./../../..; 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; myLib = _lib;
} }

View File

@ -0,0 +1,192 @@
# 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)
{
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
(
toolchain:
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
# 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;
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;
viAlias = true;
vimAlias = true;
withPython3 = true;
withNodeJs = true;
extraPackages = nvim_pkgs;
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;
};
}

View File

@ -0,0 +1,58 @@
# 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 {
options.base.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";
})
];
};
};
}

View File

@ -0,0 +1,12 @@
# A module that takes care of a GUI-ful, productive desktop environment
inputs @ {pkgs, ...}: {
imports = [
# slack
({pkgs, ...}: {
home.packages = [
pkgs.slack
];
})
./private_chromium.nix
];
}

View File

@ -1,13 +1,14 @@
# Configurations for shell stuffs. # Configurations for shell stuffs.
# Should probably be decoupled even more # Should probably be decoupled even more for each feature
{ config
, proj_root
, myLib
, ...
}:
let cfg = config.base.shells;
in
{ {
config,
proj_root,
myLib,
pkgs,
...
}: let
cfg = config.base.shells;
in {
options.base.shells = { options.base.shells = {
enable = myLib.mkOption { enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
@ -29,14 +30,13 @@ in
shellAliases = myLib.mkOption { shellAliases = myLib.mkOption {
type = myLib.types.attrs; type = myLib.types.attrs;
description = "Shell command aliases"; description = "Shell command aliases";
default = { }; default = {};
example = { example = {
nixGL = "nixGLIntel"; nixGL = "nixGLIntel";
}; };
}; };
}; };
config = myLib.mkIf cfg.enable { config = myLib.mkIf cfg.enable {
xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
# nix: Propagates the environment with packages and vars when enter (children of) # nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc # a directory with shell.nix-compatible and .envrc
programs.direnv = { programs.direnv = {
@ -51,16 +51,37 @@ in
}; };
programs.tmux = { programs.tmux = {
enable = true; enable = true;
extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf"; # 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 = { programs.exa = {
enable = true; enable = true;
enableAliases = true; enableAliases = true;
}; };
# Make the shell look beautiful
programs.starship = { programs.starship = {
enable = true; enable = true;
enableZshIntegration = 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 '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true; programs.fzf.enable = true;
programs.bash = { programs.bash = {
enable = true; enable = true;
@ -71,19 +92,44 @@ in
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
enableAutosuggestions = true; enableAutosuggestions = true;
shellAliases = { shellAliases =
{
nix-rebuild = "sudo nixos-rebuild switch"; nix-rebuild = "sudo nixos-rebuild switch";
hm-switch = "home-manager switch --flake"; hm-switch = "home-manager switch --flake";
} // (cfg.shellAliases or { }); }
// (cfg.shellAliases or {});
history = { history = {
size = 10000; size = 10000;
path = "${config.xdg.dataHome}/zsh/history"; path = "${config.xdg.dataHome}/zsh/history";
}; };
oh-my-zsh = { oh-my-zsh = {
enable = true; enable = true;
plugins = [ "git" "sudo" "command-not-found" "gitignore" "ripgrep" "rust" ]; plugins = [
"git" # git command aliases: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git#aliases
# "sudo" # double-escape to prepend sudo # UPDATE: just use vi-mode lol
"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
# "vi-mode" # edit promps with vi motions :)
];
}; };
initExtra = cfg.shellInitExtra or ""; 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
'';
}; };
}; };
} }

View File

@ -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 { options.base.ssh.enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
default = true; default = true;
@ -17,7 +17,6 @@ in
config.programs.ssh = { config.programs.ssh = {
inherit (cfg) enable; inherit (cfg) enable;
forwardAgent = true; forwardAgent = true;
extraConfig = builtins.readFile "${proj_root}/ssh/config"; includes = ["${proj_root.config.path}/ssh/config"];
}; };
} }

View File

@ -1,12 +1,13 @@
(import # We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
(
import
( (
# Get corresponding version of flake-compat declared in on ./flake.lock let
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in lock = builtins.fromJSON (builtins.readFile ./flake.lock);
fetchTarball { c_ = import ./../../c_.nix;
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; in
sha256 = lock.nodes.flake-compat.locked.narHash; c_.fetchTree lock.nodes.flake-compat.locked
}
) )
{ src = ./.; } # calls flake.nix {src = ./.;}
).defaultNix )
.defaultNix

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +1,112 @@
{ {
nixConfig = {
accept-flake-config = true;
experimental-features = "nix-command flakes";
extra-substituters = [
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
max-jobs = 12;
};
description = "simple home-manager config"; description = "simple home-manager config";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-latest.url = "github:nixos/nixpkgs";
home-manager = { home-manager = {
url = "github:nix-community/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"; flake-utils.url = "github:numtide/flake-utils";
nixgl.url = "github:guibou/nixGL"; nixgl.url = "path:./../../out-of-tree/nixGL";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
# Allows default.nix to call onto flake.nix. Useful for nix eval and automations # Allows default.nix to call onto flake.nix. Useful for nix eval and automations
flake-compat = { flake-compat = {
url = "github:edolstra/flake-compat"; url = "path:../../out-of-tree/flake-compat";
flake = false; 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?rev=88a6c749a7d126c49f3374f9f28ca452ea9419b8";
};
nix-index-database = {
url = "github:mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs = flake_inputs @ {
{ nixpkgs nixpkgs,
, home-manager home-manager,
, nixgl nixgl,
, rust-overlay rust-overlay,
, flake-utils flake-utils,
, ... kpcli-py,
}: neovim-nightly-overlay,
let nix-boost,
system = "x86_64-linux"; nixpkgs-latest,
overlays = [ nixgl.overlay rust-overlay.overlays.default ]; ...
}: 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;});
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
config = { allowUnfree = true; }; config = {allowUnfree = true;};
}; };
# lib = (import ../lib { inherit pkgs; lib = pkgs.lib; }); # lib = (import ../lib { inherit pkgs; lib = pkgs.lib; });
base = import ./base; base = import ./base flake_inputs;
inherit (base) mkModuleArgs; inherit (base) mkModuleArgs;
in
{ nerd_font_module = {
homeConfigurations = config,
let x11_wsl = '' pkgs,
...
}: {
fonts.fontconfig.enable = true;
home.packages = [
# 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"];})
];
base.alacritty.font.family = "Hack Nerd Font Mono";
};
in {
debug = {
inherit overlays pkgs base;
};
homeConfigurations = let
x11_wsl = ''
# x11 output for WSL # x11 output for WSL
export DISPLAY=$(ip route list default | awk '{print $3}'):0 export DISPLAY=$(ip route list default | awk '{print $3}'):0
export LIBGL_ALWAYS_INDIRECT=1 export LIBGL_ALWAYS_INDIRECT=1
''; '';
in in {
rec {
"hungtr" = home-manager.lib.homeManagerConfiguration { "hungtr" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = base.modules ++ [ modules =
base.modules
++ [
./home.nix ./home.nix
]; ];
# optionally pass inarguments to module # optionally pass inarguments to module
@ -61,14 +120,114 @@
}; };
}; };
}; };
"hungtr@bao" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules =
base.modules
++ [
./home.nix
nerd_font_module
./base/productive_desktop.nix
{
# since home.nix forces us to use keepass, and base.keepass.path
# defaults to a bad value (on purpose), we should configure a
# it to be the proper path
base.keepass.path = "/perso/garden/keepass.kdbx";
base.graphics.useNixGL.defaultPackage = "nixGLNvidia";
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";
};
};
};
# 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;
# 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/hungtran/keepass.kdbx";
base.alacritty.font.size = 11.0;
}
nerd_font_module
./base/productive_desktop.nix
{
base.private_chromium.enable = false;
}
{
home.packages = [
pkgs.postman
];
}
];
extraSpecialArgs = mkModuleArgs {
inherit pkgs;
myHome = {
username = "hungtran";
homeDirectory = "/Users/hungtran";
};
};
};
# 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;
base.alacritty.font.size = 11.0;
base.git.name = "Hung";
base.git.email = "htran@egihosting.com";
}
{
home.packages = [
pkgs.postman
];
}
{base.keepass.enable = pkgs.lib.mkForce false;}
];
extraSpecialArgs = mkModuleArgs {
inherit pkgs;
myHome = {
username = "htran";
homeDirectory = "/Users/htran";
};
};
};
"nixos@Felia" = home-manager.lib.homeManagerConfiguration { "nixos@Felia" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ modules = [
./home.nix ./home.nix
{ {
base.shells = { base.shells = {
shellInitExtra = '' shellInitExtra =
'' + x11_wsl; ''
''
+ x11_wsl;
}; };
} }
]; ];
@ -83,49 +242,33 @@
}; };
}; };
}; };
# 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 # Personal laptop
hwtr = home-manager.lib.homeManagerConfiguration { hwtr = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = base.modules ++ [ modules =
base.modules
++ [
./home.nix ./home.nix
./base/graphics.nix
{ {
base.graphics.enable = true;
base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font"; base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font";
base.shells = { base.keepass.path = "/media/homelab/f/PersistentHotStorage/keepass.kdbx";
shellAliases = {
nixGL = "nixGLIntel";
};
};
} }
./base/productive_desktop.nix
]; ];
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "hwtr"; username = "hwtr";
homeDirectory = "/home/hwtr"; homeDirectory = "/home/hwtr";
packages = [ packages = [
pkgs.nixgl.nixGLIntel
pkgs.postman pkgs.postman
]; ];
}; };
}; };
}; };
}; };
}; });
} }

View File

@ -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
}

View File

@ -1,109 +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 }
'';
};
}

View File

@ -3,89 +3,74 @@
# This file represents the base settings for each machine # This file represents the base settings for each machine
# Additional configurations goes to profiles/<user> # Additional configurations goes to profiles/<user>
# or inlined in flake.nix # or inlined in flake.nix
{ config # Represents the realized final configuration
, pkgs # This is by default just ``= import <nixpkgs>{}`
, myHome
, myLib
, option # The options we're given, this might be useful for typesafety?
, ...
}:
let
nvim_pkgs = [
# Yes, I desperately want neovim to work out-of-the-box without flake.nix for now
# I want at least python LSP to work everywhere because it's basically
# an alternative to bash script when I move to OpenColo
pkgs.gccStdenv
pkgs.gcc
pkgs.tree-sitter
pkgs.ripgrep
pkgs.fzf
# pkgs.sumneko-lua-language-server
pkgs.ripgrep
pkgs.zk
pkgs.fd
pkgs.stdenv.cc.cc.lib
# Python3 as alternative to bash scripts :^)
# (pkgs.python310Full.withPackages (pypkgs: [
# # python-lsp-server's dependencies is absolutely astronomous
# # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this
# pypkgs.pynvim # nvim provider
# pypkgs.ujson # pylsp seems to rely on this. satisfy it lol
# ]))
];
proj_root = builtins.toString ./../..;
inherit (myLib) fromYaml;
in
{ {
config,
# Represents the realized final configuration
pkgs,
# This is by default just ``= import <nixpkgs>{}`
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
];
home = { home = {
username = myHome.username; username = myHome.username;
homeDirectory = myHome.homeDirectory; homeDirectory = myHome.homeDirectory;
stateVersion = myHome.stateVersion or "22.05"; stateVersion = myHome.stateVersion or "22.05";
}; };
home.packages = pkgs.lib.unique ([ home.packages = pkgs.lib.unique (
pkgs.ncdu [
pkgs.htop # pkgs.ncdu
pkgs.ripgrep pkgs.rclone # cloud file operations
pkgs.unzip pkgs.htop # system diagnostics in CLI
pkgs.zip pkgs.ripgrep # content fuzzy search
pkgs.unzip # compression
pkgs.zip # compression
# cool utilities # cool utilities
pkgs.yq # Yaml adaptor for jq (only pretty print, little query) pkgs.yq-go # Yaml adaptor for jq (only pretty print, little query)
pkgs.xorg.xclock # TODO: only include if have GL # For testing GL installation # pkgs.xorg.xclock # TODO: only include if have gui # For testing GL installation
pkgs.logseq # TODO: only include if have GL # Obsidian alt # pkgs.logseq # TODO: only include if have GL # Obsidian alt
pkgs.mosh # Parsec for SSH pkgs.mosh # Parsec for SSH
# pkgs.nixops_unstable # nixops v2 # insecure for now # pkgs.nixops_unstable # nixops v2 # insecure for now
pkgs.lynx # Web browser at your local terminal pkgs.lynx # Web browser at your local terminal
pkgs.zk
# pkgs.tailscale # VPC;; This should be installed in system-nix # pkgs.tailscale # VPC;; This should be installed in system-nix
pkgs.python310 # dev packages should be in project pkgs.python310 # dev packages should be in project
# pkgs.python310.numpy # pkgs.python310.numpy
# pkgs.python310Packages.tensorflow # pkgs.python310Packages.tensorflow
# pkgs.python310Packages.scikit-learn # pkgs.python310Packages.scikit-learn
] ++ (myHome.packages or [ ]) ++ nvim_pkgs); ]
++ (myHome.packages or [])
++ (
if pkgs.system == "x86_64-linux"
then [
pkgs.logseq
]
else []
)
);
## Configs ## ## Configs ##
xdg.configFile."nvim/init.lua".source = "${proj_root}//neovim/init.lua"; xdg.configFile."zk/config.toml".source = "${proj_root.config.path}//zk/config.toml";
xdg.configFile."zk/config.toml".source = "${proj_root}//zk/config.toml";
## Programs ## ## Programs ##
programs.jq = { programs.jq = {
enable = true; enable = true;
}; };
programs.neovim = { programs.nix-index = {
enable = true; enable = true;
viAlias = true; enableBashIntegration = true;
vimAlias = true; enableZshIntegration = true;
withPython3 = true;
withNodeJs = true;
extraPackages = nvim_pkgs;
# 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";
}; };
base.keepass.enable = true;
} }

View File

@ -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

View File

@ -1,3 +1,5 @@
accept-flake-config = true accept-flake-config = true
experimental-features = nix-command flakes experimental-features = nix-command flakes
post-build-hook = /etc/nix/upload-to-cache.sh
trusted-users = root htran hungtran hwtr

View File

@ -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

View File

@ -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
]

View File

@ -1,5 +1,8 @@
# main module exporter for different configuration profiles # main module exporter for different configuration profiles
{pkgs, libs,...} @ inputs:
{ {
pkgs,
libs,
...
} @ inputs: {
hwtr = import ./hwtr.nix; hwtr = import ./hwtr.nix;
} }

View File

@ -0,0 +1 @@

View File

@ -1,10 +1,12 @@
{ pkgs {
, lib ? pkgs.lib pkgs,
, ... }@flake_import: lib ? pkgs.lib,
let serde = import ./serde { inherit pkgs lib; }; ...
} @ flake_import: let
serde = import ./serde {inherit pkgs lib;};
recursiveUpdate = lib.recursiveUpdate; recursiveUpdate = lib.recursiveUpdate;
in in
recursiveUpdate (recursiveUpdate pkgs.lib lib) { recursiveUpdate (recursiveUpdate pkgs.lib lib) {
fromYaml = serde.fromYaml; fromYaml = serde.fromYaml;
fromYamlPath = serde.fromYamlPath; fromYamlPath = serde.fromYamlPath;
} }

View File

@ -1,28 +1,39 @@
# Takes care of serializing and deserializing to some formats # Takes care of serializing and deserializing to some formats
# Blame: Pegasust<pegasucksgg@gmail.com> # Blame: Pegasust<pegasucksgg@gmail.com>
# TODO: Add to* formats from pkgs.formats.* # TODO: Add to* formats from pkgs.formats.*
{ pkgs {
, lib pkgs,
} @ inputs: lib,
let } @ inputs: let
yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage yamlToJsonDrv = yamlContent: outputPath:
({ runCommand }: pkgs.callPackage
({runCommand}:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33 # 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 # run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution # note that $out is passed onto the bash/sh script for execution
'' ''
echo "$yamlContent" | yq >$out echo "$yamlContent" | yq >$out
'') '')
{ }; {};
in { in {
# Takes in a yaml string and produces a derivation with translated JSON at $outputPath # 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 # similar to builtins.fromJSON, turns a YAML string to nix attrset
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json")); fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
fromYamlPath = yamlPath: builtins.fromJSON ( fromYamlPath = yamlPath:
builtins.fromJSON (
builtins.readFile ( builtins.readFile (
yamlToJsonDrv ( yamlToJsonDrv
builtins.readFile yamlPath) (
"any-output.json")); builtins.readFile yamlPath
# TODO: fromToml? )
"any-output.json"
)
);
fromTOML = builtins.fromTOML;
fromJSON = builtins.fromJSON;
} }

View File

@ -1,10 +1,12 @@
# This module aims to be merge (not inject/override) with top-level pkgs to provide # This module aims to be merge (not inject/override) with top-level pkgs to provide
# personalized/custom packages # personalized/custom packages
{ pkgs {
, lib pkgs,
, naersk # rust packages lib,
, ... naersk,
}@pkgs_input: { # rust packages
...
} @ pkgs_input: {
# dot-hwtr = import "./dot-hwtr" pkgs_input; # dot-hwtr = import "./dot-hwtr" pkgs_input;
cargo-bacon = pkgs.rustPlatform.buildRustPackage rec { cargo-bacon = pkgs.rustPlatform.buildRustPackage rec {
pname = "bacon"; pname = "bacon";

View File

@ -4,10 +4,12 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "gihub:nix-community/naersk"; naersk.url = "gihub:nix-community/naersk";
}; };
outputs = { nixpkgs, rust-overlay, naersk }: outputs = {
let nixpkgs,
pkgs = import nixpkgs { overlays = [ rust-overlay.overlays.default ]; }; rust-overlay,
naersk,
}: let
pkgs = import nixpkgs {overlays = [rust-overlay.overlays.default];};
lib = pkgs.lib; lib = pkgs.lib;
in in (import ./default.nix {inherit pkgs lib naersk;});
(import ./default.nix { inherit pkgs lib naersk; });
} }

17
nix-conf/secrets.nix Normal file
View File

@ -0,0 +1,17 @@
let
# user-specific (~/.ssh/id_ed25519.pub)
users = {
"hungtr@bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z";
};
# System-specific settings (/etc/ssh/ssh_hsot_ed25519_key.pub)
systems = {
"bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIBuAaAE7TiQmMH300VRj/pYCri1qPmHjd+y9aX2J0Fs";
};
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;
}

View File

@ -1,29 +1,38 @@
{ lib, pkgs, config, modulesPath, specialArgs, ... }: {
let lib,
pkgs,
config,
modulesPath,
specialArgs,
...
}: let
hostname = specialArgs.hostname; hostname = specialArgs.hostname;
enableSSH = specialArgs.enableSSH or true; enableSSH = specialArgs.enableSSH or true;
_networking = lib.recursiveUpdate { hostName = hostname; } (specialArgs._networking or { }); _networking = lib.recursiveUpdate {hostName = hostname;} (specialArgs._networking or {});
_boot = specialArgs._boot or { }; _boot = specialArgs._boot or {};
_services = specialArgs._services or { }; _services = specialArgs._services or {};
includeHardware = specialArgs.includeHardware or true; includeHardware = specialArgs.includeHardware or true;
proj_root = builtins.toString ./../..; proj_root = builtins.toString ./../..;
in in
with lib; with lib; {
{ imports =
imports = (if includeHardware then [ (
./profiles/${hostname}/hardware-configuration.nix if includeHardware
] else [ ]) ++ [ then [
"${proj_root}/hosts/${hostname}/hardware-configuration.nix"
]
else []
)
++ [
"${modulesPath}/profiles/minimal.nix" "${modulesPath}/profiles/minimal.nix"
"${proj_root}/modules/tailscale.sys.nix"
"${proj_root}/modules/mosh.sys.nix"
]; ];
boot = _boot; boot = _boot;
# prune old builds # prune old builds
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
system.stateVersion = "22.05";
# users.users.<defaultUser>.uid = 1000;
# networking.hostName = "nixos";
# Enable nix flakes # Enable nix flakes
nix.package = pkgs.nixFlakes; nix.package = pkgs.nixFlakes;
nix.extraOptions = '' nix.extraOptions = ''
@ -33,11 +42,11 @@ with lib;
isNormalUser = true; isNormalUser = true;
home = "/home/hungtr"; home = "/home/hungtr";
description = "pegasust/hungtr"; description = "pegasust/hungtr";
extraGroups = [ "wheel" "networkmanager" ]; extraGroups = ["wheel" "networkmanager" "audio"];
}; };
users.users.root = { users.users.root = {
# openssh runs in root, no? This is because port < 1024 requires root. # openssh runs in root, no? This is because port < 1024 requires root.
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/ssh/authorized_keys"); openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/native_configs/ssh/authorized_keys");
}; };
# Some basic programs # Some basic programs
@ -58,64 +67,5 @@ with lib;
pkgs.inetutils # network diag pkgs.inetutils # network diag
pkgs.mtr # network diag pkgs.mtr # network diag
pkgs.sysstat # sys diag pkgs.sysstat # sys diag
pkgs.mosh # ssh-alt; parsec-like
pkgs.tailscale # VPC
]; ];
# tailscale is mandatory : ^) }
# inherit services;
services = lib.recursiveUpdate _services {
tailscale.enable = true;
};
# create a oneshot job to authenticate to Tailscale
systemd.services.tailscale-autoconnect = {
description = "Automatic connection 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" ];
# set this service as a oneshot job
serviceConfig.Type = "oneshot";
# have the job run this shell script
script = ''
# wait for tailscaled to settle
sleep 2
# check if we are already authenticated to tailscale
status="$(${pkgs.tailscale}/bin/tailscale status -json | ${pkgs.jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing
exit 0
fi
# ${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
${pkgs.tailscale}/bin/tailscale up -authkey tskey-auth-kJcgTG5CNTRL-PUVFkk31z1bThHpfq3FC5b1jcMmkW2EYW
'';
};
# Don't touch networking.firewall.enable, just configure everything else.
# inherit networking;
# inherit _networking;
networking = lib.recursiveUpdate _networking {
firewall =
if _networking ? firewall.enable && _networking.firewall.enable then {
trustedInterfaces = _networking.firewall.trustedInterfaces or [ ] ++ [
"tailscale0"
];
allowedUDPPorts = _networking.firewall.allowedUDPPorts or [ ] ++ [
config.services.tailscale.port
];
allowedTCPPorts = _networking.firewall.allowedTCPPorts or [ ] ++ [
22
];
allowedUDPPortRanges = _networking.firewall.allowedUDPPortRanges or [ ] ++ [
{ from = 60000; to = 61000; } # mosh
];
checkReversePath = "loose";
} else { enable = false; };
};
}

View File

@ -1,12 +1,32 @@
{ {
"nodes": { "nodes": {
"agenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1665870395,
"narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=",
"owner": "ryantm",
"repo": "agenix",
"rev": "a630400067c6d03c9b3e0455347dc8559db14288",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1671200928, "lastModified": 1672525397,
"narHash": "sha256-mZfzDyzojwj6I0wyooIjGIn81WtGVnx6+avU5Wv+VKU=", "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "757b82211463dd5ba1475b6851d3731dfe14d377", "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,6 +37,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View File

@ -1,16 +1,50 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, ... }: outputs = {
let lib = nixpkgs.lib; in 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 # Windows with NixOS WSL
nixosConfigurations.Felia = nixpkgs.lib.nixosSystem { nixosConfigurations.Felia = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules =
base_modules
++ [
./wsl-configuration.nix ./wsl-configuration.nix
{
system.stateVersion = "22.05";
}
]; ];
specialArgs = { specialArgs = {
# includeHardware = false; # includeHardware = false;
@ -23,19 +57,27 @@
}; };
nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem { nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{
system.stateVersion = "22.05";
mod.tailscale.enable = true;
}
]; ];
specialArgs = { specialArgs = {
hostname = "lizzi"; hostname = "lizzi";
_networking = { _networking = {
interfaces.eth1.ipv4.addresses = [{ interfaces.eth1.ipv4.addresses = [
{
address = "71.0.0.1"; address = "71.0.0.1";
prefixLength = 24; prefixLength = 24;
}]; }
];
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [ 80 443 22 ]; allowedTCPPorts = [80 443 22];
}; };
useDHCP = false; useDHCP = false;
# required so that we get IP address from linode # required so that we get IP address from linode
@ -79,8 +121,13 @@
# Generic machine # Generic machine
nixosConfigurations.pixi = nixpkgs.lib.nixosSystem { nixosConfigurations.pixi = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{
system.stateVersion = "22.05";
}
]; ];
specialArgs = { specialArgs = {
hostname = "pixi"; hostname = "pixi";
@ -91,7 +138,7 @@
# }]; # }];
firewall = { firewall = {
enable = false; enable = false;
allowedTCPPorts = [ 80 443 22 ]; allowedTCPPorts = [80 443 22];
}; };
useDHCP = false; useDHCP = false;
# interfaces.eth0.useDHCP = true; # interfaces.eth0.useDHCP = true;
@ -132,17 +179,24 @@
}; };
nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { nixosConfigurations.nyx = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{
system.stateVersion = "22.05";
}
]; ];
specialArgs = { specialArgs = {
hostname = "nyx"; hostname = "nyx";
_networking = { _networking = {
enableIPv6 = false; enableIPv6 = false;
interfaces.eth1.ipv4.addresses = [{ interfaces.eth1.ipv4.addresses = [
{
address = "71.0.0.2"; address = "71.0.0.2";
prefixLength = 24; prefixLength = 24;
}]; }
];
firewall.enable = true; firewall.enable = true;
useDHCP = false; useDHCP = false;
interfaces.eth0.useDHCP = true; interfaces.eth0.useDHCP = true;
@ -157,12 +211,124 @@
}; };
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{
system.stateVersion = "22.05";
}
]; ];
specialArgs = { specialArgs = {
hostname = "nixos"; hostname = "nixos";
}; };
}; };
nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
base_modules
++ [
./configuration.nix
{
system.stateVersion = "22.11";
mod.tailscale.enable = false;
networking.defaultGateway = {
address = "10.100.200.1";
# interface = "ens32";
};
networking.interfaces.ens32.ipv4.addresses = [
{
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;
};
};
};
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
./../../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.
time.timeZone = "America/Phoenix";
# Configure keymap in X11
services.xserver.layout = "us";
# services.xserver.xkbOptions = {
# "eurosign:e";
# "caps:escape" # map caps to escape.
# };
# Enable CUPS to print documents.
# services.printing.enable = true;
# 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;
};
# 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;
# 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. Its 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?
})
];
};
}; };
} }

View File

@ -1,16 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ (modulesPath + "/profiles/qemu-guest.nix") lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelParams = [ "console=ttyS0,19200n8" ]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -19,17 +23,15 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/sda"; device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
swapDevices = swapDevices = [{device = "/dev/sdb";}];
[ { device = "/dev/sdb"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -10,4 +10,5 @@
) )
{ {
src = ./.; src = ./.;
}).defaultNix })
.defaultNix

View File

@ -11,9 +11,13 @@
}; };
}; };
outputs = { self, nixpkgs, flake-utils, ... }: outputs = {
self,
nixpkgs,
flake-utils,
...
}:
{ {
nixosModules.wsl = { nixosModules.wsl = {
imports = [ imports = [
./modules/build-tarball.nix ./modules/build-tarball.nix
@ -31,25 +35,24 @@
./configuration.nix ./configuration.nix
]; ];
}; };
}
} // // flake-utils.lib.eachSystem
flake-utils.lib.eachSystem (with flake-utils.lib.system; ["x86_64-linux" "aarch64-linux"])
(with flake-utils.lib.system; [ "x86_64-linux" "aarch64-linux" ]) (
(system: system: let
let pkgs = import nixpkgs {inherit system;};
pkgs = import nixpkgs { inherit system; }; in {
in checks.check-format =
pkgs.runCommand "check-format"
{ {
checks.check-format = pkgs.runCommand "check-format" buildInputs = with pkgs; [nixpkgs-fmt];
{
buildInputs = with pkgs; [ nixpkgs-fmt ];
} '' } ''
nixpkgs-fmt --check ${./.} nixpkgs-fmt --check ${./.}
mkdir $out # success mkdir $out # success
''; '';
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nixpkgs-fmt ]; nativeBuildInputs = with pkgs; [nixpkgs-fmt];
}; };
} }
); );

View File

@ -1,12 +1,24 @@
{ config, pkgs, lib, ... }: {
with builtins; with lib; config,
let pkgs,
pkgs2storeContents = l: map (x: { object = x; symlink = "none"; }) l; lib,
...
}:
with builtins;
with lib; let
pkgs2storeContents = l:
map
(x: {
object = x;
symlink = "none";
})
l;
nixpkgs = lib.cleanSource pkgs.path; nixpkgs = lib.cleanSource pkgs.path;
channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}" channelSources =
{ preferLocalBuild = true; } pkgs.runCommand "nixos-${config.system.nixos.version}"
{preferLocalBuild = true;}
'' ''
mkdir -p $out mkdir -p $out
cp -prd ${nixpkgs.outPath} $out/nixos cp -prd ${nixpkgs.outPath} $out/nixos
@ -58,10 +70,7 @@ let
sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
''} ''}
''; '';
in {
in
{
options.wsl.tarball = { options.wsl.tarball = {
includeConfig = mkOption { includeConfig = mkOption {
type = types.bool; type = types.bool;
@ -70,13 +79,12 @@ in
}; };
}; };
config = mkIf config.wsl.enable { config = mkIf config.wsl.enable {
# These options make no sense without the wsl-distro module anyway # These options make no sense without the wsl-distro module anyway
system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" { system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" {
# No contents, structure will be added by prepare script # No contents, structure will be added by prepare script
contents = [ ]; contents = [];
fileName = "nixos-wsl-${pkgs.hostPlatform.system}"; fileName = "nixos-wsl-${pkgs.hostPlatform.system}";
@ -92,6 +100,5 @@ in
compressCommand = "gzip"; compressCommand = "gzip";
compressionExtension = ".gz"; compressionExtension = ".gz";
}; };
}; };
} }

View File

@ -1,20 +1,23 @@
{ config, lib, pkgs, ... }: {
with builtins; with lib; { config,
lib,
pkgs,
...
}:
with builtins;
with lib; {
imports = [ imports = [
(mkRenamedOptionModule [ "wsl" "docker" ] [ "wsl" "docker-desktop" ]) (mkRenamedOptionModule ["wsl" "docker"] ["wsl" "docker-desktop"])
]; ];
options.wsl.docker-desktop = with types; { options.wsl.docker-desktop = with types; {
enable = mkEnableOption "Docker Desktop integration"; enable = mkEnableOption "Docker Desktop integration";
}; };
config = config = let
let
cfg = config.wsl.docker-desktop; cfg = config.wsl.docker-desktop;
in in
mkIf (config.wsl.enable && cfg.enable) { mkIf (config.wsl.enable && cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
docker docker
docker-compose docker-compose
@ -25,7 +28,7 @@ with builtins; with lib; {
script = '' script = ''
${config.wsl.automountPath}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop ${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 = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "30s"; RestartSec = "30s";
@ -35,7 +38,5 @@ with builtins; with lib; {
users.groups.docker.members = [ users.groups.docker.members = [
config.wsl.defaultUser config.wsl.defaultUser
]; ];
}; };
} }

View File

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }: {
with builtins; with lib; { config,
lib,
pkgs,
...
}:
with builtins;
with lib; {
options.wsl.docker-native = with types; { options.wsl.docker-native = with types; {
enable = mkEnableOption "Native Docker integration in NixOS."; enable = mkEnableOption "Native Docker integration in NixOS.";
@ -15,14 +20,13 @@ with builtins; with lib; {
}; };
}; };
config = config = let
let
cfg = config.wsl.docker-native; cfg = config.wsl.docker-native;
in in
mkIf (config.wsl.enable && cfg.enable) { mkIf (config.wsl.enable && cfg.enable) {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
docker = super.docker.override { iptables = pkgs.iptables-legacy; }; docker = super.docker.override {iptables = pkgs.iptables-legacy;};
}) })
]; ];

View File

@ -1,11 +1,19 @@
{ config, lib, pkgs, ... }: {
with builtins; with lib; { config,
lib,
pkgs,
...
}:
with builtins;
with lib; {
config = mkIf config.wsl.enable ( config = mkIf config.wsl.enable (
let let
mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix"; 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}"; 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" '' passwd = pkgs.writeText "passwd" ''
root:x:0:0:System administrator:/root:${installer} root:x:0:0:System administrator:/root:${installer}
''; '';
in in {
{
system.build.installer = mkTarball { system.build.installer = mkTarball {
fileName = "nixos-wsl-installer"; fileName = "nixos-wsl-installer";
compressCommand = "gzip"; compressCommand = "gzip";
compressionExtension = ".gz"; compressionExtension = ".gz";
extraArgs = "--hard-dereference"; extraArgs = "--hard-dereference";
storeContents = with pkgs; pkgs2storeContents [ storeContents = with pkgs;
pkgs2storeContents [
installer installer
]; ];
contents = [ contents = [
{ source = config.environment.etc."wsl.conf".source; target = "/etc/wsl.conf"; } {
{ source = config.environment.etc."fstab".source; target = "/etc/fstab"; } source = config.environment.etc."wsl.conf".source;
{ source = passwd; target = "/etc/passwd"; } target = "/etc/wsl.conf";
{ source = "${pkgs.busybox}/bin/busybox"; target = "/bin/sh"; } }
{ source = "${pkgs.busybox}/bin/busybox"; target = "/bin/mount"; } {
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" '' extraCommands = pkgs.writeShellScript "prepare" ''
@ -66,8 +88,6 @@ with builtins; with lib; {
ln -s /init bin/wslpath ln -s /init bin/wslpath
''; '';
}; };
} }
); );
} }

View File

@ -1,9 +1,13 @@
{ lib, pkgs, config, ... }:
with builtins; with lib;
{ {
lib,
pkgs,
config,
...
}:
with builtins;
with lib; {
imports = [ imports = [
(mkRenamedOptionModule [ "wsl" "compatibility" "interopPreserveArgvZero" ] [ "wsl" "interop" "preserveArgvZero" ]) (mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"])
]; ];
options.wsl.interop = with types; { options.wsl.interop = with types; {
@ -32,15 +36,12 @@ with builtins; with lib;
}; };
}; };
config = config = let
let
cfg = config.wsl.interop; cfg = config.wsl.interop;
in in
mkIf config.wsl.enable { mkIf config.wsl.enable {
boot.binfmt.registrations = mkIf cfg.register { boot.binfmt.registrations = mkIf cfg.register {
WSLInterop = WSLInterop = let
let
compat = cfg.preserveArgvZero; compat = cfg.preserveArgvZero;
# WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable # WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable
@ -61,12 +62,17 @@ with builtins; with lib;
''; '';
# use the autodetect hack if unset, otherwise call /init directly # use the autodetect hack if unset, otherwise call /init directly
interpreter = if compat == null then compatWrapper else "/init"; interpreter =
if compat == null
then compatWrapper
else "/init";
# enable for the wrapper and autodetect hack # enable for the wrapper and autodetect hack
preserveArgvZero = if compat == false then false else true; preserveArgvZero =
in if compat == false
{ then false
else true;
in {
magicOrExtension = "MZ"; magicOrExtension = "MZ";
fixBinary = true; fixBinary = true;
wrapInterpreterInShell = false; wrapInterpreterInShell = false;
@ -77,12 +83,9 @@ with builtins; with lib;
# Include Windows %PATH% in Linux $PATH. # Include Windows %PATH% in Linux $PATH.
environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"''; environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"'';
warnings = warnings = let
let
registrations = config.boot.binfmt.registrations; registrations = config.boot.binfmt.registrations;
in 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"; 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";
}; };
} }

View File

@ -1,12 +1,14 @@
{ lib, pkgs, config, ... }:
with builtins; with lib;
{ {
options.wsl = with types; lib,
let pkgs,
coercedToStr = coercedTo (oneOf [ bool path int ]) (toString) str; config,
in ...
{ }:
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"; enable = mkEnableOption "support for running NixOS as a WSL distribution";
automountPath = mkOption { automountPath = mkOption {
type = str; type = str;
@ -25,18 +27,20 @@ with builtins; with lib;
}; };
startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu"; startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu";
wslConf = mkOption { wslConf = mkOption {
type = attrsOf (attrsOf (oneOf [ string int bool ])); type = attrsOf (attrsOf (oneOf [string int bool]));
description = "Entries that are added to /etc/wsl.conf"; description = "Entries that are added to /etc/wsl.conf";
}; };
}; };
config = config = let
let
cfg = config.wsl; cfg = config.wsl;
syschdemd = import ../syschdemd.nix { inherit lib pkgs config; inherit (cfg) automountPath defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; }; syschdemd = import ../syschdemd.nix {
inherit lib pkgs config;
inherit (cfg) automountPath defaultUser;
defaultUserHome = config.users.users.${cfg.defaultUser}.home;
};
in in
mkIf cfg.enable { mkIf cfg.enable {
wsl.wslConf = { wsl.wslConf = {
automount = { automount = {
enabled = true; enabled = true;
@ -57,9 +61,8 @@ with builtins; with lib;
hardware.opengl.enable = true; # Enable GPU acceleration hardware.opengl.enable = true; # Enable GPU acceleration
environment = { environment = {
etc = { etc = {
"wsl.conf".text = generators.toINI { } cfg.wslConf; "wsl.conf".text = generators.toINI {} cfg.wslConf;
# DNS settings are managed by WSL # DNS settings are managed by WSL
hosts.enable = !config.wsl.wslConf.network.generateHosts; hosts.enable = !config.wsl.wslConf.network.generateHosts;
@ -67,7 +70,7 @@ with builtins; with lib;
}; };
systemPackages = [ systemPackages = [
(pkgs.runCommand "wslpath" { } '' (pkgs.runCommand "wslpath" {} ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s /init $out/bin/wslpath ln -s /init $out/bin/wslpath
'') '')
@ -79,13 +82,13 @@ with builtins; with lib;
users.users.${cfg.defaultUser} = { users.users.${cfg.defaultUser} = {
isNormalUser = true; isNormalUser = true;
uid = 1000; uid = 1000;
extraGroups = [ "wheel" ]; # Allow the default user to use sudo extraGroups = ["wheel"]; # Allow the default user to use sudo
}; };
users.users.root = { users.users.root = {
shell = "${syschdemd}/bin/syschdemd"; shell = "${syschdemd}/bin/syschdemd";
# Otherwise WSL fails to login as root with "initgroups failed 5" # Otherwise WSL fails to login as root with "initgroups failed 5"
extraGroups = [ "root" ]; extraGroups = ["root"];
}; };
security.sudo = { security.sudo = {
@ -97,7 +100,7 @@ with builtins; with lib;
system.activationScripts = { system.activationScripts = {
copy-launchers = mkIf cfg.startMenuLaunchers ( copy-launchers = mkIf cfg.startMenuLaunchers (
stringAfter [ ] '' stringAfter [] ''
for x in applications icons; do for x in applications icons; do
echo "Copying /usr/share/$x" echo "Copying /usr/share/$x"
mkdir -p /usr/share/$x mkdir -p /usr/share/$x
@ -105,7 +108,7 @@ with builtins; with lib;
done done
'' ''
); );
populateBin = stringAfter [ ] '' populateBin = stringAfter [] ''
echo "setting up /bin..." echo "setting up /bin..."
ln -sf /init /bin/wslpath ln -sf /init /bin/wslpath
ln -sf ${pkgs.bashInteractive}/bin/bash /bin/sh ln -sf ${pkgs.bashInteractive}/bin/bash /bin/sh
@ -134,6 +137,6 @@ with builtins; with lib;
enableEmergencyMode = false; 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";
}; };
} }

View File

@ -1,19 +1,19 @@
{ lib {
, pkgs lib,
, config pkgs,
, automountPath config,
, defaultUser automountPath,
, defaultUserHome ? "/home/${defaultUser}" defaultUser,
, ... defaultUserHome ? "/home/${defaultUser}",
...
}: }:
pkgs.substituteAll { pkgs.substituteAll {
name = "syschdemd"; name = "syschdemd";
src = ./syschdemd.sh; src = ./syschdemd.sh;
dir = "bin"; dir = "bin";
isExecutable = true; isExecutable = true;
buildInputs = with pkgs; [ daemonize ]; buildInputs = with pkgs; [daemonize];
inherit defaultUser defaultUserHome; inherit defaultUser defaultUserHome;
inherit (pkgs) daemonize; inherit (pkgs) daemonize;

View File

@ -1,15 +1,19 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = [ ]; config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [];
boot.initrd.availableKernelModules = [ ]; boot.initrd.availableKernelModules = [];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
## NOTE: These filesystems are mounted by a wrapper script from nix-wsl ## NOTE: These filesystems are mounted by a wrapper script from nix-wsl
@ -43,25 +47,22 @@
# fsType = "drvfs"; # fsType = "drvfs";
# }; # };
fileSystems."/mnt/c" = fileSystems."/mnt/c" = {
{
device = "C:"; device = "C:";
fsType = "drvfs"; fsType = "drvfs";
}; };
fileSystems."/mnt/d" = fileSystems."/mnt/d" = {
{
device = "D:"; device = "D:";
fsType = "drvfs"; fsType = "drvfs";
}; };
fileSystems."/mnt/f" = fileSystems."/mnt/f" = {
{
device = "F:"; device = "F:";
fsType = "drvfs"; fsType = "drvfs";
}; };
swapDevices = [ ]; swapDevices = [];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -0,0 +1,47 @@
# 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")
];
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 = [];
fileSystems."/" =
# Might be wise to use /dev/nvme0p1 instead
{
device = "/dev/disk/by-uuid/27fc09b3-e3b7-4883-94a0-c313a0e0abe2";
fsType = "ext4";
};
fileSystems."/boot" =
# Might be wise to use /dev/nvme0p2 instead
{
device = "/dev/disk/by-uuid/EBA6-394D";
fsType = "vfat";
};
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
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -1,17 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelParams = [ "console=ttyS0,19200n8" ]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -20,17 +23,15 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/sda"; device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
swapDevices = swapDevices = [{device = "/dev/sdb";}];
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,16 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ (modulesPath + "/profiles/qemu-guest.nix") lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelParams = [ "console=ttyS0,19200n8" ]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -19,17 +23,15 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/sda"; device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
swapDevices = swapDevices = [{device = "/dev/sdb";}];
[ { device = "/dev/sdb"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,17 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelParams = [ "console=ttyS0,19200n8" ]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -20,8 +23,8 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems = { fileSystems = {
"/" = { "/" = {
@ -35,8 +38,7 @@
}; };
}; };
swapDevices = swapDevices = [{device = "/dev/sdb";}];
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,17 +1,21 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ (modulesPath + "/profiles/qemu-guest.nix") lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
boot.kernelParams = ["console=ttyS0,19200n8"]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
@ -22,14 +26,12 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/sda"; device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
swapDevices = swapDevices = [{device = "/dev/sdb";}];
[ { device = "/dev/sdb"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -0,0 +1,10 @@
age-encryption.org/v1
-> ssh-ed25519 ahbzMg QEQ0gfV00KEZFXSUMAnITVG2vAhS0IrnbbEXVsQRjXA
/iXv++nOsRRmWAu4dFTmxxC7qlCjMuTYuTa6GsYgsX0
-> ssh-ed25519 glsjZQ Lob1uedpMxsDygT/i6Pnuwi6BzdgZPAeemISakcncVM
UddBD1YezLMeCUn4UuHGIrK68AwCIwuHAobpkJdi/3U
-> Tx+>#u-grease ;A%8 W
m11Fw6roG6feroJ/o5Ro8Dv1C3Piq3bGbdV78TH9Z0URPru+srdINovMvoVqjkuZ
eHiRwb1fN0ymLRD6/WxT4ZLKbT6J5yNPCrc+
--- 88hy3b76RX3PAc0Lfms//lhuqsi2tsqmL9gFQqUMBKM
>%frPåúéÚó€+÷JY`•îŽð',„ë~<7E><>ÄôʼfÝÄ_Q2A59N/ÄV·þ ºÝ[ˆSgË3ü ß4Y(´cä}N[ Ò•ëJ¡ò6Uµ¯pvf/i§Ò+tÒTÞ^–Ø)<1A>

Some files were not shown because too many files have changed in this diff Show More