diff --git a/apps/loadkey.nix b/apps/loadkey.nix index 3d2831a..9aaa0f7 100644 --- a/apps/loadkey.nix +++ b/apps/loadkey.nix @@ -1,15 +1,9 @@ { pkgs, ... }: { + # TODO: just replace with packages instead of apps + type = "app"; - program = builtins.toString ( - pkgs.writeShellScript "loadkey" '' - printf "\nEnter the seed phrase for your SSH key...\n" - printf "\nThen press ^D when complete.\n\n" - mkdir -p ~/.ssh/ - ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 - printf "\n\nContinuing activation.\n\n" - '' - ); + program = "${pkgs.loadkey}/bin/loadkey"; } diff --git a/modules/common/repositories/default.nix b/modules/common/repositories/default.nix deleted file mode 100644 index a1af845..0000000 --- a/modules/common/repositories/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: -{ - - imports = [ - ./dotfiles.nix - ./notes.nix - ]; -} diff --git a/modules/common/repositories/dotfiles.nix b/modules/common/repositories/dotfiles.nix deleted file mode 100644 index ae3ccc7..0000000 --- a/modules/common/repositories/dotfiles.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: -{ - - # Allows me to make sure I can work on my dotfiles locally - - options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles."; - - config = lib.mkIf config.dotfiles.enable { - - home-manager.users.${config.user} = { - - home.activation = { - - # Always clone dotfiles repository if it doesn't exist - cloneDotfiles = config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] '' - if [ ! -d "${config.dotfilesPath}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") - $DRY_RUN_CMD ${pkgs.git}/bin/git \ - clone ${config.dotfilesRepo} "${config.dotfilesPath}" - fi - ''; - }; - - # Set a variable for dotfiles repo, not necessary but convenient - home.sessionVariables.DOTS = config.dotfilesPath; - }; - }; -} diff --git a/modules/common/shell/bash/default.nix b/modules/common/shell/bash/default.nix deleted file mode 100644 index 13b2ee2..0000000 --- a/modules/common/shell/bash/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: -{ - - config = { - home-manager.users.${config.user} = { - - programs.bash = { - enable = true; - shellAliases = config.home-manager.users.${config.user}.programs.fish.shellAliases; - initExtra = ""; - profileExtra = ""; - }; - - programs.starship.enableBashIntegration = false; - programs.zoxide.enableBashIntegration = true; - programs.fzf.enableBashIntegration = true; - }; - }; -} diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix new file mode 100644 index 0000000..4027003 --- /dev/null +++ b/overlays/pkgs.nix @@ -0,0 +1,7 @@ +_final: prev: + +{ + loadkey = prev.callPackage ../pkgs/tools/misc/loadkey.nix; + aws-ec2 = prev.callPackage ../pkgs/tools/misc/aws-ec2/; + docker-cleanup = prev.callPackage ../pkgs/tools/misc/docker-cleanup/; +} diff --git a/modules/common/shell/bash/scripts/aws-ec2.sh b/pkgs/tools/misc/aws-ec2/aws-ec2.sh similarity index 100% rename from modules/common/shell/bash/scripts/aws-ec2.sh rename to pkgs/tools/misc/aws-ec2/aws-ec2.sh diff --git a/pkgs/tools/misc/aws-ec2/package.nix b/pkgs/tools/misc/aws-ec2/package.nix new file mode 100644 index 0000000..37e0fc7 --- /dev/null +++ b/pkgs/tools/misc/aws-ec2/package.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "aws-ec2"; + runtimeInputs = [ + pkgs.awscli2 + pkgs.jq + pkgs.fzf + pkgs.ssm-session-manager-plugin + ]; + text = builtins.readFile ./aws-ec2.sh; +} diff --git a/modules/common/shell/bash/scripts/docker-cleanup.sh b/pkgs/tools/misc/docker-cleanup/docker-cleanup.sh similarity index 100% rename from modules/common/shell/bash/scripts/docker-cleanup.sh rename to pkgs/tools/misc/docker-cleanup/docker-cleanup.sh diff --git a/pkgs/tools/misc/docker-cleanup/package.nix b/pkgs/tools/misc/docker-cleanup/package.nix new file mode 100644 index 0000000..c3f2dd6 --- /dev/null +++ b/pkgs/tools/misc/docker-cleanup/package.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "docker-cleanup"; + runtimeInputs = [ + pkgs.docker-client + pkgs.gawk + pkgs.gnugrep + ]; + text = builtins.readFile ./docker-cleanup.sh; +} diff --git a/modules/common/shell/bash/scripts/jqr.sh b/pkgs/tools/misc/jqr/jqr.sh similarity index 94% rename from modules/common/shell/bash/scripts/jqr.sh rename to pkgs/tools/misc/jqr/jqr.sh index 29a63db..7fe1f9b 100755 --- a/modules/common/shell/bash/scripts/jqr.sh +++ b/pkgs/tools/misc/jqr/jqr.sh @@ -10,6 +10,8 @@ else input=$1 fi +# TODO: make available on non-macOS + echo '' | fzf --phony \ --height 100% \ diff --git a/pkgs/tools/misc/jqr/package.nix b/pkgs/tools/misc/jqr/package.nix new file mode 100644 index 0000000..753ba92 --- /dev/null +++ b/pkgs/tools/misc/jqr/package.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "jqr"; + runtimeInputs = [ + pkgs.jq + pkgs.fzf + ]; + text = builtins.readFile ./jqr.sh; +} diff --git a/pkgs/tools/misc/loadkey.nix b/pkgs/tools/misc/loadkey.nix new file mode 100644 index 0000000..52b3bd1 --- /dev/null +++ b/pkgs/tools/misc/loadkey.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +pkgs.writeShellScriptBin "loadkey" '' + printf "\nEnter the seed phrase for your SSH key...\n" + printf "\nThen press ^D when complete.\n\n" + mkdir -p ~/.ssh/ + ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + printf "\n\nContinuing activation.\n\n" +'' diff --git a/modules/common/shell/bash/scripts/ocr.sh b/pkgs/tools/misc/ocr/ocr.sh similarity index 100% rename from modules/common/shell/bash/scripts/ocr.sh rename to pkgs/tools/misc/ocr/ocr.sh diff --git a/pkgs/tools/misc/ocr/package.nix b/pkgs/tools/misc/ocr/package.nix new file mode 100644 index 0000000..3463354 --- /dev/null +++ b/pkgs/tools/misc/ocr/package.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "ocr"; + runtimeInputs = [ pkgs.tesseract ]; + text = builtins.readFile ./ocr.sh; +} diff --git a/pkgs/tools/misc/terraform-init/package.nix b/pkgs/tools/misc/terraform-init/package.nix new file mode 100644 index 0000000..cb53b2b --- /dev/null +++ b/pkgs/tools/misc/terraform-init/package.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: + +pkgs.writeShellApplication { + name = "terraform-init"; + runtimeInputs = [ + pkgs.gawk + pkgs.git + pkgs.terraform + ]; + text = builtins.readFile ./terraform-init.sh; +} diff --git a/modules/common/shell/bash/scripts/terraform-init.sh b/pkgs/tools/misc/terraform-init/terraform-init.sh similarity index 100% rename from modules/common/shell/bash/scripts/terraform-init.sh rename to pkgs/tools/misc/terraform-init/terraform-init.sh diff --git a/platforms/home-manager/modules/nmasur/presets/services/dotfiles.nix b/platforms/home-manager/modules/nmasur/presets/services/dotfiles.nix new file mode 100644 index 0000000..dd2e290 --- /dev/null +++ b/platforms/home-manager/modules/nmasur/presets/services/dotfiles.nix @@ -0,0 +1,46 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.nmasur.presets.services.dotfiles; +in +{ + + # Allows me to make sure I can work on my dotfiles locally + + options.nmasur.preset.services.dotfiles = { + enable = lib.mkEnableOption "Clone dotfiles repository"; + repo = lib.mkOption { + type = lib.types.str; + description = "Git repo containing dotfiles"; + default = "git@github.com:nmasur/dotfiles"; + }; + path = lib.mkOption { + type = lib.types.path; + description = "Path to dotfiles on disk"; + default = config.homePath + "/dev/personal/dotfiles"; + }; + }; + + config = lib.mkIf cfg.enable { + + home.activation = { + + # Always clone dotfiles repository if it doesn't exist + cloneDotfiles = config.lib.dag.entryAfter [ "writeBoundary" "loadkey" ] '' + if [ ! -d "${cfg.path}" ]; then + run mkdir --parents $VERBOSE_ARG $(dirname "${cfg.path}") + run ${pkgs.git}/bin/git \ + clone ${cfg.repo} "${cfg.path}" + fi + ''; + }; + + # Set a variable for dotfiles repo, not necessary but convenient + home.sessionVariables.DOTS = cfg.path; + }; +} diff --git a/platforms/home-manager/modules/nmasur/presets/services/loadkey.nix b/platforms/home-manager/modules/nmasur/presets/services/loadkey.nix index 830fb16..0070391 100644 --- a/platforms/home-manager/modules/nmasur/presets/services/loadkey.nix +++ b/platforms/home-manager/modules/nmasur/presets/services/loadkey.nix @@ -18,13 +18,16 @@ in home.activation = { # Always load the key if it doesn't exist - cloneDotfiles = config.lib.dag.entryAfter [ "writeBoundary" ] '' + loadkey = config.lib.dag.entryAfter [ "writeBoundary" ] '' + if [ ! -d ~/.ssh ]; then + run mkdir --parents $VERBOSE_ARG ~/.ssh/ + fi if [ ! -f ~/.ssh/id_ed25519 ]; then - run mkdir -p ~/.ssh/ - - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}") - $DRY_RUN_CMD ${pkgs.git}/bin/git \ - clone ${config.dotfilesRepo} "${config.dotfilesPath}" + printf "\nEnter the seed phrase for your SSH key...\n" + printf "\nThen press ^D when complete.\n\n" + mkdir -p ~/.ssh/ + ${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519 + printf "\n\nContinuing activation.\n\n" fi ''; }; diff --git a/modules/common/repositories/notes.nix b/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix similarity index 65% rename from modules/common/repositories/notes.nix rename to platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix index 74d95c5..fe23b25 100644 --- a/modules/common/repositories/notes.nix +++ b/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix @@ -4,19 +4,18 @@ lib, ... }: + +let + cfg = config.nmasur.presets.services.notes-git-sync; +in + { + options.nmasur.presets.services.notes-git-sync.enable = lib.mkEnableOption "Sync notes to folder"; - # This is just a placeholder as I expect to interact with my notes in a - # certain location - - home-manager.users.${config.user} = { - - home.sessionVariables = { - NOTES_PATH = "${config.homePath}/dev/personal/notes/content"; - }; + config = lib.mkIf cfg.enable { # Sync notes for Nextcloud automatically - systemd.user.timers.refresh-notes = lib.mkIf config.services.nextcloud.enable { + systemd.user.timers.refresh-notes = { Timer = { OnCalendar = "*-*-* *:0/10:50"; # Every 10 minutes Unit = "refresh-notes.service";