diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-03-03 16:45:26 -0600 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-03-03 16:45:26 -0600 |
| commit | c29a14135736c2516bb5d951e6e97dc8143598db (patch) | |
| tree | 925628abfe934e3ea2cfd4a70357f8f9b5acb474 /pkgs/yo/default.nix | |
| parent | ce2cc260710f801c10302847796b931f7ed19709 (diff) | |
changes
Diffstat (limited to 'pkgs/yo/default.nix')
| -rw-r--r-- | pkgs/yo/default.nix | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/pkgs/yo/default.nix b/pkgs/yo/default.nix new file mode 100644 index 0000000..06e88d4 --- /dev/null +++ b/pkgs/yo/default.nix @@ -0,0 +1,59 @@ +{pkgs, ...}: let + yo = pkgs.writeText "yo.rb" '' + require '${./nixos.rb}' + + FLAKE_PATH = "/home/collin/nixos" + + case ARGV[0] + when "deploy", "dep" + hostname = ARGV[1] or abort "must specify hostname to build" + ssh_host = ARGV[2] or abort "must specify ssh host to target" + + store_path = Nix.build_configuration( + flake_path: FLAKE_PATH, + hostname: hostname + ) + Nix.switch_to_configuration_remote(store_path: store_path, ssh_host: ssh_host, use_magic_rollback: true) + when "switch", "sw" + store_path = Nix.build_configuration( + flake_path: FLAKE_PATH, + hostname: `hostname`.chomp + ) + Nix.switch_to_configuration( + store_path: store_path, + verb: "switch", + sudo_cmd: "run0 --background=" + ) + when "boot" + store_path = Nix.build_configuration( + flake_path: FLAKE_PATH, + hostname: `hostname`.chomp + ) + Nix.switch_to_configuration( + store_path: store_path, + verb: "boot", + sudo_cmd: "run0 --background=" + ) + when "test" + store_path = Nix.build_configuration( + flake_path: FLAKE_PATH, + hostname: `hostname`.chomp + ) + Nix.switch_to_configuration( + store_path: store_path, + verb: "test", + sudo_cmd: "run0 --background=" + ) + when "build" + hostname = ARGV[1] or `hostname`.chomp + + Nix.build_configuration( + flake_path: FLAKE_PATH, + hostname: hostname + ) + end + ''; +in + pkgs.writeShellScriptBin "yo" '' + exec ${pkgs.ruby}/bin/ruby ${yo} "$@" + '' |
