feat(hm): cpu usage now works on tmux
parent
1f511b052c
commit
3c483aeb89
111
c_.nix
111
c_.nix
|
@ -1,111 +0,0 @@
|
||||||
# a small helper that only builds on top of builtins functions
|
|
||||||
_: (builtins // (
|
|
||||||
let
|
|
||||||
formatSecondsSinceEpoch = t:
|
|
||||||
let
|
|
||||||
rem = x: y: x - x / y * y;
|
|
||||||
days = t / 86400;
|
|
||||||
secondsInDay = rem t 86400;
|
|
||||||
hours = secondsInDay / 3600;
|
|
||||||
minutes = (rem secondsInDay 3600) / 60;
|
|
||||||
seconds = rem t 60;
|
|
||||||
|
|
||||||
# Courtesy of https://stackoverflow.com/a/32158604.
|
|
||||||
z = days + 719468;
|
|
||||||
era = (if z >= 0 then z else z - 146096) / 146097;
|
|
||||||
doe = z - era * 146097;
|
|
||||||
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
|
||||||
y = yoe + era * 400;
|
|
||||||
doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
|
||||||
mp = (5 * doy + 2) / 153;
|
|
||||||
d = doy - (153 * mp + 2) / 5 + 1;
|
|
||||||
m = mp + (if mp < 10 then 3 else -9);
|
|
||||||
y' = y + (if m <= 2 then 1 else 0);
|
|
||||||
|
|
||||||
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
|
|
||||||
in
|
|
||||||
"${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}"
|
|
||||||
+ "${pad (toString minutes)}${pad (toString seconds)}";
|
|
||||||
|
|
||||||
fetchTree =
|
|
||||||
# this is the value of flake.lock#lock.nodes.${input_name}.locked
|
|
||||||
{ type
|
|
||||||
, host ? ""
|
|
||||||
, owner ? ""
|
|
||||||
, repo ? ""
|
|
||||||
, rev ? ""
|
|
||||||
, submodules ? ""
|
|
||||||
, path ? ""
|
|
||||||
, narHash ? null
|
|
||||||
, lastModified ? 0
|
|
||||||
, src ? ./.
|
|
||||||
}@info:
|
|
||||||
if info.type == "github" then
|
|
||||||
{
|
|
||||||
outPath =
|
|
||||||
fetchTarball
|
|
||||||
({
|
|
||||||
url = "https://api.${info.host or "github.com"}/repos/"
|
|
||||||
+ "${info.owner}/${info.repo}/tarball/${info.rev}";
|
|
||||||
}
|
|
||||||
// (if info ? narHash then { sha256 = info.narHash; } else { })
|
|
||||||
);
|
|
||||||
rev = info.rev;
|
|
||||||
shortRev = builtins.substring 0 7 info.rev;
|
|
||||||
lastModified = info.lastModified;
|
|
||||||
lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
|
|
||||||
narHash = info.narHash;
|
|
||||||
}
|
|
||||||
else if info.type == "git" then
|
|
||||||
{
|
|
||||||
outPath =
|
|
||||||
builtins.fetchGit
|
|
||||||
({ url = info.url; }
|
|
||||||
// (if info ? rev then { inherit (info) rev; } else { })
|
|
||||||
// (if info ? ref then { inherit (info) ref; } else { })
|
|
||||||
// (if info ? submodules then { inherit (info) submodules; } else { })
|
|
||||||
);
|
|
||||||
lastModified = info.lastModified;
|
|
||||||
lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
|
|
||||||
narHash = info.narHash;
|
|
||||||
} // (if info ? rev then {
|
|
||||||
rev = info.rev;
|
|
||||||
shortRev = builtins.substring 0 7 info.rev;
|
|
||||||
} else { })
|
|
||||||
else if info.type == "path" then
|
|
||||||
{
|
|
||||||
outPath = builtins.path {
|
|
||||||
path =
|
|
||||||
if builtins.substring 0 1 info.path != "/"
|
|
||||||
then src + ("/" + info.path) # make this absolute path by prepending ./
|
|
||||||
else info.path; # it's already an absolute path
|
|
||||||
};
|
|
||||||
narHash = info.narHash;
|
|
||||||
}
|
|
||||||
else if info.type == "tarball" then
|
|
||||||
{
|
|
||||||
outPath =
|
|
||||||
fetchTarball
|
|
||||||
({ inherit (info) url; }
|
|
||||||
// (if info ? narHash then { sha256 = info.narHash; } else { })
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if info.type == "gitlab" then
|
|
||||||
{
|
|
||||||
inherit (info) rev narHash lastModified;
|
|
||||||
outPath =
|
|
||||||
fetchTarball
|
|
||||||
({ url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; }
|
|
||||||
// (if info ? narHash then { sha256 = info.narHash; } else { })
|
|
||||||
);
|
|
||||||
shortRev = builtins.substring 0 7 info.rev;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
# FIXME: add Mercurial, tarball inputs.
|
|
||||||
throw "flake input has unsupported input type '${info.type}'";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit fetchTree;
|
|
||||||
}
|
|
||||||
)) nil
|
|
||||||
|
|
1238
flake.lock
1238
flake.lock
File diff suppressed because it is too large
Load Diff
141
flake.nix
141
flake.nix
|
@ -6,123 +6,36 @@
|
||||||
};
|
};
|
||||||
description = "My personal configuration in Nix (and some native configurations)";
|
description = "My personal configuration in Nix (and some native configurations)";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
# continously merged & rebased lightweight .lib. Basically a huge extension to c_.
|
deploy-rs.url = "github:serokell/deploy-rs";
|
||||||
nixlib.url = "github:nix-community/nixpkgs.lib";
|
std.url = "github:divnix/std";
|
||||||
agenix = {
|
hive.url = "github:divnix/hive";
|
||||||
url = "github:ryantm/agenix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
home-manager = {
|
|
||||||
url = "github:nix-community/home-manager";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
nixgl.url = "path:out-of-tree/nixGL";
|
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
||||||
# Allows default.nix to call onto flake.nix. Useful for nix eval and automations
|
|
||||||
flake-compat = {
|
|
||||||
url = "path:out-of-tree/flake-compat";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
kpcli-py = {
|
|
||||||
url = "github:rebkwok/kpcli";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
neovim-nightly-overlay = {
|
|
||||||
url = "github:nix-community/neovim-nightly-overlay";
|
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836";
|
|
||||||
};
|
|
||||||
nix-index-database = {
|
|
||||||
url = "github:mic92/nix-index-database";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
nickel.url = "github:tweag/nickel";
|
|
||||||
nix-boost.url = "git+https://git.pegasust.com/pegasust/nix-boost.git";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = { std, hive, ... }@inputs: std.growOn
|
||||||
{ nixpkgs
|
|
||||||
, agenix
|
|
||||||
, home-manager
|
|
||||||
, flake-utils
|
|
||||||
, nixgl
|
|
||||||
, rust-overlay
|
|
||||||
, flake-compat
|
|
||||||
, neovim-nightly-overlay
|
|
||||||
, nix-index-database
|
|
||||||
, nixlib
|
|
||||||
, nickel
|
|
||||||
, ...
|
|
||||||
}@_inputs:
|
|
||||||
let
|
|
||||||
# config_fn:: system -> config
|
|
||||||
# this function should take simple exports of homeConfigurations.${profile},
|
|
||||||
# nixosConfigurations.${profile}, devShells.${profile}, packages.${profile}
|
|
||||||
# and correctly produce
|
|
||||||
supported_systems = flake-utils.lib.defaultSystems;
|
|
||||||
forEachSystem = nixpkgs.lib.genAttrs supported_systems;
|
|
||||||
in
|
|
||||||
let
|
|
||||||
proj_root =
|
|
||||||
let
|
|
||||||
path = builtins.toString ./.;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit path;
|
|
||||||
configs.path = "${path}/native_configs";
|
|
||||||
scripts.path = "${path}/scripts";
|
|
||||||
secrets.path = "${path}/secrets";
|
|
||||||
testdata.path = "${path}/tests";
|
|
||||||
modules.path = "${path}/modules";
|
|
||||||
hosts.path = "${path}/hosts";
|
|
||||||
users.path = "${path}/users";
|
|
||||||
};
|
|
||||||
overlays = forEachSystem (system: import ./overlays.nix (_inputs // { inherit system; }));
|
|
||||||
pkgs = forEachSystem (system: (import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
overlays = overlays.${system};
|
|
||||||
config = {
|
|
||||||
allowUnfree = true;
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
lib = (builtins.foldl' (lhs: rhs: (nixpkgs.lib.recursiveUpdate lhs rhs)) { } [
|
|
||||||
nixpkgs.lib
|
|
||||||
nixlib.lib
|
|
||||||
]);
|
|
||||||
inputs_w_lib = forEachSystem (
|
|
||||||
system: lib.recursiveUpdate _inputs {
|
|
||||||
inherit system lib;
|
|
||||||
pkgs = pkgs.${system};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
modules = (import ./modules inputs_w_lib);
|
|
||||||
hosts = (import ./hosts inputs_w_lib);
|
|
||||||
users = (import ./users inputs_w_lib);
|
|
||||||
|
|
||||||
# {nixpkgs, agenix, home-manager, flake-utils, nixgl, rust-overlay, flake-compat
|
|
||||||
# ,pkgs, lib (extended), proj_root}
|
|
||||||
final_inputs = inputs_w_lib;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
inherit (hosts) nixosConfigurations;
|
# boilerplate
|
||||||
inherit (users) homeConfigurations;
|
inherit inputs;
|
||||||
inherit lib proj_root;
|
# All cell blocks are under ./nix/cells/<cell>/<cellblock> as `<cellblock>.nix`
|
||||||
devShells = forEachSystem (system:
|
# or `<cellblock/default.nix`
|
||||||
{default = (import ./dev-shell.nix final_inputs.${system});}
|
cellsFrom = ./nix/cells;
|
||||||
);
|
modules = ./nix/modules;
|
||||||
templates = forEachSystem (system: import ./templates final_inputs.${system});
|
|
||||||
secrets = {
|
|
||||||
pubKeys = {
|
|
||||||
hosts = hosts.pubKeys;
|
|
||||||
users = users.pubKeys;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
debug = {
|
cellBlocks =
|
||||||
inherit final_inputs hosts users modules lib inputs_w_lib pkgs nixpkgs nixlib;
|
let
|
||||||
};
|
inherit (std.blockTypes) devShells;
|
||||||
# formatter."${system}" = pkgs.nixpkgs-fmt;
|
inherit (hive.blockTypes) nixosConfigurations homeConfigurations;
|
||||||
|
in
|
||||||
|
[
|
||||||
|
(devShells "devshells")
|
||||||
|
(nixosConfigurations "host_profile")
|
||||||
|
(homeConfigurations "home_profile")
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
devShells = std.harvest [ [ "dotfiles" "devshells" ] ];
|
||||||
|
nixosConfigurations = std.harvest [ [ "dotfiles" "nixos" ] ];
|
||||||
|
homeConfigurations = std.harvest [ [ "dotfiles" "home" ] ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,8 @@ vim.opt.background = "dark";
|
||||||
vim.api.nvim_create_user_command('Dark', function(opts)
|
vim.api.nvim_create_user_command('Dark', function(opts)
|
||||||
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
||||||
---@type string
|
---@type string
|
||||||
local contrast = (opts.arg;
|
local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_light;
|
||||||
vim.g.gruvbox_contrast_dark = contrast;
|
= contrast;
|
||||||
vim.opt.background = "dark";
|
vim.opt.background = "dark";
|
||||||
end,
|
end,
|
||||||
{ nargs = "?", })
|
{ nargs = "?", })
|
||||||
|
@ -616,7 +616,7 @@ require("mason").setup({
|
||||||
},
|
},
|
||||||
check_outdated_packages_on_open = true,
|
check_outdated_packages_on_open = true,
|
||||||
},
|
},
|
||||||
-- The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration
|
-- NOTE: The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration
|
||||||
-- Which means Mason's installed path is prioritized against our local install
|
-- Which means Mason's installed path is prioritized against our local install
|
||||||
-- see: https://git.pegasust.com/pegasust/aoc/commit/b45dc32c74d84c9f787ebce7a174c9aa1d411fc2
|
-- 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
|
-- This introduces some pitfalls, so we'll take the approach of trusting user's local installation
|
||||||
|
|
|
@ -88,6 +88,11 @@ Host dev0
|
||||||
User htran
|
User htran
|
||||||
Port 22
|
Port 22
|
||||||
|
|
||||||
|
Host dev2
|
||||||
|
HostName 10.100.200.210
|
||||||
|
User htran
|
||||||
|
Port 22
|
||||||
|
|
||||||
Host dev1
|
Host dev1
|
||||||
HostName 10.100.200.220
|
HostName 10.100.200.220
|
||||||
User htran
|
User htran
|
||||||
|
|
|
@ -18,7 +18,6 @@ set-option -g renumber-windows on
|
||||||
# set -g status-interval 60
|
# set -g status-interval 60
|
||||||
# set -g status-right-style 'bg=#333333 fg=#5eacd3'
|
# set -g status-right-style 'bg=#333333 fg=#5eacd3'
|
||||||
# set -g status-right-length 50
|
# set -g status-right-length 50
|
||||||
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
|
|
||||||
# set -g status-left " "
|
# set -g status-left " "
|
||||||
|
|
||||||
# Keybinds
|
# Keybinds
|
||||||
|
|
|
@ -42,6 +42,7 @@ let
|
||||||
pkgs.nodePackages.pyright
|
pkgs.nodePackages.pyright
|
||||||
pkgs.python3Packages.pylint
|
pkgs.python3Packages.pylint
|
||||||
pkgs.python3Packages.flake8
|
pkgs.python3Packages.flake8
|
||||||
|
# FIXME: installing ansible from here just doesn't work :/
|
||||||
# pkgs.ansible-lint
|
# pkgs.ansible-lint
|
||||||
# pkgs.python38Packages.ansible
|
# pkgs.python38Packages.ansible
|
||||||
# pkgs.ansible-language-server
|
# pkgs.ansible-language-server
|
||||||
|
@ -51,7 +52,10 @@ let
|
||||||
# pkgs.rust-analyzer
|
# pkgs.rust-analyzer
|
||||||
# rust_pkgs
|
# rust_pkgs
|
||||||
# pkgs.evcxr # Rust REPL for Conjure!
|
# pkgs.evcxr # Rust REPL for Conjure!
|
||||||
];
|
] ++ lib.optionals (pkgs.stdenv.isDarwin) (let
|
||||||
|
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; in [
|
||||||
|
System CoreFoundation pkgs.cc
|
||||||
|
]);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.base.neovim = {
|
options.base.neovim = {
|
||||||
|
|
|
@ -54,8 +54,11 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/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 ];
|
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 (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 '
|
||||||
|
'';
|
||||||
programs.exa = {
|
programs.exa = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableAliases = true;
|
enableAliases = true;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,7 +35,7 @@
|
||||||
neovim-nightly-overlay = {
|
neovim-nightly-overlay = {
|
||||||
url = "github:nix-community/neovim-nightly-overlay";
|
url = "github:nix-community/neovim-nightly-overlay";
|
||||||
# Pin to a nixpkgs revision that doesn't have NixOS/nixpkgs#208103 yet
|
# Pin to a nixpkgs revision that doesn't have NixOS/nixpkgs#208103 yet
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836";
|
# inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836";
|
||||||
};
|
};
|
||||||
nix-index-database = {
|
nix-index-database = {
|
||||||
url = "github:mic92/nix-index-database";
|
url = "github:mic92/nix-index-database";
|
||||||
|
|
|
@ -37,7 +37,7 @@ in
|
||||||
# pkgs.xorg.xclock # TODO: only include if have gui # 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.zk
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{inputs, cells}: let
|
||||||
|
inherit (inputs) std nixpkgs;
|
||||||
|
|
||||||
|
in {
|
||||||
|
default = std.lib.dev.mkShell {
|
||||||
|
name = nixpkgs.lib.
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue