From 6aea8d1846d729b6a02c53bf0d3ad5ba15b58d0e Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 19 Feb 2024 10:42:07 -0600 Subject: [PATCH] pinix > nom --- modules/langs/python.nix | 11 +++++++---- oizys/oizys.nim | 38 ++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/modules/langs/python.nix b/modules/langs/python.nix index b09c1b4..b00c1f3 100644 --- a/modules/langs/python.nix +++ b/modules/langs/python.nix @@ -9,19 +9,22 @@ in { options.languages.python = mkEnableOption "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 (pkgs.writeShellScriptBin "python" '' export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH - exec ${pkgs.python3}/bin/python "$@" + exec ${python}/bin/python "$@" '') (pkgs.writeShellScriptBin "python3" '' 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 ]; }; diff --git a/oizys/oizys.nim b/oizys/oizys.nim index 1af45f3..22392f1 100644 --- a/oizys/oizys.nim +++ b/oizys/oizys.nim @@ -25,7 +25,7 @@ type OizysContext = object flake, host: string cache = "daylin" - nom: bool = true + pinix: bool = true proc newCtx(): OizysContext = result = OizysContext() @@ -37,24 +37,22 @@ proc check(c: OizysContext) = error c.flake, " does not exist" error "please use -f/--flake or $FLAKE_PATH" quit 1 - info "flake: ", c.flake info "host: ", c.host - +proc cmd(c: OizysContext): string {.inline.} = + if c.pinix: "pix" else: "nix" proc systemFlakePath(c: OizysContext): string = c.flake & "#nixosConfigurations." & c.host & ".config.system.build.toplevel" proc build(c: OizysContext) = ## build nixos - let - cmd = if c.nom: "nom" else: "nix" - execQuit cmd & " build " & c.systemFlakePath + execQuit c.cmd & " build " & c.systemFlakePath proc dry(c: OizysContext) = ## 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) = let start = now() @@ -77,8 +75,8 @@ proc cache(c: OizysContext) = info "Built host: " & c.host & " in " & $duration & " seconds" -proc nixosRebuild(c: OizysContext, cmd: string) = - execQuit "sudo nixos-rebuild " & cmd & " " & " --flake " & c.flake +proc nixosRebuild(c: OizysContext, subcmd: string) = + execQuit "sudo nixos-rebuild " & subcmd & " " & " --flake " & c.flake proc boot(c: OizysContext) = ## nixos rebuild boot @@ -99,11 +97,11 @@ commands: build build system flake options: - -h|--help show this help - --host hostname (current host) - -f|--flake path to flake ($FLAKE_PATH or $HOME/oizys) - -c|--cache name of cachix binary cache (daylin) - --no-nom don't use nix-output-monitor + -h|--help show this help + --host hostname (current host) + -f|--flake path to flake ($FLAKE_PATH or $HOME/oizys) + -c|--cache name of cachix binary cache (daylin) + --no-pinix don't use pinix """ @@ -128,25 +126,25 @@ proc parseFlag(c: var OizysContext, key, val: string) = c.host = val of "f", "flake": c.flake = val - of "no-nom": - c.nom = false + of "no-pinix": + c.pinix = false when isMainModule: import std/parseopt var c = newCtx() - cmd: string + subcmd: string for kind, key, val in getopt(longNoVal = @["no-nom"]): case kind of cmdArgument: - cmd = key + subcmd = key of cmdLongOption, cmdShortOption: parseFlag c, key, val of cmdEnd: discard - if cmd == "": + if subcmd == "": echo "please specify a command" echo usage; quit 1 check c - runCmd c, cmd + runCmd c, subcmd