Skip to content

Commit

Permalink
nixos-rebuild-ng: use nom
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Feb 18, 2025
1 parent 261517b commit 5cee05d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import os
import shutil
import textwrap
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
Expand Down Expand Up @@ -32,6 +33,14 @@
logger = logging.getLogger(__name__)


def nix_nom_tool() -> str:
"Return `nom` and `nom-shell` if found in $PATH"
if shutil.which("nom") and shutil.which("nom-shell"):
return "nom"

return "nix"


def build(
attr: str,
build_attr: BuildAttr,
Expand Down Expand Up @@ -62,9 +71,9 @@ def build_flake(
Returns the built attribute as path.
"""
run_args = [
"nix",
*FLAKE_FLAGS,
nix_nom_tool(),
"build",
*FLAKE_FLAGS,
"--print-out-paths",
flake.to_attr(attr),
*dict_to_flags(flake_build_flags),
Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def test_build_flake(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) ->
mock_run.assert_called_with(
[
"nix",
"build",
"--extra-experimental-features",
"nix-command flakes",
"build",
"--print-out-paths",
".#nixosConfigurations.hostname.config.system.build.toplevel",
"--no-link",
Expand Down Expand Up @@ -214,9 +214,9 @@ def test_build_remote_flake(
call(
[
"nix",
"build",
"--extra-experimental-features",
"nix-command flakes",
"build",
"/path/to/file^*",
"--print-out-paths",
"--build",
Expand Down

0 comments on commit 5cee05d

Please sign in to comment.