wip: interface-like structure but im sadge on development with no type-safety

std
Hung 2023-06-16 16:12:54 -07:00
parent e67a18e465
commit 1537fea0bd
21 changed files with 896 additions and 820 deletions

View File

@ -1,4 +1,4 @@
# Vim Plugins
# 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

View File

@ -77,21 +77,18 @@
},
"devshell": {
"inputs": {
"flake-utils": [
"std",
"flake-utils"
],
"nixpkgs": [
"std",
"nixpkgs"
]
],
"systems": "systems"
},
"locked": {
"lastModified": 1682700442,
"narHash": "sha256-qjaAAcCYgp1pBBG7mY9z95ODUBZMtUpf0Qp3Gt/Wha0=",
"lastModified": 1686680692,
"narHash": "sha256-SsLZz3TDleraAiJq4EkmdyewSyiv5g0LZYc6vaLZOMQ=",
"owner": "numtide",
"repo": "devshell",
"rev": "fb6673fe9fe4409e3f43ca86968261e970918a83",
"rev": "fd6223370774dd9c33354e87a007004b5fd36442",
"type": "github"
},
"original": {
@ -117,10 +114,13 @@
},
"dmerge": {
"inputs": {
"haumea": "haumea_2",
"namaka": "namaka",
"haumea": [
"std",
"haumea"
],
"nixlib": [
"std",
"haumea",
"nixpkgs"
],
"yants": [
@ -129,16 +129,16 @@
]
},
"locked": {
"lastModified": 1684178600,
"narHash": "sha256-EtSQcCHRQUBBEj4vbYU0vgPUYiKP261ero5k1QfQ3Bc=",
"lastModified": 1686862774,
"narHash": "sha256-ojGtRQ9pIOUrxsQEuEPerUkqIJEuod9hIflfNkY+9CE=",
"owner": "divnix",
"repo": "dmerge",
"rev": "ac9932f26325afac5baa59cf6478432d17762a4e",
"rev": "9f7f7a8349d33d7bd02e0f2b484b1f076e503a96",
"type": "github"
},
"original": {
"owner": "divnix",
"ref": "0.2.0",
"ref": "0.2.1",
"repo": "dmerge",
"type": "github"
}
@ -248,44 +248,19 @@
},
"haumea_2": {
"inputs": {
"nixpkgs": [
"std",
"dmerge",
"nixlib"
]
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1681176209,
"narHash": "sha256-bJLDun6esIyWtwRVXcsgzGbh4UKu8wJDrPgykqPyzmg=",
"lastModified": 1685133229,
"narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=",
"owner": "nix-community",
"repo": "haumea",
"rev": "b915b66b27da3a595d77b139e945bb0a2fcac926",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "haumea",
"type": "github"
}
},
"haumea_3": {
"inputs": {
"nixpkgs": [
"std",
"paisano",
"nixpkgs"
]
},
"locked": {
"lastModified": 1681176209,
"narHash": "sha256-bJLDun6esIyWtwRVXcsgzGbh4UKu8wJDrPgykqPyzmg=",
"owner": "nix-community",
"repo": "haumea",
"rev": "b915b66b27da3a595d77b139e945bb0a2fcac926",
"rev": "34dd58385092a23018748b50f9b23de6266dffc2",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "v0.2.2",
"repo": "haumea",
"type": "github"
}
@ -333,6 +308,7 @@
"inputs": {
"nixlib": [
"std",
"haumea",
"nixpkgs"
]
},
@ -362,11 +338,11 @@
]
},
"locked": {
"lastModified": 1677330646,
"narHash": "sha256-hUYCwJneMjnxTvj30Fjow6UMJUITqHlpUGpXMPXUJsU=",
"lastModified": 1685771919,
"narHash": "sha256-3lVKWrhNXjHJB6QkZ2SJaOs4X/mmYXtY6ovPVpDMOHc=",
"owner": "nlewo",
"repo": "nix2container",
"rev": "ebca8f58d450cae1a19c07701a5a8ae40afc9efc",
"rev": "95e2220911874064b5d809f8d35f7835184c4ddf",
"type": "github"
},
"original": {
@ -375,57 +351,6 @@
"type": "github"
}
},
"namaka": {
"inputs": {
"haumea": [
"std",
"dmerge",
"haumea"
],
"nixpkgs": [
"std",
"dmerge",
"nixlib"
]
},
"locked": {
"lastModified": 1683059428,
"narHash": "sha256-ZTMqleCWmuNWhZE375gtF1j1JRkaKEUFN1AM43e7h4Y=",
"owner": "nix-community",
"repo": "namaka",
"rev": "2deba2f416454aec770bc1cc7365e39c73e6b1d7",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "v0.1.1",
"repo": "namaka",
"type": "github"
}
},
"namaka_2": {
"inputs": {
"haumea": [
"std",
"paisano",
"haumea"
],
"nixpkgs": "nixpkgs_5"
},
"locked": {
"lastModified": 1681604203,
"narHash": "sha256-oA/fW/85GmSNprghgAnZi0XeVMvW9xVuCYprzPw2hz0=",
"owner": "nix-community",
"repo": "namaka",
"rev": "1550ddc025334cff2e8ec9021256473b2ffb27e5",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "namaka",
"type": "github"
}
},
"nixago": {
"inputs": {
"flake-utils": [
@ -504,11 +429,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1686592866,
"narHash": "sha256-riGg89eWhXJcPNrQGcSwTEEm7CGxWC06oSX44hajeMw=",
"lastModified": 1686869522,
"narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0eeebd64de89e4163f4d3cf34ffe925a5cf67a05",
"rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
"type": "github"
},
"original": {
@ -519,6 +444,21 @@
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1681001314,
"narHash": "sha256-5sDnCLdrKZqxLPK4KA8+f4A3YKO/u6ElpMILvX0g72c=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "367c0e1086a4eb4502b24d872cea2c7acdd557f4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1675940568,
"narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=",
@ -534,22 +474,6 @@
"type": "github"
}
},
"nixpkgs_5": {
"locked": {
"lastModified": 1680758185,
"narHash": "sha256-sCVWwfnk7zEX8Z+OItiH+pcSklrlsLZ4TJTtnxAYREw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e19daa510e47a40e06257e205965f3b96ce0ac9",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1677063315,
@ -695,8 +619,6 @@
},
"paisano_2": {
"inputs": {
"haumea": "haumea_3",
"namaka": "namaka_2",
"nixpkgs": [
"std",
"nixpkgs"
@ -708,16 +630,16 @@
]
},
"locked": {
"lastModified": 1685757649,
"narHash": "sha256-gu21uo35i5OguZ5laGpqIFgVRcowbjvLn2mxSyNKZfQ=",
"lastModified": 1686862844,
"narHash": "sha256-m8l/HpRBJnZ3c0F1u0IyQ3nYGWE0R9V5kfORuqZPzgk=",
"owner": "paisano-nix",
"repo": "core",
"rev": "db53b8a8e2e3e557bf5ec5842b7a52ee5de04e87",
"rev": "6674b3d3577212c1eeecd30d62d52edbd000e726",
"type": "github"
},
"original": {
"owner": "paisano-nix",
"ref": "0.1.0",
"ref": "0.1.1",
"repo": "core",
"type": "github"
}
@ -786,6 +708,7 @@
"devshell": "devshell",
"dmerge": "dmerge",
"flake-utils": "flake-utils",
"haumea": "haumea_2",
"incl": "incl",
"makes": [
"std",
@ -797,18 +720,18 @@
],
"n2c": "n2c",
"nixago": "nixago",
"nixpkgs": "nixpkgs_4",
"nixpkgs": "nixpkgs_5",
"paisano": "paisano_2",
"paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor",
"paisano-tui": "paisano-tui",
"yants": "yants_2"
},
"locked": {
"lastModified": 1686337240,
"narHash": "sha256-JedAsyUIbSIhVrRWSl0R3lSWemVWsHg0w3MuzW7h4tg=",
"lastModified": 1686890041,
"narHash": "sha256-yLucgr7q8o63yJHLd5b5rF/h27ktYTQrn9rYxVxrs3E=",
"owner": "divnix",
"repo": "std",
"rev": "1bd99cec90a5cee8575f45dbc193d6dd860a5f35",
"rev": "8671b6892e45d795d7409940750832d68c929dcf",
"type": "github"
},
"original": {
@ -817,6 +740,21 @@
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
@ -858,15 +796,16 @@
"inputs": {
"nixpkgs": [
"std",
"haumea",
"nixpkgs"
]
},
"locked": {
"lastModified": 1667096281,
"narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=",
"lastModified": 1686863218,
"narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=",
"owner": "divnix",
"repo": "yants",
"rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c",
"rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d",
"type": "github"
},
"original": {

View File

@ -1,3 +1,12 @@
# Native configs
Contains all configurations that are written in their native language
Contains all configurations that are written in their native configuration language.
## Why native language?
- Easier portability
- 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.

View File

@ -293,12 +293,19 @@ vim.api.nvim_create_user_command(
-- telescope
local fb_actions = require "telescope".extensions.file_browser.actions
local tel_actions = require("telescope.actions")
local tel_actionset = require("telescope.actions.set")
local function term_height()
return vim.opt.lines:get()
end
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = false,
n = {
['<C-u>'] = function(prompt_bufnr) tel_actionset.shift_selection(prompt_bufnr, -math.floor(term_height() / 2)) end,
['<C-d>'] = function(prompt_bufnr) tel_actionset.shift_selection(prompt_bufnr, math.floor(term_height() / 2)) end,
},
},
},
@ -361,13 +368,13 @@ end, { desc = '[F]ind [A]ll files' })
remap('n', '<leader>fg', function()
require('telescope.builtin').live_grep()
end, { desc = '[F]ind by [G]rep' })
end, { desc = '[F]ind thru [G]rep' })
remap('n', '<leader>fug', function()
-- This relies on many factors: We use `rg` and that `-g '**/*'` effectively
-- drops ignore rules like the default `.gitignore` rule.
require('telescope.builtin').live_grep({ glob_pattern = '**/*' })
end, { desc = '[F]ind by [u]nrestricted [G]rep' })
end, { desc = '[F]ind thru [u]nrestricted [G]rep' })
remap('n', '<leader>fb', function()
require('telescope.builtin').buffers()
@ -427,7 +434,7 @@ end
-- Close all tabs except the first one
vim.api.nvim_set_keymap('n', '<C-t>x', ':tabdo if tabpagenr() > 1 | tabclose | endif<CR>',
{ noremap = true, silent = true })
{ noremap = true, silent = true, desc = "Close all tabs except the first one", })
-- }}}
@ -749,7 +756,6 @@ local cmp_config = {
entry_filter(entry, function(entry)
if entry.source_name == "nvim_lsp" then
log.debug('format:entry: ' .. vim.inspect(entry, { depth = 2 }))
end
end)
@ -805,7 +811,7 @@ local cmp_config = {
cmp.setup(vim.tbl_deep_extend("force", require('cmp.config.default')(), cmp_config))
-- set max autocomplete height. this prevents huge recommendations to take over the screen
vim.o.pumheight = 15 -- 15/70 is good enough ratio for me. I generally go with 80-90 max height, though
vim.o.pumblend = 15 -- semi-transparent for the art, nothing too useful
vim.o.pumblend = 10 -- semi-transparent for the art, nothing too useful (neovim recommends 0-30)
-- `/` cmdline search.
cmp.setup.cmdline('/', {
@ -864,7 +870,10 @@ require("mason").setup({
})
require('mason-lspconfig').setup({
-- ensure_installed = servers,
ensure_installed = { "pylsp", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver" },
ensure_installed = {
"pylsp", "pyright", "tailwindcss", "svelte", "astro", "lua_ls", "tsserver",
"ansiblels", "yamlls", "docker_compose_language_service", "jsonls",
},
automatic_installation = false,
})
@ -1206,7 +1215,6 @@ require('zk.commands').add("ZkGrep", function(match_ctor)
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 }

View File

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

View File

@ -1,12 +1,13 @@
# 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
{ 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 =

View File

@ -30,7 +30,7 @@ in
};
};
};
# importing shells does not mean we're enabling everything, if we do mkDefault false
# NOTE: importing shells does not mean we're enabling everything, if we do mkDefault false
# but the dilemma is, if the user import BOTH graphics.nix and shells.nix
# they will also need to do `config.base.shells.enable`
# generally, we want the behavior: import means enable

View File

@ -28,7 +28,7 @@ let
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
pkgs.nickel
pkgs.lsp-nls
pkgs.nls
pkgs.go # doesn't work, Mason installs from runtime path

View File

@ -21,6 +21,7 @@ in
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;

View File

@ -37,7 +37,6 @@ in
};
};
config = myLib.mkIf cfg.enable {
xdg.configFile."starship.toml".source = "${proj_root.config.path}//starship/starship.toml";
# nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc
programs.direnv = {
@ -68,6 +67,15 @@ in
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = let
native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
patch-nix = pkgs.lib.recursiveUpdate native ({
c.commands = [
["nix" "run" "nixpkgs#clang" "--" "--version"]
["nix" "run" "nixpkgs#gcc" "--" "--version"]
];
});
in patch-nix;
};
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true;

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,8 @@
nixpkgs-latest.url = "github:nixos/nixpkgs";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
# url = "github:pegasust/home-manager/starship-config-type";
follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nixgl.url = "path:./../../out-of-tree/nixGL";
@ -40,7 +41,6 @@
url = "github:mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
nickel.url = "github:tweag/nickel";
};
outputs =
@ -51,7 +51,6 @@
, flake-utils
, kpcli-py
, neovim-nightly-overlay
, nickel
, nix-boost
, nixpkgs-latest
, ...

View File

@ -3,7 +3,6 @@ flake_input@{ kpcli-py
, rust-overlay
, neovim-nightly-overlay
, system
, nickel
, nix-boost
, nixpkgs-latest
, ...
@ -60,10 +59,6 @@ let
rust4normi = nightlyRustWithExts rust-default-components;
});
nickel = (final: prev: {
inherit (flake_input.nickel.packages.${system})
lsp-nls nickel nickelWasm;
});
vimPlugins = (final: prev: {
inherit (nixpkgs-latest.legacyPackages.${system}) vimPlugins;
@ -76,6 +71,5 @@ in
neovim-nightly-overlay.overlay
rust
kpcli-py
nickel
vimPlugins
]

View File

@ -26,5 +26,6 @@ in
(
builtins.readFile yamlPath)
"any-output.json"));
# TODO: fromToml?
fromTOML = builtins.fromTOML;
fromJSON = builtins.fromJSON;
}

