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.nix | |
| parent | ce2cc260710f801c10302847796b931f7ed19709 (diff) | |
changes
Diffstat (limited to 'pkgs/yo.nix')
| -rw-r--r-- | pkgs/yo.nix | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/pkgs/yo.nix b/pkgs/yo.nix deleted file mode 100644 index 8a71e51..0000000 --- a/pkgs/yo.nix +++ /dev/null @@ -1,93 +0,0 @@ -{pkgs, ...}: let - yo = pkgs.writeText "yo.lua" '' - local CONF_FILE = os.getenv("HOME") .. "/.config/yo.conf" - - local conf = {} - for l in io.open(CONF_FILE):lines() do - if l:match("^(%a+)%s") then - local k, v = l:match("^(%a+)%s+(.*)$") - conf[k] = v - end - end - - local SUDO = "sudo" - if conf.sudo then - SUDO = conf.sudo - elseif os.getenv("SUDO") then - SUDO = os.getenv("SUDO") - end - - local TARGET = "/home/collin/nixos" - - local function getHostname() - local f = io.popen("hostname") - local h = f:read("*l") - f:close() - return h - end - - local function buildConfiguration(args) - local flake_path = args.flakePath - local hostname = args.hostname - local extra_args = table.concat(args.extraArgs or {}, " ") - local build_cmd = ('nix build %s#nixosConfigurations."%s".config.system.build.toplevel --log-format internal-json %s |& ${pkgs.nix-output-monitor}/bin/nom --json'):format(flake_path, hostname, extra_args) - print("+ "..build_cmd) - os.execute(build_cmd) - end - - local function switchToConfiguration(verb) - local proc_store_path = io.popen(("readlink -f %s/result"):format(TARGET)) - local store_path = proc_store_path:read("*l") - proc_store_path:close() - - -- create generation - local create_gen_cmd = ("nix build --no-link --profile %s %s"):format("/nix/var/nix/profiles/system", store_path) - - local verb_cmd = ("%s/result/bin/switch-to-configuration %s"):format(TARGET, verb) - - local sudo_verb_cmd = ("%s ${pkgs.bashNonInteractive}/bin/bash -c '%s; %s'"):format(SUDO, create_gen_cmd, verb_cmd) - print("+ "..sudo_verb_cmd) - os.execute(sudo_verb_cmd) - end - - local function deployConfiguration(args) - local flake_path = args.flakePath - cmd = ("nix run github:serokell/deploy-rs %s -- --skip-checks -- --log-format internal-json |& ${pkgs.nix-output-monitor}/bin/nom --json"):format(flake_path) - print("+ "..cmd) - os.execute(cmd) - end - - if arg[1] == "deploy" or arg[1] == "dep" or arg[1] == "d" then - deployConfiguration{ - flakePath = TARGET - } - elseif arg[1] == "switch" or arg[1] == "sw" then - buildConfiguration{ - flakePath = TARGET, - hostname = getHostname() - } - switchToConfiguration("switch") - elseif arg[1] == "boot" then - buildConfiguration { - flakePath = TARGET, - hostname = getHostname() - } - switchToConfiguration("boot") - elseif arg[1] == "test" then - buildConfiguration { - flakePath = TARGET, - hostname = getHostname() - } - switchToConfiguration("test") - elseif arg[1] == "build" then - local hostname = arg[2] or getHostname() - buildConfiguration { - flakePath = TARGET, - hostname = hostname - } - end - ''; -in - pkgs.writeShellScriptBin "yo" '' - exec ${pkgs.lua}/bin/lua ${yo} "$@" - '' |
