From ca25688c2cab2e32d9288e5b5ae96fb41df32b9d Mon Sep 17 00:00:00 2001 From: jahanson Date: Thu, 30 May 2024 21:33:06 -0500 Subject: [PATCH] Mixing things around --- .taskfiles/nix/Taskfile.yaml | 121 -------------------- .taskfiles/nix/update-all.sh | 37 ------ .taskfiles/nix/update-single-machine.sh | 33 ------ .vscode/module.code-snippets | 2 +- .vscode/settings.json | 6 - flake.nix | 2 +- nixos/home/jahanson/global.nix | 3 +- nixos/home/jahanson/server.nix | 3 +- nixos/home/jahanson/workstation.nix | 6 +- nixos/home/modules/security/ssh/default.nix | 6 +- nixos/home/modules/shell/fish/default.nix | 49 +------- nixos/home/modules/shell/git/default.nix | 10 +- nixos/profiles/global/nix.nix | 4 +- shell.nix | 2 - 14 files changed, 18 insertions(+), 266 deletions(-) delete mode 100644 .taskfiles/nix/Taskfile.yaml delete mode 100755 .taskfiles/nix/update-all.sh delete mode 100755 .taskfiles/nix/update-single-machine.sh delete mode 100644 .vscode/settings.json diff --git a/.taskfiles/nix/Taskfile.yaml b/.taskfiles/nix/Taskfile.yaml deleted file mode 100644 index a2689cb..0000000 --- a/.taskfiles/nix/Taskfile.yaml +++ /dev/null @@ -1,121 +0,0 @@ ---- -# yaml-language-server: $schema=https://taskfile.dev/schema.json -version: "3" - -vars: - hostname: $HOSTNAME - host: '{{ or .host .hostname }}' - - -tasks: - switch: - desc: Build and apply nix configuration - silent: true - requires: - vars: - - host - cmds: - - echo "This will switch your config." - - task: .prompt_to_continue - - git add . - - sudo nixos-rebuild switch --flake "{{.ROOT_DIR}}/#{{.hostname}}" --impure - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - deploy-single: - desc: Deploy flake to single node - # silent: true - requires: - vars: - - host - cmds: - - echo "This will deploy the local flake to host {{ .host }}." - - task: .prompt_to_continue - - .taskfiles/nix/update-single-machine.sh {{.host}} - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - deploy-all: - desc: Deploy flake to all nodes - # silent: true - requires: - vars: - - host - cmds: - - echo "This will deploy the local flake to all whitelisted hosts." - - task: .prompt_to_continue - - .taskfiles/nix/update-all.sh - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - - - test: - desc: Build and apply nix configuration - silent: true - requires: - vars: - - host - cmds: - - echo "This will test your config." - - task: .prompt_to_continue - - sudo nixos-rebuild test --flake "{{.ROOT_DIR}}/#{{.host}}" --impure - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - dry-run: - desc: Build and apply nix configuration - silent: true - requires: - vars: - - host - cmds: - - echo "This will dry-run your config and add your untracked git files." - - git add . - - nixos-rebuild dry-run --flake "{{.ROOT_DIR}}/#{{.host}}" --impure - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - - build: - desc: Build nix configuration - silent: true - requires: - vars: - - host - cmds: - - git add . - - nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure --fast - - nvd diff /run/current-system result - preconditions: - - sh: which nix - msg: "nix not found" - - sh: which nixos-rebuild - msg: "nixos-rebuild not found" - - sh: which nvd - msg: "nvd not found" - - .prompt_to_continue: - internal: true - prompt: Do you want to continue applying this configuration? - - build-image-rpi4: - desc: Build basic machine build-image - silent: true - cmds: - - nix build .#images.rpi4 diff --git a/.taskfiles/nix/update-all.sh b/.taskfiles/nix/update-all.sh deleted file mode 100755 index 19d6963..0000000 --- a/.taskfiles/nix/update-all.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e - -hosts=($(echo $(nix eval .#nixosConfigurations --apply 'pkgs: builtins.concatStringsSep " " (builtins.attrNames pkgs)') | xargs)) -skip=( - "citadel" - "rickenbacker" -) - -reboot=0 - -while getopts ":r" option; do - case $option in - r) - reboot=1 - ;; - esac -done - -for host in "${hosts[@]}"; do - # Check if the host is in the skip list - if [[ " ${skip[*]} " =~ " ${host} " ]]; then - continue - fi - fqdn="$host.l.voltaicforge.com" - if [ $reboot -eq 0 ]; then - echo $fqdn - nixos-rebuild switch -j auto --use-remote-sudo --target-host $fqdn --flake ".#$host" - else - echo "$fqdn with reboot" - nixos-rebuild boot -j auto --use-remote-sudo --target-host $fqdn --flake ".#$host" - ssh -i $rsa_key $fqdn 'sudo reboot' - fi - echo - echo -done diff --git a/.taskfiles/nix/update-single-machine.sh b/.taskfiles/nix/update-single-machine.sh deleted file mode 100755 index acd967f..0000000 --- a/.taskfiles/nix/update-single-machine.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd /home/truxnell/.local/nix-config - -# rsa_key="~/.nixos/secrets/ssh_keys/ansible/ansible.key" -# export NIX_SSHOPTS="-t -i $rsa_key" - -reboot=0 - -while getopts ":r" option; do - case $option in - r) - reboot=1 - host=$2 - fqdn="$host.l.voltaicforge.com" - echo "$fqdn with reboot" - nixos-rebuild boot -j auto --use-remote-sudo --target-host $fqdn --flake ".#$host" - # ssh -i $rsa_key $fqdn 'sudo reboot' - ssh $fqdn 'sudo reboot' - ;; - esac -done - -if [ $reboot -eq 0 ]; then - host=$1 - fqdn="$host.l.voltaicforge.com" - echo "$fqdn" - nixos-rebuild switch -j auto --use-remote-sudo --target-host $fqdn --flake ".#$host" -fi -echo -echo diff --git a/.vscode/module.code-snippets b/.vscode/module.code-snippets index b341dad..8c47588 100644 --- a/.vscode/module.code-snippets +++ b/.vscode/module.code-snippets @@ -10,7 +10,7 @@ "with lib;", "let", " cfg = config.mySystem.${1}.${2};", - " app = \"${3}\"" + " app = \"${3}\"", " appFolder = \"apps/${app}\";", " persistentFolder = \"${config.mySystem.persistentFolder}/${appFolder}\";", " user = app;", diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5e354be..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cSpell.words": [ - "homelab", - "Seafile" - ] -} diff --git a/flake.nix b/flake.nix index d7a1a64..1e9db2d 100644 --- a/flake.nix +++ b/flake.nix @@ -79,7 +79,7 @@ formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixpkgs-fmt); # setup devshells against shell.nix - devShells = forAllSystems (pkgs: import ./shell.nix { inherit pkgs; }); + # devShells = forAllSystems (pkgs: import ./shell.nix { inherit pkgs; }); # extend lib with my custom functions lib = nixpkgs.lib.extend ( diff --git a/nixos/home/jahanson/global.nix b/nixos/home/jahanson/global.nix index 95a89b7..1cc4d5a 100644 --- a/nixos/home/jahanson/global.nix +++ b/nixos/home/jahanson/global.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, self, config, ... }: +{ pkgs, config, ... }: with config; { @@ -79,7 +79,6 @@ with config; # dev utils direnv # shell environment management envsubst - lazygit # nix tools nvd diff --git a/nixos/home/jahanson/server.nix b/nixos/home/jahanson/server.nix index 9015112..4ff97db 100644 --- a/nixos/home/jahanson/server.nix +++ b/nixos/home/jahanson/server.nix @@ -1,5 +1,4 @@ -{ lib, pkgs, self, config, ... }: -with config; +{ ... }: { imports = [ ./global.nix diff --git a/nixos/home/jahanson/workstation.nix b/nixos/home/jahanson/workstation.nix index da14b85..e4d72ae 100644 --- a/nixos/home/jahanson/workstation.nix +++ b/nixos/home/jahanson/workstation.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, self, config, inputs, ... }: +{ pkgs, config, ... }: with config; { imports = [ @@ -13,9 +13,9 @@ with config; git = { enable = true; - username = "jahanson"; + username = "Joseph Hanson"; email = "joe@veri.dev"; - # signingKey = ""; # TODO setup signing keys n shit + signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIDSAmssproxG+KsVn2DfuteBAemHrmmAFzCtldpKl4J"; }; }; diff --git a/nixos/home/modules/security/ssh/default.nix b/nixos/home/modules/security/ssh/default.nix index 4b1e87c..7094444 100644 --- a/nixos/home/modules/security/ssh/default.nix +++ b/nixos/home/modules/security/ssh/default.nix @@ -1,8 +1,4 @@ -{ config -, pkgs -, lib -, ... -}: +{ config, lib, ... }: with lib; let cfg = config.myHome.security.ssh; in diff --git a/nixos/home/modules/shell/fish/default.nix b/nixos/home/modules/shell/fish/default.nix index febdd4f..2d102ba 100644 --- a/nixos/home/modules/shell/fish/default.nix +++ b/nixos/home/modules/shell/fish/default.nix @@ -23,49 +23,15 @@ in ll = "${pkgs.eza}/bin/eza --long --all --group --header"; tm = "tmux attach -t (basename $PWD) || tmux new -s (basename $PWD)"; x = "exit"; + # lazydocker --> lazypodman + lazypodman="sudo DOCKER_HOST=unix:///run/podman/podman.sock lazydocker"; }; shellAbbrs = { - dup = "git add . ; darwin-rebuild --flake . switch"; - dupb = "git add . ; darwin-rebuild --flake . build --show-trace ; nvd diff /run/current-system result"; - nup = "git add . ; sudo nixos-rebuild --flake . switch"; - nhup = "nh os switch . --dry"; + nrs = "sudo nixos-rebuild switch --flake ."; nvdiff = "nvd diff /run/current-system result"; - ap = "ansible-playbook"; - apb = "ansible-playbook --ask-become"; - gfp = "git fetch -p && git pull"; - gitp = "git push"; - gitpf = "git push -f"; - tf = "terraform"; }; - # functions = { - # brewup = { - # description = "Update homebrew applications"; - # body = builtins.readFile ./functions/brewup.fish; - # }; - # fish_prompt = { - # description = "Set the fish prompt"; - # body = builtins.readFile ./functions/fish_prompt.fish; - # }; - # fish_right_prompt = { - # description = "Set the right prompt"; - # body = builtins.readFile ./functions/fish_right_prompt.fish; - # }; - # fish_title = { - # description = "Set the title"; - # body = builtins.readFile ./functions/fish_title.fish; - # }; - # fwatch = { - # description = "Watch with fish alias support"; - # body = builtins.readFile ./functions/fwatch.fish; - # }; - # git_current_branch = { - # description = "Display the current branch"; - # body = builtins.readFile ./functions/git_current_branch.fish; - # }; - # }; - interactiveShellInit = '' # Erase fish_mode_prompt function functions -e fish_mode_prompt @@ -109,15 +75,6 @@ in home.sessionVariables.fish_greeting = ""; programs.nix-index.enable = true; - - # programs.fish = { - # functions = { - # agent = { - # description = "Start SSH agent"; - # body = builtins.readFile ./functions/agent.fish; - # }; - # }; - # }; }) ]; } diff --git a/nixos/home/modules/shell/git/default.nix b/nixos/home/modules/shell/git/default.nix index 117edc0..166459f 100644 --- a/nixos/home/modules/shell/git/default.nix +++ b/nixos/home/modules/shell/git/default.nix @@ -45,6 +45,11 @@ in rebase = { autoStash = true; }; + user = { + signingKey = cfg.signingKey; + }; + gpg.format = "ssh"; + gpg.program = "${pkgs._1password}/bin/op-ssh-sign"; }; aliases = { co = "checkout"; @@ -62,15 +67,12 @@ in # Python virtualenvs ".venv" ]; - # signing = lib.mkIf (cfg.signingKey != "") { - # signByDefault = true; - # key = cfg.signingKey; - # }; }; home.packages = [ pkgs.git-filter-repo pkgs.tig + pkgs.lazygit ]; }) ]; diff --git a/nixos/profiles/global/nix.nix b/nixos/profiles/global/nix.nix index 851cdf3..a8f2521 100644 --- a/nixos/profiles/global/nix.nix +++ b/nixos/profiles/global/nix.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, nixpkgs, self, ... }: +{ lib, nixpkgs, ... }: { ## Below is to align shell/system to flake's nixpkgs ## ref: https://nixos-and-flakes.thiscute.world/best-practices/nix-path-and-flake-registry @@ -14,8 +14,6 @@ # https://github.com/NixOS/nix/issues/9574 settings.nix-path = lib.mkForce "nixpkgs=/etc/nix/inputs/nixpkgs"; - ### - settings = { # Enable flakes experimental-features = [ diff --git a/shell.nix b/shell.nix index 39ab879..d1fc12c 100644 --- a/shell.nix +++ b/shell.nix @@ -12,8 +12,6 @@ import nixpkgs { inherit system overlays; } , ... }: -let -in pkgs.mkShell { # Enable experimental features without having to specify the argument NIX_CONFIG = "experimental-features = nix-command flakes";