View File

@ -1,9 +0,0 @@
{inputs, cell}: {
nerd_font_module = {config, pkgs, ...}: {
fonts.fontconfig.enable = true;
home.packages = [
(pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
];
base.alacritty.font.family = "Hack Nerd Font Mono";
};
}

View File

@ -0,0 +1,241 @@
# This is an interface for home-profiles and should not contain opinionated
# configurations. It should provide alternative configurations, aggregates
# or new configurations
_imports@{inputs, cell}: let
namespace = "repo";
imports = _imports // {inherit namespace;};
in {
git = { config , lib , ... }: let
cfg = config."${namespace}".git;
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
default-user = "Pegasust";
default-email = "pegasucksgg@gmail.com";
in {
options."${namespace}".git = {
aliases = lib.mkOption {
type = lib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
};
name = lib.mkOption {
type = lib.types.str;
default = default-user;
description = "Git username that appears on commits";
example = default-user;
};
email = lib.mkOption {
type = lib.types.str;
default = default-email;
example = default-email;
description = "Git email that appears on commits";
};
ignores = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
".DS_Store" # MacOS users, amrite
];
description = ''
.gitignore patterns that are applied in every "${namespace}"sitory.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = lib.mkOption {
type = lib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
};
};
# TODO : anyway to override configuration?
# idk wtf I was thinking about. there is no context in this question
config.programs.git = {
inherit (cfg) enable ignores;
userName = cfg.name;
userEmail = cfg.email;
aliases = baseAliases // cfg.aliases;
extraConfig = {
# TODO: in the case of darwin, git always open up the built-in keychain.
# possibly something we can't really control since we don't have access to `nix-darwin`
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
};
lfs.enable = true;
};
};
alacritty = {config, lib}: let
inherit (inputs.cells.repo.lib) fromYAML;
cfg = config."${namespace}".alacritty;
in {
options."${namespace}".alacritty = {
font.family = lib.mkOption {
type = lib.types.nullOr lib.types.singleLineStr;
default = null;
description = ''
The font family for Alacritty
'';
example = "DroidSansMono NF";
};
font.size = lib.mkOption {
type = lib.types.nullOr lib.types.number;
default = null;
description = ''
The default font size for Alacritty. This is probably measured in px.
'';
example = 7.0;
};
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enables alacritty
'';
example = true;
};
config-file = lib.mkOption {
type = lib.types.path;
description = "Path to alacritty yaml";
default = null;
example = "./config/alacritty.yaml";
};
};
config.programs.alacritty = {
enable = cfg.enable;
settings = let ;
actualConfig = if cfg.config-file != null then fromYAML (builtins.readFile cfg.config-file) else {};
in lib.recursiveUpdate actualConfig {
font.normal.family = opt-toNullable(opt-leftmostSome (builtins.map opt-fromNullable [
cfg.font.family actualConfig.font.family actualConfig.font.normal.family
]));
font.size = cfg.font.size or actualConfig.font.size or 7.0;
};
};
};
# TODO: chromium is not really supported on darwin
private_chromium = { config, pkgs, lib, ... }: let
cfg = config."${namespace}".private_chromium;
in {
options."${namespace}".private_chromium = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Enable extremely lightweight chromium with vimium plugin
'';
};
};
config = lib.mkIf (cfg.enable) {
# home.packages = [pkgs.ungoogled-chromium];
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;
crxPath = builtins.fetchurl {
url = "https://clients2.google.com/service/update2/crx" +
"?response=redirect" +
"&acceptformat=crx2,crx3" +
"&prodversion=${browserVersion}" +
"&x=id%3D${id}%26installsource%3Dondemand%26uc";
name = "${id}.crx";
inherit sha256;
};
version = extVersion;
};
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
in
[
# vimium
(mkChromiumExt {
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
extVersion = "1.67.4";
})
];
};
};
};
darwin-spotlight = { lib, pkgs, config, ... }: {
# This patch exists since Darwin's search bar requires solid apps and not
# symlinked
# TODO: QA
# - [x] works for base case
# - [x] works for repeated case
# - [ ] works after base case, then removed
# - [ ] works for repeated case, then removed
# Copy GUI apps to "~/Applications/Home Manager Apps"
# Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334
home.activation.patch-spotlight =
if pkgs.stdenv.isDarwin then
let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in
lib.hm.dag.entryAfter [ "linkGeneration" ] ''
# Install MacOS applications to the user environment.
HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state
if [ -e "$HM_APPS" ]; then
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
fi
$DRY_RUN_CMD mkdir -p "$HM_APPS"
# .app dirs need to be actual directories for Finder to detect them as Apps.
# In the env of Apps we build, the .apps are symlinks. We pass all of them as
# arguments to cp and make it dereference those using -H
$DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS"
$DRY_RUN_CMD chmod +w -R "$HM_APPS"
''
else
"";
# We need this in case upstream home-manager changes the behavior of linking
# applications
home.activation.remove-patch-spotlight =
if pkgs.stdenv.isDarwin then
lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state
if [ -e "$HM_APPS" ]; then
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
fi
''
else
"";
};
}

