mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-05 03:32:34 +01:00
implement nix rbuild nushell command
This commit is contained in:
parent
29b5164b15
commit
4ca0521a5f
3 changed files with 54 additions and 17 deletions
|
@ -1,14 +0,0 @@
|
|||
def "attic bpush" [
|
||||
cache:string, # The Attic cache to push to
|
||||
flake:string, # The flake reference to build
|
||||
...nixargs:string, # Extra arguments for Nix
|
||||
--nom(-n), # Use Nom
|
||||
] {
|
||||
let outpath = (^(if $nom { "nom" } else { "nix" })
|
||||
build
|
||||
--no-link
|
||||
--print-out-paths
|
||||
$flake
|
||||
...$nixargs)
|
||||
attic push $cache $outpath
|
||||
}
|
51
.config/nushell/conf.d/99-nix.nu
Normal file
51
.config/nushell/conf.d/99-nix.nu
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Build a flake reference on a remote host. Creates a `result` symlink.
|
||||
# The nix-command and flakes experimental features must be active both locally and on the target host.
|
||||
def "nix rbuild" [
|
||||
host:string, # The remote host to build on
|
||||
flakeref:string, # A flake reference to build
|
||||
...nixargs:string, # Additional arguments to pass to the eval command
|
||||
--no-link(-n), # Don't create a `result` link
|
||||
--nom, # Invoke `nom` on the remote machine instead of `nix`
|
||||
--remote-eval(-r), # Evaluate the derivation on the remote. Note that this will incorrectly handle path-based flake references.
|
||||
]: nothing -> list<string> {
|
||||
let outpaths = if $remote_eval {
|
||||
print "Eval & Build on Remote..."
|
||||
ssh $host $"(if $nom { "nom" } else { "nix" }) build --no-link --print-out-paths '($flakeref)' ($nixargs | str join ' ')" | lines
|
||||
} else {
|
||||
print "Eval..."
|
||||
let eval_output = nix eval $flakeref ...$nixargs
|
||||
if $eval_output =~ "error:" {
|
||||
error make {
|
||||
msg: "Derivation evaluation failed!",
|
||||
help: $eval_output,
|
||||
} | return $in
|
||||
}
|
||||
let drv_path = $eval_output | parse "«derivation {drv}»" | get 0.drv
|
||||
|
||||
print "Copy drv to Remote..."
|
||||
nix copy --substitute-on-destination --derivation --to $"ssh://($host)" $drv_path
|
||||
|
||||
print "Build on Remote..."
|
||||
ssh $host $"(if $nom { "nom" } else { "nix" }) build --no-link --print-out-paths '($drv_path)^*'" | lines
|
||||
}
|
||||
|
||||
print "Copy from Remote..."
|
||||
nix copy --substitute-on-destination --no-check-sigs --from $"ssh://($host)" ...$outpaths
|
||||
|
||||
$outpaths
|
||||
}
|
||||
|
||||
def "attic bpush" [
|
||||
cache:string, # The Attic cache to push to
|
||||
flake:string, # The flake reference to build
|
||||
...nixargs:string, # Extra arguments for Nix
|
||||
--nom(-n), # Use Nom
|
||||
] {
|
||||
let outpath = (^(if $nom { "nom" } else { "nix" })
|
||||
build
|
||||
--no-link
|
||||
--print-out-paths
|
||||
$flake
|
||||
...$nixargs)
|
||||
attic push $cache $outpath
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1722062969,
|
||||
"narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=",
|
||||
"lastModified": 1722630782,
|
||||
"narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3",
|
||||
"rev": "d04953086551086b44b6f3c6b7eeb26294f207da",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
Loading…
Reference in a new issue