From 5e33cfeabf1fc40c16df082cfff2d8b6ad178e35 Mon Sep 17 00:00:00 2001 From: seang96 Date: Fri, 1 Aug 2025 15:28:41 -0400 Subject: [PATCH] Initual Commit --- cli.nix | 43 +++++++++ flake.lock | 240 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 60 ++++++++++++ home.nix | 69 ++++++++++++++ kubernetes.nix | 28 ++++++ nix-on-droid.nix | 57 +++++++++++ 6 files changed, 497 insertions(+) create mode 100644 cli.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 kubernetes.nix create mode 100644 nix-on-droid.nix diff --git a/cli.nix b/cli.nix new file mode 100644 index 0000000..8c9a102 --- /dev/null +++ b/cli.nix @@ -0,0 +1,43 @@ +{ pkgs, bck, ... }: +let + unstable = (builtins.getFlake "nixpkgs/382f738a0dab4950bb35d6005c6bca18c876a4d4").legacyPackages.aarch64-linux; + +in +{ + + environment.packages = with pkgs; [ + iftop + iotop + smartmontools + inetutils + tree + htop + tmux + nmap + dig + gnused + unstable.operator-sdk + jq + openssl + unstable.kubectl-df-pv + unstable.kubectl-cnpg + gnutar + gzip + nodejs_22 + nixos-rebuild + + + nodePackages.prettier + + unstable.velero + unstable.fish + kopia + helix + ]; + + user.shell = "${pkgs.fish}/bin/fish"; +# security.pam.sshAgentAuth.enable = true; +# security.pam.sshAgentAuth.authorizedKeysFiles = [ +# "%h/.ssh/id_cluster" +# ]; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4771491 --- /dev/null +++ b/flake.lock @@ -0,0 +1,240 @@ +{ + "nodes": { + "bck": { + "inputs": { + "impermanence": "impermanence", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1746080520, + "narHash": "sha256-A3AFE2kNhm88IpiWMa9+gku5BJFcPYR91k5vFxY9R1o=", + "owner": "buckley310", + "repo": "nixos-config", + "rev": "593856ce8274de09cf830d8b4bd5e70d7807d0f9", + "type": "github" + }, + "original": { + "owner": "buckley310", + "repo": "nixos-config", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726989464, + "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.05", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "locked": { + "lastModified": 1737831083, + "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "nix-formatter-pack": { + "inputs": { + "nixpkgs": [ + "nix-on-droid", + "nixpkgs" + ], + "nmd": "nmd", + "nmt": "nmt" + }, + "locked": { + "lastModified": 1705252799, + "narHash": "sha256-HgSTREh7VoXjGgNDwKQUYcYo13rPkltW7IitHrTPA5c=", + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "rev": "2de39dedd79aab14c01b9e2934842051a160ffa5", + "type": "github" + }, + "original": { + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "type": "github" + } + }, + "nix-on-droid": { + "inputs": { + "home-manager": [ + "home-manager" + ], + "nix-formatter-pack": "nix-formatter-pack", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-docs": "nixpkgs-docs", + "nixpkgs-for-bootstrap": "nixpkgs-for-bootstrap", + "nmd": "nmd_2" + }, + "locked": { + "lastModified": 1720396533, + "narHash": "sha256-UFzk/hZWO1VkciIO5UPaSpJN8s765wsngUSvtJM6d5Q=", + "owner": "nix-community", + "repo": "nix-on-droid", + "rev": "f3d3b8294039f2f9a8fb7ea82c320f29c6b0fe25", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.05", + "repo": "nix-on-droid", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735563628, + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-docs": { + "locked": { + "lastModified": 1705957679, + "narHash": "sha256-Q8LJaVZGJ9wo33wBafvZSzapYsjOaNjP/pOnSiKVGHY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9a333eaa80901efe01df07eade2c16d183761fa3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-for-bootstrap": { + "locked": { + "lastModified": 1720244366, + "narHash": "sha256-WrDV0FPMVd2Sq9hkR5LNHudS3OSMmUrs90JUTN+MXpA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "49ee0e94463abada1de470c9c07bfc12b36dcf40", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "49ee0e94463abada1de470c9c07bfc12b36dcf40", + "type": "github" + } + }, + "nmd": { + "flake": false, + "locked": { + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", + "owner": "rycee", + "repo": "nmd", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmd", + "type": "gitlab" + } + }, + "nmd_2": { + "inputs": { + "nixpkgs": [ + "nix-on-droid", + "nixpkgs-docs" + ], + "scss-reset": "scss-reset" + }, + "locked": { + "lastModified": 1705050560, + "narHash": "sha256-x3zzcdvhJpodsmdjqB4t5mkVW22V3wqHLOun0KRBzUI=", + "owner": "~rycee", + "repo": "nmd", + "rev": "66d9334933119c36f91a78d565c152a4fdc8d3d3", + "type": "sourcehut" + }, + "original": { + "owner": "~rycee", + "repo": "nmd", + "type": "sourcehut" + } + }, + "nmt": { + "flake": false, + "locked": { + "lastModified": 1648075362, + "narHash": "sha256-u36WgzoA84dMVsGXzml4wZ5ckGgfnvS0ryzo/3zn/Pc=", + "owner": "rycee", + "repo": "nmt", + "rev": "d83601002c99b78c89ea80e5e6ba21addcfe12ae", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmt", + "type": "gitlab" + } + }, + "root": { + "inputs": { + "bck": "bck", + "home-manager": "home-manager", + "nix-on-droid": "nix-on-droid", + "nixpkgs": "nixpkgs" + } + }, + "scss-reset": { + "flake": false, + "locked": { + "lastModified": 1631450058, + "narHash": "sha256-muDlZJPtXDIGevSEWkicPP0HQ6VtucbkMNygpGlBEUM=", + "owner": "andreymatin", + "repo": "scss-reset", + "rev": "0cf50e27a4e95e9bb5b1715eedf9c54dee1a5a91", + "type": "github" + }, + "original": { + "owner": "andreymatin", + "repo": "scss-reset", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0070990 --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "Basic example of Nix-on-Droid system config."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + + bck.url = "github:buckley310/nixos-config"; + bck.inputs.nixpkgs.follows = "nixpkgs"; + + home-manager = { + url = "github:nix-community/home-manager/release-24.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nix-on-droid = { + url = "github:nix-community/nix-on-droid/release-24.05"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.home-manager.follows = "home-manager"; + }; + }; + + outputs = { self, nixpkgs, bck, home-manager, nix-on-droid }: { + nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { + modules = [ + ./nix-on-droid.nix + ./kubernetes.nix + ./cli.nix + + # list of extra modules for Nix-on-Droid system + # { nix.registry.nixpkgs.flake = nixpkgs; } + # ./path/to/module.nix + + # or import source out-of-tree modules like: + # flake.nixOnDroidModules.module + ]; + + # list of extra special args for Nix-on-Droid modules + extraSpecialArgs = { + # rootPath = ./.; + }; + + # set nixpkgs instance, it is recommended to apply `nix-on-droid.overlays.default` + pkgs = import nixpkgs { + system = "aarch64-linux"; + + config = { + allowUnfree = true; + }; + overlays = [ + nix-on-droid.overlays.default +# bck.packages + # add other overlays + ]; + }; + + # set path to home-manager flake + home-manager-path = home-manager.outPath; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..8db5c04 --- /dev/null +++ b/home.nix @@ -0,0 +1,69 @@ +{ config, lib, pkgs, ... }: +let + unstable = (builtins.getFlake "nixpkgs/382f738a0dab4950bb35d6005c6bca18c876a4d4").legacyPackages.aarch64-linux; + +in +{ + # Read the changelog before changing this value + home.stateVersion = "24.05"; + + programs.fish = { + enable = true; + package = unstable.fish; + plugins = [ + { + name = "Hydro"; + src = pkgs.fetchFromGitHub { + owner = "jethrokuan"; + repo = "hydro"; + rev = "75ab7168a35358b3d08eeefad4ff0dd306bd80d4"; + sha256 = "0cd6fa6g0jdjdsxgy5qja2jx180s26v5hcs71npj5zim9sqvi2j1"; + }; + } + ]; + + functions = { + kubectl = { + body = "command kubecolor $argv"; + wraps = "kubectl"; + }; + + k = { + body = "command kubecolor $argv"; + wraps = "kubectl"; + }; + + kubecolor = { + body = "command kubecolor $argv"; + wraps = "kubectl"; + }; + }; + shellAliases = { + vi = "hx"; + }; + shellInit= '' + export EDITOR=hx + ''; + }; + + programs.htop = { + enable = true; + settings = { + hide_userland_threads = 1; + highlight_base_name = 1; + show_program_path = 0; + tree_sort_direction = -1; + tree_view = 1; + update_process_names = 1; + }; + }; + + programs.tmux = { + enable = true; + terminal = "screen-256color"; + extraConfig = '' + bind-key j command-prompt -p "Join pane:" "join-pane -s '%%'" + bind-key p display-popup -h 75% -w 75% -E "tmux new-session -A -s scratch" + ''; + }; +} diff --git a/kubernetes.nix b/kubernetes.nix new file mode 100644 index 0000000..6a0db4a --- /dev/null +++ b/kubernetes.nix @@ -0,0 +1,28 @@ +{ pkgs, ... }: +let + unstable = (builtins.getFlake "nixpkgs/382f738a0dab4950bb35d6005c6bca18c876a4d4").legacyPackages.aarch64-linux; + +in +{ + environment.packages = with pkgs; [ + unstable.kubectl + unstable.kubernetes-helm + unstable.kubecolor + unstable.kompose + unstable.k9s + unstable.krew + unstable.stern + unstable.kubectl-rook-ceph + unstable.kubectl-view-secret + unstable.helmfile + unstable.kubernetes-helmPlugins.helm-diff + unstable.kubernetes-helmPlugins.helm-secrets + unstable.kubernetes-helmPlugins.helm-git + unstable.kubernetes-helmPlugins.helm-s3 + + # dedicated script, because bash aliases dont work with `watch` +# (writeShellScriptBin "k" "exec kube -n \"$(basename \"$(pwd)\")\" \"$@\"") +# (writeShellScriptBin "k" "exec kubecolor \"$@\"") + (writeShellScriptBin "ceph" "exec kubecolor -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l \"app=rook-ceph-tools\" -o jsonpath='{.items[*].metadata.name}') -- ceph \"$@\"") + ]; +} diff --git a/nix-on-droid.nix b/nix-on-droid.nix new file mode 100644 index 0000000..90679ff --- /dev/null +++ b/nix-on-droid.nix @@ -0,0 +1,57 @@ +{ config, lib, pkgs, ... }: + +{ + # Simply install just the packages + environment.packages = with pkgs; [ + # User-facing stuff that you really really want to have + #vim # or some other editor, e.g. nano or neovim + git + openssh + curl + #dig3 + bash-completion + nix-bash-completions + complete-alias + watch + which + gawk + + # Some common stuff that people expect to have + #diffutils + findutils + utillinux + #tzdata + #hostname + #man + gnugrep + #gnupg + #gnused + #gnutar + #bzip2 + #gzip + #xz + #zip + #unzip + ]; + + # Backup etc files instead of failing to activate generation if a file already exists in /etc + environment.etcBackupExtension = ".bak"; + + # Read the changelog before changing this value + system.stateVersion = "23.11"; + + # Set up nix for flakes + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + + # Configure home-manager + home-manager = { + config = ./home.nix; + backupFileExtension = "hm-bak"; + useGlobalPkgs = true; + }; + + # Set your time zone + time.timeZone = "America/New_York"; +}