View File

@ -0,0 +1,40 @@
{inputs, cell, namespace}: { pkgs, config, lib, ... }:
let
cfg = config."${namespace}".graphics;
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
types = lib.types;
in
{
imports = [ ./shells.nix ];
options."${namespace}".nixgl = {
enable = lib.mkEnableOption "nixgl";
useNixGL = {
package = lib.mkPackageOption pkgs "nixGL package" {
default = [
"nixgl"
"auto"
"nixGLDefault"
];
};
defaultPackage = lib.mkOption {
type = types.nullOr (types.enum [ "nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee" ]);
description = "Which nixGL package to be aliased as `nixGL` on the shell";
default = null;
example = "nixGLIntel";
};
};
};
# NOTE: importing shells does not mean we're enabling everything, if we do mkDefault false
# but the dilemma is, if the user import BOTH graphics.nix and shells.nix
# they will also need to do `config."${namespace}".shells.enable`
# generally, we want the behavior: import means enable
config = lib.mkIf cfgEnable {
"${namespace}".graphics._enable = lib.mkForce true;
"${namespace}".shells = {
shellAliases = lib.mkIf (cfg.useNixGL.defaultPackage != null) {
nixGL = cfg.useNixGL.defaultPackage;
};
};
home.packages = [ cfg.useNixGL.package ];
};
}

