diff --git a/modules/home/apps/tmux/default.nix b/modules/home/apps/tmux/default.nix index c7503c9..47128b2 100644 --- a/modules/home/apps/tmux/default.nix +++ b/modules/home/apps/tmux/default.nix @@ -6,7 +6,9 @@ ... }: let inherit (lib) mkEnableOption; + inherit (pkgs) tmuxPlugins; + sources = import ../../../../npins; cfg = config.${namespace}.apps.tmux; in { options.${namespace}.apps.tmux = { @@ -23,11 +25,9 @@ in { sensibleOnTop = true; terminal = "screen-256color"; - # TOOD: Check if neovim is enabled before config vim integrations - plugins = [ { - plugin = pkgs.tmuxPlugins.resurrect; + plugin = tmuxPlugins.resurrect; extraConfig = '' set -g @resurrect-capture-pane-contents 'on' set -g @resurrect-strategy-nvim 'session' @@ -35,7 +35,7 @@ in { } { - plugin = pkgs.tmuxPlugins.continuum; + plugin = tmuxPlugins.continuum; extraConfig = '' set -g @continuum-restore 'on' ''; @@ -43,16 +43,11 @@ in { { plugin = - pkgs.tmuxPlugins.mkTmuxPlugin + tmuxPlugins.mkTmuxPlugin { pluginName = "tmux-nerd-font-window-name"; version = "2.1.1"; - src = pkgs.fetchFromGitHub { - owner = "joshmedeski"; - repo = "tmux-nerd-font-window-name"; - rev = "57961cb0a99b76f20e02639d398c973d81971d05"; - sha256 = "sha256-8P4jFEkcJn/JbdRAC5PCrLAGTJwFxCknllOjkD+PK9w="; - }; + src = sources.tmux-nerd-font-window-name; nativeBuildInputs = [pkgs.makeWrapper]; rtpFilePath = "tmux-nerd-font-window-name.tmux"; postInstall = '' @@ -65,8 +60,8 @@ in { }; } - pkgs.tmuxPlugins.vim-tmux-navigator - pkgs.tmuxPlugins.open + tmuxPlugins.vim-tmux-navigator + tmuxPlugins.open ]; extraConfig = '' diff --git a/modules/home/tools/zsh/default.nix b/modules/home/tools/zsh/default.nix index a4f7b90..81d0f7d 100644 --- a/modules/home/tools/zsh/default.nix +++ b/modules/home/tools/zsh/default.nix @@ -1,13 +1,12 @@ { config, lib, - pkgs, namespace, ... }: let inherit (lib) mkEnableOption mkIf; - inherit (pkgs) fetchFromGitHub; + sources = import ../../../../npins; cfg = config.${namespace}.tools.zsh; in { options.${namespace}.tools.zsh = { @@ -36,22 +35,12 @@ in { plugins = [ { name = "zsh-syntax-highlighting"; - src = fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-syntax-highlighting"; - rev = "0.7.1"; - sha256 = "sha256-gOG0NLlaJfotJfs+SUhGgLTNOnGLjoqnUp54V9aFJg8="; - }; + src = sources.zsh-syntax-highlighting; file = "zsh-syntax-highlighting.zsh"; } { name = "powerlevel10k"; - src = fetchFromGitHub { - owner = "romkatv"; - repo = "powerlevel10k"; - rev = "v1.17.0"; - sha256 = "sha256-fgrwbWj6CcPoZ6GbCZ47HRUg8ZSJWOsa7aipEqYuE0Q="; - }; + src = sources.powerlevel10k; file = "powerlevel10k.zsh-theme"; } { @@ -61,12 +50,7 @@ in { } { name = "base16-shell"; - src = fetchFromGitHub { - owner = "chriskempson"; - repo = "base16-shell"; - rev = "588691ba71b47e75793ed9edfcfaa058326a6f41"; - sha256 = "sha256-X89FsG9QICDw3jZvOCB/KsPBVOLUeE7xN3VCtf0DD3E="; - }; + src = sources.base16-shell; file = "base16-shell.plugin.zsh"; } ]; diff --git a/modules/nixos/suites/development/default.nix b/modules/nixos/suites/development/default.nix index e83c1d3..378332d 100644 --- a/modules/nixos/suites/development/default.nix +++ b/modules/nixos/suites/development/default.nix @@ -26,6 +26,7 @@ in { awscli2 direnv minio-client + npins pre-commit git ]; diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..5e7d086 --- /dev/null +++ b/npins/default.nix @@ -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`" diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..30da918 --- /dev/null +++ b/npins/sources.json @@ -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 +} \ No newline at end of file diff --git a/systems/x86_64-linux/carbon/default.nix b/systems/x86_64-linux/carbon/default.nix index 91d1528..a2f2ac5 100644 --- a/systems/x86_64-linux/carbon/default.nix +++ b/systems/x86_64-linux/carbon/default.nix @@ -1,8 +1,4 @@ -{ - config, - pkgs, - ... -}: { +{pkgs, ...}: { imports = [ # Include the results of the hardware scan. ./hardware-configuration-zfs.nix