Introduced npins for managing github sources

This commit is contained in:
alejandro-angulo 2024-07-30 22:37:10 -07:00
parent e61790e2b9
commit c29af554fa
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
6 changed files with 156 additions and 38 deletions

View file

@ -6,7 +6,9 @@
... ...
}: let }: let
inherit (lib) mkEnableOption; inherit (lib) mkEnableOption;
inherit (pkgs) tmuxPlugins;
sources = import ../../../../npins;
cfg = config.${namespace}.apps.tmux; cfg = config.${namespace}.apps.tmux;
in { in {
options.${namespace}.apps.tmux = { options.${namespace}.apps.tmux = {
@ -23,11 +25,9 @@ in {
sensibleOnTop = true; sensibleOnTop = true;
terminal = "screen-256color"; terminal = "screen-256color";
# TOOD: Check if neovim is enabled before config vim integrations
plugins = [ plugins = [
{ {
plugin = pkgs.tmuxPlugins.resurrect; plugin = tmuxPlugins.resurrect;
extraConfig = '' extraConfig = ''
set -g @resurrect-capture-pane-contents 'on' set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-nvim 'session' set -g @resurrect-strategy-nvim 'session'
@ -35,7 +35,7 @@ in {
} }
{ {
plugin = pkgs.tmuxPlugins.continuum; plugin = tmuxPlugins.continuum;
extraConfig = '' extraConfig = ''
set -g @continuum-restore 'on' set -g @continuum-restore 'on'
''; '';
@ -43,16 +43,11 @@ in {
{ {
plugin = plugin =
pkgs.tmuxPlugins.mkTmuxPlugin tmuxPlugins.mkTmuxPlugin
{ {
pluginName = "tmux-nerd-font-window-name"; pluginName = "tmux-nerd-font-window-name";
version = "2.1.1"; version = "2.1.1";
src = pkgs.fetchFromGitHub { src = sources.tmux-nerd-font-window-name;
owner = "joshmedeski";
repo = "tmux-nerd-font-window-name";
rev = "57961cb0a99b76f20e02639d398c973d81971d05";
sha256 = "sha256-8P4jFEkcJn/JbdRAC5PCrLAGTJwFxCknllOjkD+PK9w=";
};
nativeBuildInputs = [pkgs.makeWrapper]; nativeBuildInputs = [pkgs.makeWrapper];
rtpFilePath = "tmux-nerd-font-window-name.tmux"; rtpFilePath = "tmux-nerd-font-window-name.tmux";
postInstall = '' postInstall = ''
@ -65,8 +60,8 @@ in {
}; };
} }
pkgs.tmuxPlugins.vim-tmux-navigator tmuxPlugins.vim-tmux-navigator
pkgs.tmuxPlugins.open tmuxPlugins.open
]; ];
extraConfig = '' extraConfig = ''

View file

@ -1,13 +1,12 @@
{ {
config, config,
lib, lib,
pkgs,
namespace, namespace,
... ...
}: let }: let
inherit (lib) mkEnableOption mkIf; inherit (lib) mkEnableOption mkIf;
inherit (pkgs) fetchFromGitHub;
sources = import ../../../../npins;
cfg = config.${namespace}.tools.zsh; cfg = config.${namespace}.tools.zsh;
in { in {
options.${namespace}.tools.zsh = { options.${namespace}.tools.zsh = {
@ -36,22 +35,12 @@ in {
plugins = [ plugins = [
{ {
name = "zsh-syntax-highlighting"; name = "zsh-syntax-highlighting";
src = fetchFromGitHub { src = sources.zsh-syntax-highlighting;
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
rev = "0.7.1";
sha256 = "sha256-gOG0NLlaJfotJfs+SUhGgLTNOnGLjoqnUp54V9aFJg8=";
};
file = "zsh-syntax-highlighting.zsh"; file = "zsh-syntax-highlighting.zsh";
} }
{ {
name = "powerlevel10k"; name = "powerlevel10k";
src = fetchFromGitHub { src = sources.powerlevel10k;
owner = "romkatv";
repo = "powerlevel10k";
rev = "v1.17.0";
sha256 = "sha256-fgrwbWj6CcPoZ6GbCZ47HRUg8ZSJWOsa7aipEqYuE0Q=";
};
file = "powerlevel10k.zsh-theme"; file = "powerlevel10k.zsh-theme";
} }
{ {
@ -61,12 +50,7 @@ in {
} }
{ {
name = "base16-shell"; name = "base16-shell";
src = fetchFromGitHub { src = sources.base16-shell;
owner = "chriskempson";
repo = "base16-shell";
rev = "588691ba71b47e75793ed9edfcfaa058326a6f41";
sha256 = "sha256-X89FsG9QICDw3jZvOCB/KsPBVOLUeE7xN3VCtf0DD3E=";
};
file = "base16-shell.plugin.zsh"; file = "base16-shell.plugin.zsh";
} }
]; ];

View file

@ -26,6 +26,7 @@ in {
awscli2 awscli2
direnv direnv
minio-client minio-client
npins
pre-commit pre-commit
git git
]; ];

80
npins/default.nix Normal file
View file

@ -0,0 +1,80 @@
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
mkSource =
spec:
assert spec ? type;
let
path =
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };
mkGitSource =
{
repository,
revision,
url ? null,
hash,
branch ? null,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else
assert repository.type == "Git";
let
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName repository.url revision;
in
builtins.fetchGit {
url = repository.url;
rev = revision;
inherit name;
# hash = hash;
};
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

62
npins/sources.json Normal file
View file

@ -0,0 +1,62 @@
{
"pins": {
"base16-shell": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "chriskempson",
"repo": "base16-shell"
},
"branch": "master",
"revision": "588691ba71b47e75793ed9edfcfaa058326a6f41",
"url": "https://github.com/chriskempson/base16-shell/archive/588691ba71b47e75793ed9edfcfaa058326a6f41.tar.gz",
"hash": "0w8g0gyvahkm6zqlwy6lw9ac3hragwh3hvrnvvq2082hdyq4bksz"
},
"powerlevel10k": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "romkatv",
"repo": "powerlevel10k"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"version": "v1.20.0",
"revision": "ff0311157d6b24fea21aa70699783f362b0f554f",
"url": "https://api.github.com/repos/romkatv/powerlevel10k/tarball/v1.20.0",
"hash": "1ha7qb601mk97lxvcj9dmbypwx7z5v0b7mkqahzsq073f4jnybhi"
},
"tmux-nerd-font-window-name": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "joshmedeski",
"repo": "tmux-nerd-font-window-name"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"version": "v2.1.1",
"revision": "57961cb0a99b76f20e02639d398c973d81971d05",
"url": "https://api.github.com/repos/joshmedeski/tmux-nerd-font-window-name/tarball/v2.1.1",
"hash": "1p1biwzr18skjqkjki05ki60dc5cqa9hnh6ldp4py9hw94a27zph"
},
"zsh-syntax-highlighting": {
"type": "GitRelease",
"repository": {
"type": "GitHub",
"owner": "zsh-users",
"repo": "zsh-syntax-highlighting"
},
"pre_releases": false,
"version_upper_bound": null,
"release_prefix": null,
"version": "0.8.0",
"revision": "b1379f1ee96b1fe25701c9418c75f81eaabdab56",
"url": "https://api.github.com/repos/zsh-users/zsh-syntax-highlighting/tarball/0.8.0",
"hash": "1yl8zdip1z9inp280sfa5byjbf2vqh2iazsycar987khjsi5d5w8"
}
},
"version": 3
}

View file

@ -1,8 +1,4 @@
{ {pkgs, ...}: {
config,
pkgs,
...
}: {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration-zfs.nix ./hardware-configuration-zfs.nix