View File

@ -0,0 +1,121 @@
{inputs, cell, namespace}: { config
, lib
, pkgs
, ...
}:
let cfg = config."${namespace}".shells;
in
{
options."${namespace}".shells = {
enable = lib.mkOption {
type = lib.types.bool;
description = "Enable umbrella shell configuration";
default = true;
example = false;
};
shellInitExtra = lib.mkOption {
type = lib.types.str;
description = "Extra shell init. The syntax should be sh-compliant";
default = "";
example = ''
# X11 support for WSL
export DISPLAY=$(ip route list default | awk '{print $3}'):0
export LIBGL_ALWAYS_INDIRECT=1
'';
};
shellAliases = lib.mkOption {
type = lib.types.attrs;
description = "Shell command aliases";
default = { };
example = {
nixGL = "nixGLIntel";
};
};
};
config = lib.mkIf cfg.enable {
# nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc
programs.direnv = {
enable = true;
nix-direnv.enable = true;
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
};
# z <path> as smarter cd
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
programs.tmux = {
enable = true;
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [ cpu net-speed ];
extraConfig = (builtins.readFile "${proj_root.config.path}/tmux/tmux.conf");
};
xdg.configFile."tmux/tmux.conf".text = lib.mkOrder 600 ''
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
'';
# Colored ls
programs.exa = {
enable = true;
enableAliases = true;
};
# Make the shell look beautiful
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = let
native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
patch-nix = pkgs.lib.recursiveUpdate native ({
c.commands = [
["nix" "run" "nixpkgs#clang" "--" "--version"]
["nix" "run" "nixpkgs#gcc" "--" "--version"]
];
});
in patch-nix;
};
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true;
programs.bash = {
enable = true;
enableCompletion = true;
initExtra = cfg.shellInitExtra or "";
};
programs.zsh = {
enable = true;
enableCompletion = true;
enableAutosuggestions = true;
shellAliases = {
nix-rebuild = "sudo nixos-rebuild switch";
hm-switch = "home-manager switch --flake";
} // (cfg.shellAliases or { });
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
oh-my-zsh = {
enable = true;
plugins = [
"git" # git command aliases: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git#aliases
"command-not-found" # suggests which package to install; does not support nixos (we have solution already)
"gitignore" # `gi list` -> `gi java >>.gitignore`
"ripgrep" # adds completion for `rg`
"rust" # compe for rustc/cargo
"poetry" # compe for poetry - Python's cargo
];
};
sessionVariables = {
# Vim mode on the terminal
# VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true;
# VI_MODE_SET_CURSOR = true;
# ZVM_VI_ESCAPE_BINDKEY = "";
ZVM_READKEY_ENGINE = "$ZVM_READKEY_ENGINE_NEX";
ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
};
initExtra = (cfg.shellInitExtra or "") + ''
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
'';
};
};
}

