diff --git a/flake.lock b/flake.lock index 8e10a9a..06a4219 100644 --- a/flake.lock +++ b/flake.lock @@ -380,6 +380,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1723637854, "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=", @@ -432,10 +448,29 @@ "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", + "rust-overlay": "rust-overlay", "sops-nix": "sops-nix", "talhelper": "talhelper" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1726021481, + "narHash": "sha256-4J4E+Fh+77XIYnq2RVtg+ENWXpu6t74P0jKN/f2RQmI=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "1c2c120246c51a644c20ba2a36a33d3bd4860d70", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "sops-nix": { "inputs": { "nixpkgs": [ @@ -490,7 +525,7 @@ "talhelper": { "inputs": { "flake-parts": "flake-parts_2", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1726017029, diff --git a/flake.nix b/flake.nix index 2e73fa6..7943e92 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + # Rust toolchain overlay + rust-overlay = { + url = "github:oxalica/rust-overlay"; + }; + # sops-nix sops-nix = { url = "github:Mic92/sops-nix"; diff --git a/homes/_modules/kubernetes/default.nix b/homes/_modules/kubernetes/default.nix index 6cea3f4..5ca0814 100644 --- a/homes/_modules/kubernetes/default.nix +++ b/homes/_modules/kubernetes/default.nix @@ -1,15 +1,57 @@ -{ lib, ... }: { - imports = [ - ./kubecm - ./kubecolor - ./kubectl - ./stern - ./talhelper - ./utilities - ]; - + config, + lib, + pkgs, + ... +}: +let + cfg = config.modules.kubernetes; +in +{ options.modules.kubernetes = { enable = lib.mkEnableOption "kubernetes"; }; + + config = lib.mkIf cfg.enable { + home.packages = + (with pkgs; [ + fluxcd + helmfile + krew + kubecm + kubeconform + kubernetes-helm + kubecolor + kubectl-rook-ceph + minio-client + talhelper + ]) + ++ (with pkgs.unstable; [ + kubectl + kubectl-cnpg + kubectl-node-shell + kubectl-view-secret + stern + talosctl + ]); + + programs.fish = { + interactiveShellInit = '' + fish_add_path $HOME/.krew/bin + ${lib.getExe pkgs.unstable.kubecm} completion fish | source + ''; + + functions = { + k = { + description = "kubectl shorthand"; + wraps = "kubectl"; + body = builtins.readFile ./functions/k.fish; + }; + }; + + shellAliases = { + kc = "kubecm"; + }; + }; + }; } diff --git a/homes/_modules/kubernetes/kubectl/functions/k.fish b/homes/_modules/kubernetes/functions/k.fish similarity index 100% rename from homes/_modules/kubernetes/kubectl/functions/k.fish rename to homes/_modules/kubernetes/functions/k.fish diff --git a/homes/_modules/kubernetes/krewfile/default.nix b/homes/_modules/kubernetes/krewfile/default.nix deleted file mode 100644 index 9447207..0000000 --- a/homes/_modules/kubernetes/krewfile/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -let - cfg = config.modules.kubernetes; -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { - programs.krewfile = { - enable = true; - krewPackage = pkgs.krew; - plugins = [ - "node-shell" - "cnpg" - "rook-ceph" - ]; - }; - }) - ]; -} diff --git a/homes/_modules/kubernetes/kubecm/default.nix b/homes/_modules/kubernetes/kubecm/default.nix deleted file mode 100644 index 1c04d3b..0000000 --- a/homes/_modules/kubernetes/kubecm/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -let - cfg = config.modules.kubernetes; - package = pkgs.unstable.kubecm.overrideAttrs ( - _: prev: { - meta = prev.meta // { - mainProgram = "kubecm"; - }; - } - ); -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { - home.packages = [ package ]; - - programs.fish = { - interactiveShellInit = '' - ${lib.getExe package} completion fish | source - ''; - - shellAliases = { - kc = "kubecm"; - }; - }; - }) - ]; -} diff --git a/homes/_modules/kubernetes/kubecolor/default.nix b/homes/_modules/kubernetes/kubecolor/default.nix deleted file mode 100644 index 7bf9848..0000000 --- a/homes/_modules/kubernetes/kubecolor/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - pkgs, - lib, - config, - flake-packages, - ... -}: -let - cfg = config.modules.kubernetes; -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { home.packages = [ flake-packages.${pkgs.system}.kubecolor ]; }) - ]; -} diff --git a/homes/_modules/kubernetes/kubectl/default.nix b/homes/_modules/kubernetes/kubectl/default.nix deleted file mode 100644 index bebe862..0000000 --- a/homes/_modules/kubernetes/kubectl/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -let - cfg = config.modules.kubernetes; -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { - home.packages = [ pkgs.unstable.kubectl ]; - - programs.fish.functions = { - k = { - description = "kubectl shorthand"; - wraps = "kubectl"; - body = builtins.readFile ./functions/k.fish; - }; - }; - }) - ]; -} diff --git a/homes/_modules/kubernetes/stern/default.nix b/homes/_modules/kubernetes/stern/default.nix deleted file mode 100644 index cafb781..0000000 --- a/homes/_modules/kubernetes/stern/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -let - cfg = config.modules.kubernetes; -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { - home.packages = [ pkgs.stern ]; - programs.fish.interactiveShellInit = "${pkgs.stern}/bin/stern --completion fish | source"; - }) - ]; -} diff --git a/homes/_modules/kubernetes/talhelper/default.nix b/homes/_modules/kubernetes/talhelper/default.nix deleted file mode 100644 index 116cd9a..0000000 --- a/homes/_modules/kubernetes/talhelper/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - pkgs, - lib, - config, - inputs, - ... -}: -let - cfg = config.modules.kubernetes; -in -{ - config = lib.mkMerge [ - (lib.mkIf cfg.enable { home.packages = [ inputs.talhelper.packages.${pkgs.system}.default ]; }) - ]; -} diff --git a/homes/_modules/kubernetes/utilities/default.nix b/homes/_modules/kubernetes/utilities/default.nix deleted file mode 100644 index e48add8..0000000 --- a/homes/_modules/kubernetes/utilities/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs, ... }: -{ - config = { - home.packages = with pkgs; [ - fluxcd - helmfile - kubeconform - kubernetes-helm - minio-client - unstable.talosctl - ]; - }; -} diff --git a/homes/_modules/shell/gh/default.nix b/homes/_modules/shell/gh/default.nix index 96a58c7..c7444fc 100644 --- a/homes/_modules/shell/gh/default.nix +++ b/homes/_modules/shell/gh/default.nix @@ -1,12 +1,12 @@ -{ pkgs, flake-packages, ... }: +{ pkgs, ... }: { config = { programs.gh = { enable = true; - extensions = [ - flake-packages.${pkgs.system}.gh-copilot - flake-packages.${pkgs.system}.gh-tidy + extensions = with pkgs; [ + gh-copilot + gh-tidy ]; }; }; diff --git a/homes/_modules/shell/utilities/default.nix b/homes/_modules/shell/utilities/default.nix index 1b29782..32e3b6f 100644 --- a/homes/_modules/shell/utilities/default.nix +++ b/homes/_modules/shell/utilities/default.nix @@ -1,4 +1,4 @@ -{ pkgs, flake-packages, ... }: +{ pkgs, ... }: { config = { home.packages = with pkgs; [ @@ -16,7 +16,6 @@ jo jq openssl - flake-packages.${pkgs.system}.shcopy tlrc wget yq-go diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 13f21f5..5faf579 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -28,7 +28,6 @@ inputs.nix-index-database.hmModules.nix-index inputs.nixvim.homeManagerModules.nixvim inputs.sops-nix.homeManagerModules.sops - inputs.krewfile.homeManagerModules.krewfile ]; extraSpecialArgs = { inherit inputs hostname flake-packages; @@ -74,7 +73,6 @@ inputs.nix-index-database.hmModules.nix-index inputs.nixvim.homeManagerModules.nixvim inputs.sops-nix.homeManagerModules.sops - inputs.krewfile.homeManagerModules.krewfile ]; extraSpecialArgs = { inherit inputs hostname flake-packages; @@ -120,7 +118,6 @@ inputs.nix-index-database.hmModules.nix-index inputs.nixvim.homeManagerModules.nixvim inputs.sops-nix.homeManagerModules.sops - inputs.krewfile.homeManagerModules.krewfile ]; extraSpecialArgs = { inherit inputs hostname flake-packages; diff --git a/overlays/default.nix b/overlays/default.nix index 2c15aaa..657d503 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,27 +1,44 @@ { inputs, ... }: { - additions = final: prev: { - # flake = import ../pkgs { - # pkgs = prev; - # inherit inputs; - # }; - }; + rust-overlay = inputs.rust-overlay.overlays.default; - modifications = final: prev: { - # kubecm = prev.kubecm.overrideAttrs (_: prev: { - # meta = prev.meta // { - # mainProgram = "kubecm"; - # }; - # }); - kubectl = inputs.krew2nix.outputs.packages.${prev.system}.kubectl; - }; + additions = + final: _prev: + import ../pkgs { + inherit inputs; + pkgs = final; + }; # The unstable nixpkgs set (declared in the flake inputs) will - # be accessible through 'pkgs.unstable' - unstable-packages = final: _prev: { + # be accessible through `pkgs.unstable` + unstable-packages = final: prev: { unstable = import inputs.nixpkgs-unstable { - system = final.system; + inherit (final) system; config.allowUnfree = true; + overlays = [ + # overlays of unstable packages are declared here + (final: prev: { + kubectl-node-shell = prev.kubectl-node-shell.overrideAttrs ( + _: prev: { meta = builtins.removeAttrs prev.meta [ "platforms" ]; } + ); + kubectl-view-secret = prev.kubectl-view-secret.overrideAttrs ( + _: prev: { + postInstall = '' + mv $out/bin/cmd $out/bin/kubectl-view_secret + ''; + } + ); + }) + ]; }; }; + + # Your own overlays for stable nixpkgs should be declared here + nixpkgs-overlays = final: prev: { + # kubectl-view-secret = prev.kubectl-view-secret.overrideAttrs (_: prev: { + # postInstall = '' + # mv $out/bin/cmd $out/bin/kubectl-view_secret + # ''; + # }); + }; } diff --git a/pkgs/_sources/generated.json b/pkgs/_sources/generated.json index 5463e44..778d481 100644 --- a/pkgs/_sources/generated.json +++ b/pkgs/_sources/generated.json @@ -99,6 +99,26 @@ }, "version": "v0.0.25" }, + "kubectl-rook-ceph": { + "cargoLocks": null, + "date": null, + "extract": null, + "name": "kubectl-rook-ceph", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "rook", + "repo": "kubectl-rook-ceph", + "rev": "v0.9.1", + "sha256": "sha256-glPcrjtMsf96hnvtXKawzlQjsPnEmdYXrYcRzviHcgg=", + "type": "github" + }, + "version": "v0.9.1" + }, "shcopy": { "cargoLocks": null, "date": null, diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix index 1dba9dc..68c875a 100644 --- a/pkgs/_sources/generated.nix +++ b/pkgs/_sources/generated.nix @@ -56,6 +56,17 @@ sha256 = "sha256-FyKTI7Br9BjSpmf9ch2E4EZAWM7/jowZfRrCn4GTcps="; }; }; + kubectl-rook-ceph = { + pname = "kubectl-rook-ceph"; + version = "v0.9.1"; + src = fetchFromGitHub { + owner = "rook"; + repo = "kubectl-rook-ceph"; + rev = "v0.9.1"; + fetchSubmodules = false; + sha256 = "sha256-glPcrjtMsf96hnvtXKawzlQjsPnEmdYXrYcRzviHcgg="; + }; + }; shcopy = { pname = "shcopy"; version = "v0.1.4"; diff --git a/pkgs/default.nix b/pkgs/default.nix index 81a3adf..fce025e 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,6 +1,7 @@ # Custom packages, that can be defined similarly to ones from nixpkgs # You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' { + inputs, pkgs ? (import ) { }, ... }: @@ -9,7 +10,8 @@ let in { kubecolor = callPackage ./kubecolor.nix { }; + kubectl-rook-ceph = callPackage ./kubectl-rook-ceph.nix { }; gh-copilot = callPackage ./gh-copilot.nix { }; gh-tidy = callPackage ./gh-tidy.nix { }; - shcopy = callPackage ./shcopy.nix { }; + talhelper = inputs.talhelper.packages.${pkgs.system}.default; } diff --git a/pkgs/kubectl-rook-ceph.nix b/pkgs/kubectl-rook-ceph.nix new file mode 100644 index 0000000..aac2716 --- /dev/null +++ b/pkgs/kubectl-rook-ceph.nix @@ -0,0 +1,46 @@ +{ + buildGoModule, + callPackage, + installShellFiles, + lib, +}: + +let + sourceData = callPackage _sources/generated.nix { }; +in +buildGoModule rec { + inherit (sourceData.kubectl-rook-ceph) pname src; + version = lib.strings.removePrefix "v" sourceData.kubectl-rook-ceph.version; + + vendorHash = "sha256-KOt8JghzEzg4e3zAOHSHTboqE+yQMPVUOOP/JS2+wJE="; + + nativeBuildInputs = [ installShellFiles ]; + + subPackages = [ "cmd" ]; + + postInstall = '' + mv $out/bin/cmd $out/bin/kubectl-rook_ceph + + # Shell completion for `kubectl rook-ceph` + # Quite ugly but it works, see: https://github.com/kubernetes/kubernetes/pull/105867 + cat <$out/bin/kubectl_complete-rook_ceph + #!/usr/bin/env sh + + kubectl rook-ceph __complete "\$@" + EOF + + chmod u+x $out/bin/kubectl_complete-rook_ceph + + # This is the more elegant way of doing it but it doesn't work + # for shell in bash fish zsh; do + # $out/bin/kubectl-rook_ceph completion $shell > kubectl-rook_ceph.$shell + # installShellCompletion kubectl-rook_ceph.$shell + # done + ''; + + meta = with lib; { + description = "kubectl plugin to run kubectl commands with rook-ceph"; + homepage = "https://github.com/rook/kubectl-rook-ceph"; + licence = licences.asl20; + }; +} diff --git a/pkgs/nvfetcher.toml b/pkgs/nvfetcher.toml index 12cd0fc..4196c7e 100644 --- a/pkgs/nvfetcher.toml +++ b/pkgs/nvfetcher.toml @@ -1,6 +1,9 @@ [kubecolor] src.github_tag = "hidetatz/kubecolor" fetch.github = "hidetatz/kubecolor" +[kubectl-rook-ceph] +src.github_tag = "rook/kubectl-rook-ceph" +fetch.github = "rook/kubectl-rook-ceph" [gh-copilot-linux-amd64] src.github_tag = "github/gh-copilot" src.prefix = "v" diff --git a/pkgs/shcopy.nix b/pkgs/shcopy.nix deleted file mode 100644 index f909341..0000000 --- a/pkgs/shcopy.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - buildGoModule, - callPackage, - lib, -}: -let - sourceData = callPackage _sources/generated.nix { }; -in -buildGoModule rec { - inherit (sourceData.shcopy) pname src; - version = lib.strings.removePrefix "v" sourceData.shcopy.version; - - vendorHash = "sha256-kD73EozkeUd23pwuy71bcNmth2lEKom0CUPDUNPNB1Q="; - - ldflags = [ - "-s" - "-w" - "-X=main.ProjectName=${pname}" - "-X=main.CommitSHA=${src.rev}" - ]; - - meta = with lib; { - description = "Copy text to your system clipboard locally and remotely using ANSI OSC52 sequence"; - homepage = "https://github.com/aymanbagabas/shcopy"; - license = licenses.mit; - maintainers = with maintainers; [ rodent1 ]; - mainProgram = "shcopy"; - }; -}