diff --git a/.gitignore b/.gitignore index d98e502..0e7f8e7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,10 @@ # Devenv .devenv* devenv.local.nix +.devbox + +# tmp +tmp # direnv .direnv @@ -11,4 +15,4 @@ devenv.local.nix .pre-commit-config.yaml # nix build -result \ No newline at end of file +result diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 261d5b5..705c912 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ - "pinage404.nix-extension-pack" + "pinage404.nix-extension-pack", + "brettm12345.nixfmt-vscode" ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..aaaafe6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ + +{ + "nix.enableLanguageServer": true, + "nix.serverPath": "nil", +} diff --git a/configs/sumo/functions.sh b/configs/sumo/functions.sh new file mode 100644 index 0000000..6536c68 --- /dev/null +++ b/configs/sumo/functions.sh @@ -0,0 +1,55 @@ +export DEV_DEPLOYMENTS=(stag long) +export PROD_DEPLOYMENTS=(dub fra mon mum prod syd tky us2 fed) +echo "Loading functions" +function airflow-v2-exec-web() { + dep=${1} + airflow-v2-exec $dep bash +} +function airflow-v2-exec() { + dep=${1} + airflow-v2 $dep exec -it svc/$dep-analytics-airflow-v2-webserver -c webserver -- ${@:2} +} +function tsh.login() { + tsh login -d --proxy teleport.kumoroku.com eks-${1} + tsh kube login eks-${1} +} +function tsh.hop() { + tsh ssh -d --cluster=eks-${1} hop-${2:-1} +} +function tsh.shared() { + tsh ssh -d --cluster=main shared_box-${2:-1} +} +function tsh.login.all() { + for dep in ${DEV_DEPLOYMENTS[@]}; do + echo "---------" + echo " $dep " + echo "---------" + tsh.login $dep + done + for dep in ${PROD_DEPLOYMENTS[@]}; do + echo "---------" + echo " $dep " + echo "---------" + tsh.login $dep + done +} +function airflow-v2-all-tasks() { + for dep in ${DEV_DEPLOYMENTS[@]}; do + echo "[ $dep ]" + airflow-v2-list-tasks $dep + done + for dep in ${PROD_DEPLOYMENTS[@]}; do + echo "[ $dep ]" + airflow-v2-list-tasks $dep + done +} +function airflow-v2-delete-pod-tasks() { + dep=${1} + for pod in $(airflow-v2-list-tasks $dep | awk -F ' ' '{print $1}'); do airflow-v2 $dep delete pod/$pod &; done +} +function open-paas() { + dep=${1:-infrastructure} + eval $(dev hcvault cli_env -a $dep) + export GITHUB_TOKEN=$(dev secrets get -s github_token | jq -r .github_token_password) + paas-iac-shell +} diff --git a/configs/sumo/scripts/airflow b/configs/sumo/scripts/airflow new file mode 100755 index 0000000..e395ab5 --- /dev/null +++ b/configs/sumo/scripts/airflow @@ -0,0 +1,4 @@ +#!/bin/bash + +dep=${1} +eks $dep analytics-airflow ${@:2} \ No newline at end of file diff --git a/configs/sumo/scripts/airflow-v2 b/configs/sumo/scripts/airflow-v2 new file mode 100755 index 0000000..ff27dcd --- /dev/null +++ b/configs/sumo/scripts/airflow-v2 @@ -0,0 +1,4 @@ +#!/bin/bash + +dep=${1} +eks $dep analytics-airflow-v2 ${@:2} diff --git a/configs/sumo/scripts/airflow-v2-list-tasks b/configs/sumo/scripts/airflow-v2-list-tasks new file mode 100755 index 0000000..0398695 --- /dev/null +++ b/configs/sumo/scripts/airflow-v2-list-tasks @@ -0,0 +1,4 @@ +#!/bin/bash + +current_dep=$(kubectl config current-context | cut -d '-' -f2) +airflow-v2 ${1:-$current_dep} get pod --sort-by=.status.startTime -l task_id \ No newline at end of file diff --git a/configs/sumo/scripts/airflow-v2-restart-web-and-scheduler b/configs/sumo/scripts/airflow-v2-restart-web-and-scheduler new file mode 100755 index 0000000..6f4ea1b --- /dev/null +++ b/configs/sumo/scripts/airflow-v2-restart-web-and-scheduler @@ -0,0 +1,7 @@ +#!/bin/bash + +current_dep=$(kubectl config current-context | cut -d '-' -f2) +dep=${1:-$current_dep} +airflow-v2 $dep rollout restart deploy/$dep-analytics-airflow-v2-web & +airflow-v2 $dep rollout restart deploy/$dep-analytics-airflow-v2-scheduler & +wait diff --git a/configs/sumo/scripts/analytics b/configs/sumo/scripts/analytics new file mode 100755 index 0000000..ca1b191 --- /dev/null +++ b/configs/sumo/scripts/analytics @@ -0,0 +1,4 @@ +#!/bin/bash + +dep=${1} +eks $dep analytics ${@:2} \ No newline at end of file diff --git a/configs/sumo/scripts/csi b/configs/sumo/scripts/csi new file mode 100755 index 0000000..d059a0f --- /dev/null +++ b/configs/sumo/scripts/csi @@ -0,0 +1,4 @@ +#!/bin/bash + +dep=${1} +eks $dep csi ${@:2} \ No newline at end of file diff --git a/configs/sumo/scripts/docker-login-sumo-ecr b/configs/sumo/scripts/docker-login-sumo-ecr new file mode 100755 index 0000000..f436038 --- /dev/null +++ b/configs/sumo/scripts/docker-login-sumo-ecr @@ -0,0 +1,10 @@ +#!/bin/bash + + +dev hcvault login +eval $(dev hcvault cli_env -a infrastructure) + +region="us-west-2" +aws_account_id=`aws sts get-caller-identity --query "Account" --output text` + +aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${aws_account_id}.dkr.ecr.${region}.amazonaws.com diff --git a/configs/sumo/scripts/eks b/configs/sumo/scripts/eks new file mode 100755 index 0000000..94c6621 --- /dev/null +++ b/configs/sumo/scripts/eks @@ -0,0 +1,6 @@ +#!/bin/bash + +dep=${1} +assembly=${2} +echo "${dep}/${assembly}" +kubectl --cluster eks-$dep -n $dep-${assembly} --context eks-$dep-eks-$dep ${@:3} diff --git a/configs/sumo/scripts/eks-namespace b/configs/sumo/scripts/eks-namespace new file mode 100755 index 0000000..ef41b66 --- /dev/null +++ b/configs/sumo/scripts/eks-namespace @@ -0,0 +1,6 @@ +#!/bin/bash + +current_dep=$(kubectl config current-context | cut -d "-" -f2) +dep=${2:-$current_dep} +echo "$dep $current_dep" +kubectl config set-context --current --namespace=$dep-${1} \ No newline at end of file diff --git a/configs/sumo/scripts/get-memory-dump b/configs/sumo/scripts/get-memory-dump new file mode 100755 index 0000000..ccb6d1c --- /dev/null +++ b/configs/sumo/scripts/get-memory-dump @@ -0,0 +1,25 @@ + +# pod=analytics-84d4bff6c-2fzj9 +namespace=us2-analytics + +echo "getting pods..." +pods=`kubectl get pods -n $namespace` +totalpods=$(echo $pods | wc -l) +totalpods="$((totalpods-1))" +echo $pods | awk "NR==1" | awk '$0=" "$0' +echo $pods | awk "NR>1" | awk '$0=NR") "$0' +echo "> Please select one of the pods, enter a number between 1 and $totalpods" +read pod_num + +case ${pod_num#[-+]} in + *[!0-9]* | '') echo "Must be an integer." ;; +esac + +pod=$(kubectl get pods -n $namespace | awk {'print $1}' | awk -v pod_num=$pod_num 'NR==pod_num+1') +echo "Getting memory dump for $pod - Continue? [ANY KEY]..." +read +kubectl exec -n $namespace $pod -c analytics-assembly -- jcmd Bootstrap GC.heap_dump /tmp/$pod.hprof +kubectl exec -n $namespace $pod -c analytics-assembly -- gzip /tmp/$pod.hprof +kubectl -n $namespace cp -c analytics-assembly $pod:/tmp/$pod.hprof.gz $pod.hprof.gz + +kubectl exec -n $namespace $pod -c analytics-assembly -it -- /bin/bash \ No newline at end of file diff --git a/configs/sumo/scripts/helm-out b/configs/sumo/scripts/helm-out new file mode 100755 index 0000000..662745d --- /dev/null +++ b/configs/sumo/scripts/helm-out @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +name=${1:-new} +dep=${2:-stag} + +cmd="helm template --values test_values.yaml --values values.yaml --values values-$dep.yaml" + +if [ ! -z "values-$dep.auto.yaml"]; then + cmd="$cmd --values values-$dep.auto.yaml" +fi + +cmd="$cmd --debug . > tmp/$name.yml" +echo $cmd + +$cmd + +if [ $name == "new" ]; + + if [ ! -z "tmp/old.yml" ]; then + diff tmp/original.yml tmp/new.yml > tmp/diff + fi + +fi \ No newline at end of file diff --git a/configs/sumo/scripts/identify-perm b/configs/sumo/scripts/identify-perm new file mode 100755 index 0000000..b420d15 --- /dev/null +++ b/configs/sumo/scripts/identify-perm @@ -0,0 +1,9 @@ +#!/bin/bash + +TF_LOG=trace terraform apply --auto-approve &> apply.log +TF_LOG=trace terraform destroy --auto-approve &> destroy.log + +cat destroy.log | grep "DEBUG: Request" | sed -nr 's/^.*Request (.*) Details:/\1/p' | sort | uniq > all.perms +cat apply.log | grep "DEBUG: Request" | sed -nr 's/^.*Request (.*) Details:/\1/p' | sort | uniq >> all.perms +cat all.perms | sort | uniq -u > required.perms +rm all.perms \ No newline at end of file diff --git a/configs/sumo/scripts/mount-dev b/configs/sumo/scripts/mount-dev new file mode 100755 index 0000000..76971a8 --- /dev/null +++ b/configs/sumo/scripts/mount-dev @@ -0,0 +1,6 @@ +#/bin/zsh +set -e + +dev encrypted_disk mount +dev provision ssh_keys +ssh-add /Volumes/Encrypted/keys/prod_rsa diff --git a/configs/sumo/scripts/open-aws b/configs/sumo/scripts/open-aws new file mode 100755 index 0000000..803024a --- /dev/null +++ b/configs/sumo/scripts/open-aws @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +dev hcvault login +dev hcvault console -o diff --git a/configs/sumo/scripts/regex b/configs/sumo/scripts/regex new file mode 100755 index 0000000..7a90dbd --- /dev/null +++ b/configs/sumo/scripts/regex @@ -0,0 +1,3 @@ +#!/bin/bash + +gawk 'match($0,/'$1'/, ary) {print ary['${2:-'1'}']}' \ No newline at end of file diff --git a/configs/sumo/scripts/sagemaker b/configs/sumo/scripts/sagemaker new file mode 100755 index 0000000..2f4519a --- /dev/null +++ b/configs/sumo/scripts/sagemaker @@ -0,0 +1,3 @@ +#!/bin/bash + +eks us2 analytics-sagemaker ${@:1} \ No newline at end of file diff --git a/configs/sumo/scripts/update-aws-cred b/configs/sumo/scripts/update-aws-cred new file mode 100755 index 0000000..bdae9d4 --- /dev/null +++ b/configs/sumo/scripts/update-aws-cred @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +cred_file=${1} +aws_cred_file=$HOME/.aws/credentials + +source $HOME/$cred_file.sh + +if [ -z "${AWS_ACCESS_KEY_ID}" ]; then + echo "Missing access key"; + exit 1 +fi +if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then + echo "Missing AWS_SECRET_ACCESS_KEY"; + exit 1 +fi +if [ -z "${AWS_SESSION_TOKEN}" ]; then + echo "Missing AWS_SESSION_TOKEN"; + exit 1 +fi + +echo "Updating $aws_cred_file ..." +echo "[default]" > $aws_cred_file +echo "aws_access_key_id = $AWS_ACCESS_KEY_ID" >> $aws_cred_file +echo "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY" >> $aws_cred_file +echo "aws_session_token=$AWS_SESSION_TOKEN" >> $aws_cred_file + +unset AWS_ACCESS_KEY_ID +unset AWS_SECRET_ACCESS_KEY +unset AWS_SESSION_TOKEN + +echo `aws sts get-caller-identity` diff --git a/configs/sumo/scripts/update-dsh-knobs b/configs/sumo/scripts/update-dsh-knobs new file mode 100755 index 0000000..371f05c --- /dev/null +++ b/configs/sumo/scripts/update-dsh-knobs @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "<<< ◉ Updating dsh ⦿ >>>" +cd ~/git/sumo && git fetch origin master:master && git merge master && git status + +echo "<<< ◉ Updatig knobs ⦿ >>>" +cd ~/git/knobs && git fetch origin master:master && git merge master && git status + diff --git a/devenv.lock b/devenv.lock index 9907bcf..ad9b769 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1713632052, + "lastModified": 1716370999, "owner": "cachix", "repo": "devenv", - "rev": "9c134f73b11b298674317b84292fa126744a65fb", - "treeHash": "b23850beedbddb3c23ecd5320f95d8c4525aeb18", + "rev": "38bf3509369446cc04410dc7b8f3e6c0e800e282", + "treeHash": "95e7e2cf5c39211e1687c8700841ed3180c4327b", "type": "github" }, "original": { @@ -33,24 +33,6 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "treeHash": "bd263f021e345cb4a39d80c126ab650bebc3c10c", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "gitignore": { "inputs": { "nixpkgs": [ @@ -74,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713596654, + "lastModified": 1716312448, "owner": "NixOS", "repo": "nixpkgs", - "rev": "fd16bb6d3bcca96039b11aa52038fafeb6e4f4be", - "treeHash": "fadc8eefb11cd63b3a7f59eaf6fac47ece269476", + "rev": "e381a1288138aceda0ac63db32c7be545b446921", + "treeHash": "94e1ec859be23f2ea92ba136657f35237682df6d", "type": "github" }, "original": { @@ -90,11 +72,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1713564160, + "lastModified": 1716218643, "owner": "NixOS", "repo": "nixpkgs", - "rev": "bc194f70731cc5d2b046a6c1b3b15f170f05999c", - "treeHash": "f0682fcd74b6547997b0a93d9d7d1047ef695b3f", + "rev": "a8695cbd09a7ecf3376bd62c798b9864d20f86ee", + "treeHash": "7c62ffb1bbf9fc2417d1720663e38db0c3f0b907", "type": "github" }, "original": { @@ -107,7 +89,6 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" @@ -115,11 +96,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1712897695, + "lastModified": 1716213921, "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", - "treeHash": "9ba338feee8e6b2193c305f46b65b0fef49816b7", + "rev": "0e8fcc54b842ad8428c9e705cb5994eaf05c26a0", + "treeHash": "17b9f9f9983467bcff247b09761dca9831d3d3be", "type": "github" }, "original": { @@ -134,21 +115,6 @@ "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "treeHash": "cce81f2a0f0743b2eb61bc2eb6c7adbe2f2c6beb", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/devenv.nix b/devenv.nix index ba03d30..5cfc1b1 100644 --- a/devenv.nix +++ b/devenv.nix @@ -4,6 +4,7 @@ languages.nix.enable = true; packages = [ pkgs.nixpkgs-fmt + pkgs.nixd ]; pre-commit = { hooks.nixpkgs-fmt.enable = true; diff --git a/example-configuration.nix b/example-configuration.nix deleted file mode 100644 index 84d0f4b..0000000 --- a/example-configuration.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ ... }: -{ - imports = - [ - (import ./main.nix { - hostName = "fw1"; - user = { - name = "ari"; - fullName = "Ari Sosnovsky"; - email = "ariel@sosnovsky.ca"; - }; - }) - ]; -} diff --git a/flake.lock b/flake.lock index d11c3a0..046eeac 100644 --- a/flake.lock +++ b/flake.lock @@ -77,7 +77,23 @@ "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 90e5649..02c4e26 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,8 @@ { inputs = { - nixos-hardware = { - url = "github:NixOS/nixos-hardware/master"; - }; - nixpkgs = { - url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - }; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -22,6 +19,7 @@ , nixpkgs , home-manager , nix-darwin + , systems }: let user = { @@ -29,15 +27,31 @@ fullName = "Ari Sosnovsky"; email = "ariel@sosnovsky.ca"; }; + sumoUser = rec { + name = "asosnovsky"; + fullName = user.fullName; + email = "${name}@sumologic.com"; + homepath = "/Users/${name}"; + extraGitConfigs = [ + { path = "${homepath}/.config/mysumo/gitconfig"; } + ]; + }; homeMangerVersion = "24.05"; lib = (import modules/lib.nix { nixpkgs = nixpkgs; home-manager = home-manager; nix-darwin = nix-darwin; }); + eachSystem = nixpkgs.lib.genAttrs (import systems); in { lib = lib; + formatter = eachSystem (system: + nixpkgs.legacyPackages.${system}.nixpkgs-fmt + ); + + # NIXOS Setups + # ------------- nixosConfigurations."fwbook" = lib.makeNixOsModule { system = "x86_64-linux"; user = user; @@ -45,7 +59,6 @@ hostName = "fwbook"; home-manager = { enable = true; - mode = "nixos"; version = homeMangerVersion; }; desktop = { @@ -73,5 +86,27 @@ ]; }; }; + + # MacBooks Setups + # ------------- + darwinConfigurations."asosnovsky-mac" = lib.makeDarwinModule { + user = sumoUser; + systemStateVersion = 4; + system = "x86_64-darwin"; + hostName = "asosnovsky-mac"; + home-manager = { + enable = true; + version = homeMangerVersion; + }; + desktop = { + enable = false; + }; + os = { + enable = false; + }; + configuration = (import ./hosts/asosnovsky-mac.nix { + user = sumoUser; + }); + }; }; } diff --git a/fwbook.knsv b/fwbook.knsv deleted file mode 100644 index 3f53bf7..0000000 Binary files a/fwbook.knsv and /dev/null differ diff --git a/hosts/asosnovsky-mac.nix b/hosts/asosnovsky-mac.nix new file mode 100644 index 0000000..efdc4ea --- /dev/null +++ b/hosts/asosnovsky-mac.nix @@ -0,0 +1,55 @@ +{ user }: +{ pkgs, ... }: +let + zshSumo = builtins.filterSource (p: t: true) ../configs/sumo; + zshScripts = zshSumo + "/scripts"; + zshFunctions = zshSumo + "/functions.sh"; +in +{ + home-manager.users.${user.name} = { + home = { + packages = with pkgs; [ + coreutils-prefixed + awscli2 + kubernetes-helm + nixfmt-classic + nil + jq + pre-commit + devenv + terragrunt + oterm + ]; + shellAliases = { + k = "kubectl"; + gradlew = "dev gradlew"; + psh = "source $HOME/git/github/psh/psh.sh"; + hcvault = "dev hcvault"; + }; + sessionVariables = { + "DOCKER_DEFAULT_PLATFORM" = "linux/amd64"; + "SUMO_HOME" = "$HOME/git/sumo"; + "_JAVA_OPTIONS" = "-Djava.awt.headless=true"; + "LC_ALL" = "en_US.UTF-8"; + "JAVA_HOME" = "/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home"; + }; + sessionPath = [ + "$HOME/.devcli/bin" + "$HOME/.krew/bin" + "$HOME/git/github/paas-infrastructure/bin" + "$HOME/.krew/bin" + zshScripts + ]; + }; + programs.zsh.initExtra = '' + source ${zshFunctions} + source /dev/stdin <<< "$($HOME/.devcli/dev --init)" + complete -o default -F __start_kubectl k + source <(helm completion zsh) + complete -C '/opt/homebrew/bin/aws_completer' aws + source <(kubectl completion zsh) + test -f ~/.prada/artifactory.env && source ~/.prada/artifactory.env + ulimit -n $(sysctl -n kern.maxfilesperproc) + ''; + }; +} diff --git a/modules/desktop/main.nix b/modules/desktop/default.nix similarity index 100% rename from modules/desktop/main.nix rename to modules/desktop/default.nix diff --git a/modules/home-manager-config.nix b/modules/home-manager/common.nix similarity index 90% rename from modules/home-manager-config.nix rename to modules/home-manager/common.nix index 32bb206..6624a14 100644 --- a/modules/home-manager-config.nix +++ b/modules/home-manager/common.nix @@ -40,6 +40,7 @@ in neofetch ipfetch nixd + devbox ]; }; programs = { @@ -69,7 +70,11 @@ in init = { defaultBranch = "main"; }; }; includes = - (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles); + (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) + ++ (if builtins.hasAttr "extraGitConfigs" user then + user.extraGitConfigs + else + [ ]); }; zsh = { enable = true; @@ -88,12 +93,7 @@ in enable = true; clock24 = true; mouse = true; - plugins = with pkgs.tmuxPlugins; [ - nord - cpu - battery - sidebar - ]; + plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ]; }; }; }; diff --git a/modules/gitconfigs/alias.conf b/modules/home-manager/gitconfigs/alias.conf similarity index 100% rename from modules/gitconfigs/alias.conf rename to modules/home-manager/gitconfigs/alias.conf diff --git a/modules/macos-home-manager.nix b/modules/home-manager/macos.nix similarity index 100% rename from modules/macos-home-manager.nix rename to modules/home-manager/macos.nix diff --git a/modules/lib.nix b/modules/lib.nix index 5b2a854..8311a8e 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -38,7 +38,7 @@ in attrs = attrs; home-manager-modules = [ home-manager.darwinModules.home-manager - (import ./macos-home-manager.nix { user = user; }) + (import ./home-manager/macos.nix { user = user; }) ]; }) ++ [ (import ./macos.nix { diff --git a/modules/macos.nix b/modules/macos.nix index f72ed1d..e3481cb 100644 --- a/modules/macos.nix +++ b/modules/macos.nix @@ -3,5 +3,6 @@ services.nix-daemon.enable = true; security.pam.enableSudoTouchIdAuth = true; users.users.${user.name}.home = user.homepath; + users.users.root.home = "/var/root"; nixpkgs.hostPlatform = system; } diff --git a/modules/main.nix b/modules/main.nix index 24b6931..f34713f 100644 --- a/modules/main.nix +++ b/modules/main.nix @@ -19,12 +19,12 @@ { ... }: { imports = [ - (import ./nix/main.nix { + (import ./nix { user = user; - systemStateVersion = "23.11"; + systemStateVersion = systemStateVersion; }) ] ++ (if desktop.enable then [ - (import ./desktop/main.nix { + (import ./desktop { user = user; enableKDE = desktop.enableKDE; enableHypr = desktop.enableHypr; @@ -32,7 +32,7 @@ enableWine = desktop.enableWine; }) ] else [ ]) ++ (if os.enable then [ - (import ./os/main.nix { + (import ./os { user = user; hostName = hostName; firewall = os.firewall; @@ -42,7 +42,7 @@ hardware = os.hardware; }) ] else [ ]) ++ (if home-manager.enable then [ - (import ./home-manager-config.nix { + (import ./home-manager/common.nix { user = user; homeMangerVersion = home-manager.version; hostName = hostName; diff --git a/modules/nix/core.nix b/modules/nix/default.nix similarity index 61% rename from modules/nix/core.nix rename to modules/nix/default.nix index 9182ab4..4e65108 100644 --- a/modules/nix/core.nix +++ b/modules/nix/default.nix @@ -4,9 +4,13 @@ # Nix core system.stateVersion = systemStateVersion; nixpkgs.config.allowUnfree = true; - services.hydra.useSubstitutes = true; nix.settings = { experimental-features = [ "nix-command" "flakes" ]; + substituters = [ + "https://cache.nixos.org" + "https://cache.flox.dev" + "https://devenv.cachix.org" + ]; trusted-substituters = [ "https://cache.flox.dev" "https://devenv.cachix.org" @@ -17,37 +21,22 @@ "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" ]; }; - # Set your time zone. - time.timeZone = "America/Toronto"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_CA.UTF-8"; # System Packages programs.zsh.enable = true; - programs.nix-ld.enable = true; environment.systemPackages = with pkgs; [ # nix utils nix-index nil cachix nixpkgs-fmt + nix-serve # shell tools wget - # misc - glib - glibc ]; # Storage Optim nix.optimise.automatic = true; - nix.optimise.dates = [ "01:00" ]; - services.cron = { - enable = true; - systemCronJobs = [ - "* 23 * * * root nix-collect-garbage --delete-older-than 1d" - "* 23 * * * ${user.name} nix-collect-garbage --delete-older-than 1d" - ]; - }; + } diff --git a/modules/nix/main.nix b/modules/nix/main.nix deleted file mode 100644 index 8472fa2..0000000 --- a/modules/nix/main.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ user -, systemStateVersion -}: -{ ... }: -{ - imports = [ - (import ./core.nix { - user = user; - systemStateVersion = systemStateVersion; - }) - ]; -} diff --git a/modules/os/core.nix b/modules/os/core.nix index fe2a116..6ea124a 100644 --- a/modules/os/core.nix +++ b/modules/os/core.nix @@ -1,8 +1,15 @@ +{ user }: { pkgs, ... }: { # System Packages + services.hydra.useSubstitutes = true; services.flatpak.enable = true; + services.nix-serve = { + enable = true; + port = 5000; + }; programs.dconf.enable = true; + programs.nix-ld.enable = true; environment.systemPackages = with pkgs; [ # nix utils appimage-run @@ -17,6 +24,8 @@ # misc glib-networking + glib + glibc # printer system-config-printer @@ -24,4 +33,18 @@ services.xserver.excludePackages = with pkgs; [ xterm ]; + # Set your time zone. + time.timeZone = "America/Toronto"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_CA.UTF-8"; + + # Storage Clean up + services.cron = { + enable = true; + systemCronJobs = [ + "* 23 * * * root nix-collect-garbage --delete-older-than 1d" + "* 23 * * * ${user.name} nix-collect-garbage --delete-older-than 1d" + ]; + }; } diff --git a/modules/os/main.nix b/modules/os/default.nix similarity index 92% rename from modules/os/main.nix rename to modules/os/default.nix index 20d4d29..5a0e718 100644 --- a/modules/os/main.nix +++ b/modules/os/default.nix @@ -11,7 +11,9 @@ { pkgs, ... }: { imports = [ - ./core.nix + (import ./core.nix { + user = user; + }) ./rootUser.nix (import ./user.nix { user = user; diff --git a/modules/os/ssh.nix b/modules/os/ssh.nix index 7cd029e..8196846 100644 --- a/modules/os/ssh.nix +++ b/modules/os/ssh.nix @@ -1,18 +1,21 @@ { enableSSHServer, user }: { ... }: { - services.openssh = if enableSSHServer then { - enable = true; - settings.PasswordAuthentication = false; - settings.KbdInteractiveAuthentication = false; - settings.PermitRootLogin = "yes"; - } else { - enable = false; - }; - users.users.${user.name}.openssh.authorizedKeys.keys = if enableSSHServer then [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared" - ] else []; - users.users.root.openssh.authorizedKeys.keys = if enableSSHServer then [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared" - ] else []; -} \ No newline at end of file + services.openssh = + if enableSSHServer then { + enable = true; + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + settings.PermitRootLogin = "yes"; + } else { + enable = false; + }; + users.users.${user.name}.openssh.authorizedKeys.keys = + if enableSSHServer then [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared" + ] else [ ]; + users.users.root.openssh.authorizedKeys.keys = + if enableSSHServer then [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuatskL9qXvgvS3E8zRwosFnpcN0f8PkKl8syAvpn297V2iPk6mi8yK3EE7xPpxaKKlwUuBHDj3BNUCoLgdRFKUgroRDzr3BMm+gZTHy6CuEZBY9zBRTmH+aOV6FZ96QPW4zba0BW5YPkPNy/FhYibjpXyZ3nX4/LWSbPKQJ7wTnUJZgq4VFmevBOttvhzUJUgTziMFsGXn6I38fAi6LI8qwI+zOOdsNjtKgr/TIlO/7VqcH7GYnQEwlthl577sDd1V6+XWz649qoiBYyq0Ahm09dwYx2iGQwLo8IYFbSy4aJRK/PI0+ytnPBoF5QCl+ILb5E8uV3e6Wb9WpXl9Hv2iLx91/9iq5hykHPnfVtkq3MK0C2vqkvX1qFOIkKM7vmxvXGbaDZDGK3G+/zkQ7GUw8ydbl9wGwE9cKbm9miqs4w2Ry/+3IZasE6G2TI97bSzSYInQd2RwoglqBOaJojbUqgI9wvNdKxGhADNFbZah2+s6SSe1ByQRN3b9wtmqu0= ari@shared" + ] else [ ]; +}