View File

@ -0,0 +1,60 @@
_imports@{inputs, cell}: let
namespace = "repo";
imports = _imports // {inherit namespace;};
in {
neovim = import ./neovim.nix imports;
nerd_font_module = {config, pkgs, ...}: {
imports = [
import inputs.cells."${namespace}"
];
fonts.fontconfig.enable = true;
home.packages = [
(pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
];
"${namespace}".alacritty.font.family = "Hack Nerd Font Mono";
};
secrets = {
age.secrets.s3fs = {
file = "${inputs.self}/secrets/s3fs.age";
# mode = "600"; # owner + group only
# owner = "hungtr";
# group = "users";
};
age.secrets."s3fs.digital-garden" = {
file = "${inputs.self}/secrets/s3fs.digital-garden.age";
};
age.secrets._nhitrl_cred = {
file = "${inputs.self}/secrets/_nhitrl.age";
};
age.secrets."wifi.env" = {
file = "${inputs.self}/secrets/wifi.env.age";
};
};
ssh = {config, lib, ...}: let cfg = config."${namespace}".ssh; in {
options."${namespace}".ssh.enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Enables SSH
'';
};
config.programs.ssh = {
inherit (cfg) enable;
forwardAgent = true;
includes = ["${inputs.self}/native_configs/ssh/config"];
};
};
alacritty = {config, lib,...}: let cfg = config."${namespace}".alacritty; in {
imports = [
import "${inputs.cells.repo.home-modules.alacritty}"
];
configs."${namespace}".alacritty = {
enable = true;
config-file = "${inputs.self}//native-configs/alacritty/alacritty.yml";
};
};
}

