mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 18:30:43 -06:00
pinix > nom
This commit is contained in:
parent
079647b843
commit
6aea8d1846
2 changed files with 25 additions and 24 deletions
|
@ -9,19 +9,22 @@
|
||||||
in {
|
in {
|
||||||
options.languages.python = mkEnableOption "python";
|
options.languages.python = mkEnableOption "python";
|
||||||
config = mkIf cfg.python {
|
config = mkIf cfg.python {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages =
|
||||||
|
let python = pkgs.python3.withPackages(ps: with ps; [pip]);
|
||||||
|
in
|
||||||
|
with pkgs; [
|
||||||
# https://github.com/Mic92/nix-ld?tab=readme-ov-file#my-pythonnodejsrubyinterpreter-libraries-do-not-find-the-libraries-configured-by-nix-ld
|
# https://github.com/Mic92/nix-ld?tab=readme-ov-file#my-pythonnodejsrubyinterpreter-libraries-do-not-find-the-libraries-configured-by-nix-ld
|
||||||
(pkgs.writeShellScriptBin "python" ''
|
(pkgs.writeShellScriptBin "python" ''
|
||||||
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
||||||
exec ${pkgs.python3}/bin/python "$@"
|
exec ${python}/bin/python "$@"
|
||||||
'')
|
'')
|
||||||
|
|
||||||
(pkgs.writeShellScriptBin "python3" ''
|
(pkgs.writeShellScriptBin "python3" ''
|
||||||
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
||||||
exec ${pkgs.python3}/bin/python "$@"
|
exec ${python}/bin/python "$@"
|
||||||
'')
|
'')
|
||||||
|
|
||||||
(python3.withPackages (ps: with ps; [pip]))
|
# (python3.withPackages (ps: with ps; [pip]))
|
||||||
micromamba
|
micromamba
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@ type
|
||||||
OizysContext = object
|
OizysContext = object
|
||||||
flake, host: string
|
flake, host: string
|
||||||
cache = "daylin"
|
cache = "daylin"
|
||||||
nom: bool = true
|
pinix: bool = true
|
||||||
|
|
||||||
proc newCtx(): OizysContext =
|
proc newCtx(): OizysContext =
|
||||||
result = OizysContext()
|
result = OizysContext()
|
||||||
|
@ -37,24 +37,22 @@ proc check(c: OizysContext) =
|
||||||
error c.flake, " does not exist"
|
error c.flake, " does not exist"
|
||||||
error "please use -f/--flake or $FLAKE_PATH"
|
error "please use -f/--flake or $FLAKE_PATH"
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
info "flake: ", c.flake
|
info "flake: ", c.flake
|
||||||
info "host: ", c.host
|
info "host: ", c.host
|
||||||
|
|
||||||
|
proc cmd(c: OizysContext): string {.inline.} =
|
||||||
|
if c.pinix: "pix" else: "nix"
|
||||||
|
|
||||||
proc systemFlakePath(c: OizysContext): string =
|
proc systemFlakePath(c: OizysContext): string =
|
||||||
c.flake & "#nixosConfigurations." & c.host & ".config.system.build.toplevel"
|
c.flake & "#nixosConfigurations." & c.host & ".config.system.build.toplevel"
|
||||||
|
|
||||||
proc build(c: OizysContext) =
|
proc build(c: OizysContext) =
|
||||||
## build nixos
|
## build nixos
|
||||||
let
|
execQuit c.cmd & " build " & c.systemFlakePath
|
||||||
cmd = if c.nom: "nom" else: "nix"
|
|
||||||
execQuit cmd & " build " & c.systemFlakePath
|
|
||||||
|
|
||||||
proc dry(c: OizysContext) =
|
proc dry(c: OizysContext) =
|
||||||
## poor man's nix flake check
|
## poor man's nix flake check
|
||||||
execQuit "nix build " & c.systemFlakePath & " --dry-run"
|
execQuit c.cmd & " build " & c.systemFlakePath & " --dry-run"
|
||||||
|
|
||||||
proc cache(c: OizysContext) =
|
proc cache(c: OizysContext) =
|
||||||
let start = now()
|
let start = now()
|
||||||
|
@ -77,8 +75,8 @@ proc cache(c: OizysContext) =
|
||||||
info "Built host: " & c.host & " in " & $duration & " seconds"
|
info "Built host: " & c.host & " in " & $duration & " seconds"
|
||||||
|
|
||||||
|
|
||||||
proc nixosRebuild(c: OizysContext, cmd: string) =
|
proc nixosRebuild(c: OizysContext, subcmd: string) =
|
||||||
execQuit "sudo nixos-rebuild " & cmd & " " & " --flake " & c.flake
|
execQuit "sudo nixos-rebuild " & subcmd & " " & " --flake " & c.flake
|
||||||
|
|
||||||
proc boot(c: OizysContext) =
|
proc boot(c: OizysContext) =
|
||||||
## nixos rebuild boot
|
## nixos rebuild boot
|
||||||
|
@ -103,7 +101,7 @@ options:
|
||||||
--host hostname (current host)
|
--host hostname (current host)
|
||||||
-f|--flake path to flake ($FLAKE_PATH or $HOME/oizys)
|
-f|--flake path to flake ($FLAKE_PATH or $HOME/oizys)
|
||||||
-c|--cache name of cachix binary cache (daylin)
|
-c|--cache name of cachix binary cache (daylin)
|
||||||
--no-nom don't use nix-output-monitor
|
--no-pinix don't use pinix
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,25 +126,25 @@ proc parseFlag(c: var OizysContext, key, val: string) =
|
||||||
c.host = val
|
c.host = val
|
||||||
of "f", "flake":
|
of "f", "flake":
|
||||||
c.flake = val
|
c.flake = val
|
||||||
of "no-nom":
|
of "no-pinix":
|
||||||
c.nom = false
|
c.pinix = false
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import std/parseopt
|
import std/parseopt
|
||||||
var
|
var
|
||||||
c = newCtx()
|
c = newCtx()
|
||||||
cmd: string
|
subcmd: string
|
||||||
for kind, key, val in getopt(longNoVal = @["no-nom"]):
|
for kind, key, val in getopt(longNoVal = @["no-nom"]):
|
||||||
case kind
|
case kind
|
||||||
of cmdArgument:
|
of cmdArgument:
|
||||||
cmd = key
|
subcmd = key
|
||||||
of cmdLongOption, cmdShortOption:
|
of cmdLongOption, cmdShortOption:
|
||||||
parseFlag c, key, val
|
parseFlag c, key, val
|
||||||
of cmdEnd:
|
of cmdEnd:
|
||||||
discard
|
discard
|
||||||
if cmd == "":
|
if subcmd == "":
|
||||||
echo "please specify a command"
|
echo "please specify a command"
|
||||||
echo usage; quit 1
|
echo usage; quit 1
|
||||||
|
|
||||||
check c
|
check c
|
||||||
runCmd c, cmd
|
runCmd c, subcmd
|
||||||
|
|
Loading…
Reference in a new issue