Adjust config for new lua functions

main
trivernis 8 months ago
parent 5a046686f6
commit 0b69c1aa13
Signed by: Trivernis
GPG Key ID: 7E6D18B61C8D2F4B

@ -2,10 +2,26 @@
def hosts [] { def hosts [] {
[ [
{{#each cfg.ssh_hosts}} {{#each cfg.ssh_hosts}}
"{{this}}" {
nu: false
name: (non-empty "{{this.name}}")
ip: (non-empty "{{this.ip}}")
port: (non-empty "{{this.port}}")
username: (non-empty "{{this.username}}")
mac: (non-empty "{{this.mac}}")
}
{{/each}} {{/each}}
] ]
} }
def non-empty [entry: string] {
if ($entry | str length) == 0 {
null
} else {
$entry
}
}
def "nu-complete wol" [] { def "nu-complete wol" [] {
hosts hosts
|where mac != '' |where mac != ''
@ -46,6 +62,9 @@ export def ssh [
...args # commands you wish to run on the host ...args # commands you wish to run on the host
] { ] {
let host = (hosts|where name == $hostname|get -i 0) let host = (hosts|where name == $hostname|get -i 0)
if $host == null {
^ssh $hostname ...$args
}
if ($host.nu) { if ($host.nu) {
if ($args|length) > 0 { if ($args|length) > 0 {
^ssh (get-url $host) (build-string ($args|str join ' ') '|to json -r')|from json ^ssh (get-url $host) (build-string ($args|str join ' ') '|to json -r')|from json
@ -53,7 +72,7 @@ export def ssh [
^ssh (get-url $host) ^ssh (get-url $host)
} }
} else { } else {
^ssh (get-url $host) $args ^ssh (get-url $host) ...$args
} }
} }

@ -7,7 +7,7 @@ Description=Pueue Daemon - CLI process scheduler and manager
[Service] [Service]
Restart=no Restart=no
ExecStart=/home/jri/.nix-profile/bin/pueued -vv ExecStart={{dirs.home}}/.nix-profile/bin/pueued -vv
[Install] [Install]
WantedBy=default.target WantedBy=default.target

@ -1,15 +1,17 @@
local utils = require 'utils' local utils = require 'utils'
local silo = require 'silo' local silo = require 'silo'
local log = require 'log' local log = require 'log'
local path = require 'path'
local exports = {} local exports = {}
local shasum = utils.ext_piped "shasum" local shasum = utils.ext_piped "shasum"
local ha_checksum = "" local ha_checksum = ""
local homenix = path.join { silo.dirs.config, "home-manager/home.nix" }
if utils.nu("'" .. silo.dirs.config .. "/home-manager/home.nix' | path exists") == "true\n" then if path.exists(homenix) then
ha_checksum = (shasum { silo.dirs.config .. "/home-manager/home.nix" }).stdout ha_checksum = (shasum {homenix}).stdout
log.debug(ha_checksum) log.debug(ha_checksum)
end end
@ -40,7 +42,7 @@ local function link_apps()
end end
exports.after_apply_all = function() exports.after_apply_all = function()
if utils.nu "which home-manager | is-empty" == "false\n" and (shasum { silo.dirs.config .. "/home-manager/home.nix" }).stdout ~= ha_checksum then if utils.which "home-manager" == nil and (shasum {homenix}).stdout ~= ha_checksum then
local hm = utils.ext "home-manager" local hm = utils.ext "home-manager"
log.info("Applying home-manager config") log.info("Applying home-manager config")

@ -3,7 +3,7 @@ local utils = require 'utils'
-- dirconfig -- dirconfig
local function not_installed(program) local function not_installed(program)
return utils.nu("which " .. program .. " | is-empty") == "true\n" return utils.which(program) == nil
end end
local function needs(config, program, glob) local function needs(config, program, glob)

@ -58,6 +58,7 @@ config.modules = {
'gitlint', 'gitlint',
'commitlint', 'commitlint',
'meld', 'meld',
'pueue',
}, },
gui = mod { gui = mod {
'kdePackages.breeze-icons', 'kdePackages.breeze-icons',

Loading…
Cancel
Save