Compare commits
5 Commits
bbcc5a14b7
...
3c483aeb89
Author | SHA1 | Date |
---|---|---|
Hung | 3c483aeb89 | |
Hung | 1f511b052c | |
Hung | 17937c2146 | |
Hung | 335efeb2d9 | |
Hung | b7c3707213 |
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
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
pkgs.rust4cargo
|
pkgs.rust4cargo
|
||||||
pkgs.sops
|
pkgs.sops
|
||||||
pkgs.ssh-to-age
|
pkgs.ssh-to-age
|
||||||
|
pkgs.go
|
||||||
|
pkgs.gopls
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
1066
flake.lock
1066
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" ] ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,13 +147,13 @@ vim.opt.scrolloff = 30;
|
||||||
vim.opt.signcolumn = "yes";
|
vim.opt.signcolumn = "yes";
|
||||||
vim.opt.colorcolumn = "80";
|
vim.opt.colorcolumn = "80";
|
||||||
|
|
||||||
vim.opt.background = "light";
|
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.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_dark;
|
local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_light;
|
||||||
vim.g.gruvbox_contrast_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 = {
|
||||||
|
|
|
@ -52,11 +52,13 @@ in
|
||||||
};
|
};
|
||||||
programs.tmux = {
|
programs.tmux = {
|
||||||
enable = true;
|
enable = true;
|
||||||
configBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
|
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
|
||||||
plugins =
|
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [ cpu net-speed ];
|
||||||
let inherit (pkgs.tmuxPlugins) cpu net-speed;
|
extraConfig = (builtins.readFile "${proj_root.config.path}/tmux/tmux.conf");
|
||||||
in [ cpu net-speed ];
|
|
||||||
};
|
};
|
||||||
|
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
|
@ -16,7 +16,7 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
home-manager = {
|
home-manager = {
|
||||||
url = "github:Pegasust/home-manager";
|
url = "github:nix-community/home-manager";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
@ -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";
|
||||||
|
@ -202,6 +202,7 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
nerd_font_module
|
nerd_font_module
|
||||||
|
{ base.keepass.enable = pkgs.lib.mkForce false; }
|
||||||
];
|
];
|
||||||
extraSpecialArgs = mkModuleArgs {
|
extraSpecialArgs = mkModuleArgs {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
|
|
@ -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.
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,65 +1,81 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import urllib3
|
# execution: fetch.py >nvidia_versions.json
|
||||||
|
|
||||||
|
import http.client
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
http = urllib3.PoolManager()
|
NV_FREE_X86_URL = "download.nvidia.com"
|
||||||
dl_dir = http.request("GET", "https://download.nvidia.com/XFree86/Linux-x86_64/")
|
POTENTIAL_SHA256_EXTS = [".sha256sum", ".sha256"]
|
||||||
|
RIGHT_PAD = " " * 20
|
||||||
|
|
||||||
# print(f"{dl_dir.status=}\n{dl_dir.data=}")
|
conn = http.client.HTTPSConnection(NV_FREE_X86_URL)
|
||||||
|
conn.request("GET", "/XFree86/Linux-x86_64/")
|
||||||
|
response = conn.getresponse()
|
||||||
|
dir_html = response.read()
|
||||||
|
|
||||||
assert (dl_dir.status < 400), "Error probably occurred"
|
assert (response.status < 400), "Error occurred fetching for source from"
|
||||||
|
|
||||||
def find_versions(dir_html: bytes) -> list[str]:
|
def scrape_driver_versions(dir_html: bytes):
|
||||||
# this algorithm obviously need recursion because we need to discover the items
|
# The idea is to recursively follows all interesting `src` from `<a href={src}>`
|
||||||
def _rec(dir_html: bytes, start: int = 0, so_far: list[str] = []) -> list[str]:
|
def _rec(dir_html: bytes, href_url_start: int = 0, so_far: list[str] = []) -> list[str]:
|
||||||
MATCH_START = b"<span class=\'dir\'><a href=\'"
|
MATCH_START = b"<span class=\'dir\'><a href=\'"
|
||||||
potential_start = dir_html.find(MATCH_START, start)
|
href_url_start = dir_html.find(MATCH_START, href_url_start)
|
||||||
if potential_start == -1:
|
if href_url_start == -1: # EOF
|
||||||
return so_far
|
return so_far
|
||||||
# check that it starts with a number
|
|
||||||
potential_version_start = potential_start + len(MATCH_START)
|
# version href should start with a number
|
||||||
|
potential_version_start = href_url_start + len(MATCH_START)
|
||||||
p = potential_version_start
|
p = potential_version_start
|
||||||
if not (dir_html[p: p+1].decode().isnumeric()):
|
if not (dir_html[p: p+1].decode().isnumeric()):
|
||||||
return _rec(dir_html, potential_version_start, so_far)
|
return _rec(dir_html, potential_version_start, so_far)
|
||||||
|
|
||||||
# this thing matches, add to so_far and continue
|
|
||||||
version_end = dir_html.find(b"/", potential_version_start)
|
version_end = dir_html.find(b"/", potential_version_start)
|
||||||
assert version_end != -1, "There should be matching /"
|
assert version_end != -1, "Should have end-signaling /"
|
||||||
so_far.append(dir_html[potential_version_start:version_end].decode())
|
so_far.append(dir_html[potential_version_start:version_end].decode())
|
||||||
return _rec(dir_html, version_end, so_far)
|
return _rec(dir_html, version_end, so_far)
|
||||||
return _rec(dir_html, 0, [])
|
|
||||||
|
|
||||||
versions = find_versions(dl_dir.data)
|
|
||||||
# print("\n".join(versions))
|
|
||||||
|
|
||||||
download_urls = lambda ver: [f"https://download.nvidia.com/XFree86/Linux-x86_64/{ver}/NVIDIA-Linux-x86_64-{ver}.run"]
|
versions = _rec(dir_html, 0, [])
|
||||||
sha256_urls = lambda ver: [f"{url}{dl_ext}" for dl_ext in [".sha256sum", ".sha256"] for url in download_urls(ver)]
|
num_versions = len(versions)
|
||||||
def req_monad(url: str, err_fn, then_fn):
|
for i, version in enumerate(versions):
|
||||||
res = http.request("GET", url)
|
print(f"[{i+1}/{num_versions}] Processing version {version}{RIGHT_PAD}", end="\r", file=sys.stderr)
|
||||||
if res.status >= 400:
|
yield version
|
||||||
return err_fn(res.status)
|
print()
|
||||||
return then_fn(res.data)
|
|
||||||
|
|
||||||
identity = lambda e: e
|
versions = scrape_driver_versions(dir_html)
|
||||||
none_id = lambda _: None
|
|
||||||
|
|
||||||
def get_sha256(version: str) -> str | None:
|
download_urls_of = lambda ver: [f"/XFree86/Linux-x86_64/{ver}/NVIDIA-Linux-x86_64-{ver}.run"]
|
||||||
for url in sha256_urls(version):
|
sha256_urls_of = lambda ver: [
|
||||||
res = http.request("GET", url)
|
f"{url}{dl_ext}"
|
||||||
# print(f"attempting: {url}")
|
for dl_ext in POTENTIAL_SHA256_EXTS
|
||||||
if res.status < 400:
|
for url in download_urls_of(ver)
|
||||||
return res.data.decode().split()[0]
|
]
|
||||||
|
|
||||||
|
def sha256_of(version: str) -> str | None:
|
||||||
|
if int(version.split(".")[0]) < 256:
|
||||||
|
# Has 3 different packages that we should probably not bother
|
||||||
|
return None
|
||||||
|
for url in sha256_urls_of(version):
|
||||||
|
conn = http.client.HTTPSConnection(NV_FREE_X86_URL)
|
||||||
|
conn.request("GET", url)
|
||||||
|
response = conn.getresponse()
|
||||||
|
if response.status < 400:
|
||||||
|
return response.read().decode().split()[0]
|
||||||
|
print(f"No sha256 for {version}{RIGHT_PAD}", file=sys.stderr)
|
||||||
return None
|
return None
|
||||||
fetch_data = [(v, download_urls(v)[0], get_sha256(v)) for v in versions]
|
|
||||||
fetch_data.append(("latest", *fetch_data[-1][1:]))
|
|
||||||
|
|
||||||
# print(fetch_data)
|
def fetch(version: str):
|
||||||
|
dl_url = download_urls_of(version)[0]
|
||||||
|
sha256 = sha256_of(version)
|
||||||
|
return (version, dl_url, sha256)
|
||||||
|
|
||||||
|
fetch_data = [fetch(v) for v in versions]
|
||||||
|
fetch_data.append(("latest", *fetch_data[-1][1:]))
|
||||||
|
|
||||||
# now print the JSON object
|
# now print the JSON object
|
||||||
print(json.dumps({
|
print(json.dumps({
|
||||||
version: {
|
version: {
|
||||||
"url": dl_url,
|
"url": f"https://{NV_FREE_X86_URL}{dl_url}",
|
||||||
"sha256": sha256
|
"sha256": sha256
|
||||||
} for (version, dl_url, sha256) in fetch_data if sha256 is not None}, indent=4))
|
} for (version, dl_url, sha256) in fetch_data if sha256 is not None}, indent=4))
|
||||||
# execution: fetch.py >nvidia_versions.json
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
nixGLIntel = pkgs.nixGLIntel;
|
nixGLIntel = pkgs.nixGLIntel;
|
||||||
nixVulkanNvidia = pkgs.auto.nixVulkanNvidia;
|
nixVulkanNvidia = pkgs.auto.nixVulkanNvidia;
|
||||||
nixVulkanIntel = pkgs.nixVulkanIntel;
|
nixVulkanIntel = pkgs.nixVulkanIntel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# deprecated attributes for retro compatibility
|
# deprecated attributes for retro compatibility
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"256.25": {
|
"256.25": {
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/256.25/NVIDIA-Linux-x86_64-256.25.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/256.25/NVIDIA-Linux-x86_64-256.25.run",
|
||||||
|
@ -539,6 +540,10 @@
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/470.161.03/NVIDIA-Linux-x86_64-470.161.03.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/470.161.03/NVIDIA-Linux-x86_64-470.161.03.run",
|
||||||
"sha256": "5da82a7f8c76e781e7d7f0be7b798db4d344f26bd4facf9abcf3c71c71fe7640"
|
"sha256": "5da82a7f8c76e781e7d7f0be7b798db4d344f26bd4facf9abcf3c71c71fe7640"
|
||||||
},
|
},
|
||||||
|
"470.182.03": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/470.182.03/NVIDIA-Linux-x86_64-470.182.03.run",
|
||||||
|
"sha256": "3dbc1408fc48b865d3ddacefc45f4a3fc13b90b83a628ee546b0082ab2c3fc79"
|
||||||
|
},
|
||||||
"510.108.03": {
|
"510.108.03": {
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/510.108.03/NVIDIA-Linux-x86_64-510.108.03.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/510.108.03/NVIDIA-Linux-x86_64-510.108.03.run",
|
||||||
"sha256": "410a515e78df29c2cba4ac0b497889ce0ff1b04cfc711ff889e2dfc80f0da0d8"
|
"sha256": "410a515e78df29c2cba4ac0b497889ce0ff1b04cfc711ff889e2dfc80f0da0d8"
|
||||||
|
@ -547,6 +552,10 @@
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/515.86.01/NVIDIA-Linux-x86_64-515.86.01.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/515.86.01/NVIDIA-Linux-x86_64-515.86.01.run",
|
||||||
"sha256": "141777e1ca2f11e97d8d33260213f1be327eb73922ae22f4ddab404bb2ef4664"
|
"sha256": "141777e1ca2f11e97d8d33260213f1be327eb73922ae22f4ddab404bb2ef4664"
|
||||||
},
|
},
|
||||||
|
"515.105.01": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/515.105.01/NVIDIA-Linux-x86_64-515.105.01.run",
|
||||||
|
"sha256": "9dd2221f26c847c864dfe80cc8533f322c5f4dfaa2939cf54a934b8f7a2f6a0d"
|
||||||
|
},
|
||||||
"525.53": {
|
"525.53": {
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.53/NVIDIA-Linux-x86_64-525.53.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.53/NVIDIA-Linux-x86_64-525.53.run",
|
||||||
"sha256": "74bb0971f04f1dddd3c4641c891706fb96e8de52e22f6079e50de76d3a51687f"
|
"sha256": "74bb0971f04f1dddd3c4641c891706fb96e8de52e22f6079e50de76d3a51687f"
|
||||||
|
@ -563,8 +572,28 @@
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.78.01/NVIDIA-Linux-x86_64-525.78.01.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.78.01/NVIDIA-Linux-x86_64-525.78.01.run",
|
||||||
"sha256": "43da42d2bf69bc37ea9c7c0fa02f52db0dcc483c272f52edacad89a5cb495a93"
|
"sha256": "43da42d2bf69bc37ea9c7c0fa02f52db0dcc483c272f52edacad89a5cb495a93"
|
||||||
},
|
},
|
||||||
|
"525.85.05": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.85.05/NVIDIA-Linux-x86_64-525.85.05.run",
|
||||||
|
"sha256": "ea63b4253403b224bb7313a8977a920dfe9d203d661dd5f6fc26585a70179140"
|
||||||
|
},
|
||||||
|
"525.89.02": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.89.02/NVIDIA-Linux-x86_64-525.89.02.run",
|
||||||
|
"sha256": "0e412c88c5bd98f842a839a6f64614f20e4c0950ef7cffb12b158a71633593e9"
|
||||||
|
},
|
||||||
|
"525.105.17": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.105.17/NVIDIA-Linux-x86_64-525.105.17.run",
|
||||||
|
"sha256": "c635a21a282c9b53485f19ebb64a0f4b536a968b94d4d97629e0bc547a58142a"
|
||||||
|
},
|
||||||
|
"530.30.02": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.30.02/NVIDIA-Linux-x86_64-530.30.02.run",
|
||||||
|
"sha256": "47fddbbd7a22ba661923dbce6e7f51eec54df68050c406cc0490c3bfbede7963"
|
||||||
|
},
|
||||||
|
"530.41.03": {
|
||||||
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.41.03/NVIDIA-Linux-x86_64-530.41.03.run",
|
||||||
|
"sha256": "ae27a16a968c85503f5d161dda343c1602612b025f4aee15f92e2ea0acb784b1"
|
||||||
|
},
|
||||||
"latest": {
|
"latest": {
|
||||||
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/525.78.01/NVIDIA-Linux-x86_64-525.78.01.run",
|
"url": "https://download.nvidia.com/XFree86/Linux-x86_64/530.41.03/NVIDIA-Linux-x86_64-530.41.03.run",
|
||||||
"sha256": "43da42d2bf69bc37ea9c7c0fa02f52db0dcc483c272f52edacad89a5cb495a93"
|
"sha256": "ae27a16a968c85503f5d161dda343c1602612b025f4aee15f92e2ea0acb784b1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
overlays.nix
18
overlays.nix
|
@ -5,8 +5,9 @@ flake_input@{ kpcli-py
|
||||||
, system
|
, system
|
||||||
, nickel
|
, nickel
|
||||||
, nix-boost
|
, nix-boost
|
||||||
, ...
|
, ...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
kpcli-py = (final: prev: {
|
kpcli-py = (final: prev: {
|
||||||
# use python3.9, which works because of cython somehow?
|
# use python3.9, which works because of cython somehow?
|
||||||
kpcli-py = final.poetry2nix.mkPoetryApplication {
|
kpcli-py = final.poetry2nix.mkPoetryApplication {
|
||||||
|
@ -21,8 +22,7 @@ flake_input@{ kpcli-py
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
kpcli = super.kpcli.overridePythonAttrs (old: {
|
kpcli = super.kpcli.overridePythonAttrs (old: {
|
||||||
buildInputs = (old.buildInputs or [ ]) ++ [self.setuptools];
|
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools ];
|
||||||
src = old.src;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
# ubersmith = super.ubersmith.overridePythonAttrs (old: {
|
# ubersmith = super.ubersmith.overridePythonAttrs (old: {
|
||||||
|
@ -43,7 +43,7 @@ flake_input@{ kpcli-py
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
rust = (final: prev:
|
rust = (final: prev:
|
||||||
let
|
let
|
||||||
nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
|
nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
|
||||||
toolchain: (toolchain.minimal.override {
|
toolchain: (toolchain.minimal.override {
|
||||||
|
@ -53,17 +53,19 @@ flake_input@{ kpcli-py
|
||||||
# https://rust-lang.github.io/rustup/concepts/profiles.html
|
# https://rust-lang.github.io/rustup/concepts/profiles.html
|
||||||
rust-default-components = [ "rust-docs" "rustfmt" "clippy" ];
|
rust-default-components = [ "rust-docs" "rustfmt" "clippy" ];
|
||||||
rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ];
|
rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ];
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
rust4devs = nightlyRustWithExts rust-dev-components;
|
rust4devs = nightlyRustWithExts rust-dev-components;
|
||||||
rust4cargo = nightlyRustWithExts [ ];
|
rust4cargo = nightlyRustWithExts [ ];
|
||||||
rust4normi = nightlyRustWithExts rust-default-components;
|
rust4normi = nightlyRustWithExts rust-default-components;
|
||||||
});
|
});
|
||||||
|
|
||||||
nickel = (final: prev: {
|
nickel = (final: prev: {
|
||||||
inherit (flake_input.nickel.packages.${system})
|
inherit (flake_input.nickel.packages.${system})
|
||||||
lsp-nls nickel nickelWasm;
|
lsp-nls nickel nickelWasm;
|
||||||
});
|
});
|
||||||
in [
|
in
|
||||||
|
[
|
||||||
nix-boost.overlays.default
|
nix-boost.overlays.default
|
||||||
nixgl.overlays.default
|
nixgl.overlays.default
|
||||||
rust-overlay.overlays.default
|
rust-overlay.overlays.default
|
||||||
|
|
Loading…
Reference in New Issue