View File

@ -0,0 +1,181 @@
# TODO: vim-plug and Mason supports laziness. Probably worth it to explore incremental dependencies based on the project TODO: just install these things, then symlink to mason's bin directory
#
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
# might be different from `home-manager`'s (~/.nix_profile/bin/jq)
{inputs, cell, namespace}: { pkgs, lib, config, ... }:
let
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
# and is added to the path after wrapping.
# check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand`
# see: :/--suffix.*PATH
# there should be mentions of additional packages
my_neovim = pkgs.neovim-unwrapped;
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;
};
};
config = lib.mkIf config.base.neovim.enable {
# home-manager
programs.neovim = {
enable = true;
package = my_neovim;
viAlias = true;
vimAlias = true;
withPython3 = true;
withNodeJs = true;
# NOTE: this adds path to the wrapped version of neovim
extraPackages = nvim_pkgs;
extraLuaConfig = (builtins.readFile "${inputs.self}/native_configs/neovim/init.lua");
plugins = (let inherit (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,35 @@
{inputs, cell}: let
namespace = "repo";
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution
''
echo "$yamlContent" | yq >$out
'')
{ });
in {
fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
# ctor
opt-some = a: [a];
opt-none = [];
opt-none_thunk = _: [];
# from-to null
opt-fromNullable = nullable: if nullable == null then [] else [nullable];
opt-toNullable = opt-fork (a:a) (_: null);
opt-map = builtins.map;
opt-filter = builtins.filter;
opt-fork = on_some: on_none: opt: if opt == [] then (on_none null) else (on_some (builtins.elemAt opt 0));
opt-unwrap = opt-fork (a:a) (_: throw "opt-unwrap: expected some, got none");
opt-unwrapOrElse = opt-fork (a:a);
opt-unwrapOr = fallback_val: opt-fork (a:a) (_: fallback_val);
opt-orElse = opt: fallback_opt: opt-fork (opt-some) (opt-none_thunk) (opt ++ fallback_opt);
opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [] opts;
}