From a742860b6e96a35234ec3c172ec15d21639707a3 Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Mon, 26 May 2025 19:52:59 -0400 Subject: [PATCH 1/3] allow IFD in nix flake show Signed-off-by: ahuston-0 --- flupdt/cli.py | 5 +++++ flupdt/flake_show.py | 6 ++++-- flupdt/main.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/flupdt/cli.py b/flupdt/cli.py index a99e9b4..db658b7 100644 --- a/flupdt/cli.py +++ b/flupdt/cli.py @@ -21,6 +21,11 @@ def parse_inputs() -> argparse.Namespace: action="store_true", help="whether to compare two drv sets, must provide two evaluation jsons to compare", ) + parser.add_argument( + "--allow-import-from-derivation", + action="store_true", + help="whether to allow IFD during certain actions (ex. nix flake show)", + ) parser.add_argument( "--compare-pre-json", metavar="pre-json-path", diff --git a/flupdt/flake_show.py b/flupdt/flake_show.py index 655b8f9..2d626b7 100644 --- a/flupdt/flake_show.py +++ b/flupdt/flake_show.py @@ -71,7 +71,7 @@ def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]: return derivations -def get_derivations(path_to_flake: str) -> list[str]: +def get_derivations(path_to_flake: str, *, allow_import_from_derivation: False = False) -> list[str]: """Gets all derivations present in a flake. :param path_to_flake: path to flake to be checked @@ -83,7 +83,9 @@ def get_derivations(path_to_flake: str) -> list[str]: if nix_path is None: status_msg = "nix is not available in the PATH, please verify that it is installed" raise RuntimeError(status_msg) - flake_show = bash_wrapper(f"{nix_path} flake show --json --accept-flake-path", path=path_to_flake) + cmd = f"{nix_path} flake show --json --accept-flake-path" + cmd += " --allow-import-from-derivation" if allow_import_from_derivation else "" + flake_show = bash_wrapper(cmd, path=path_to_flake) if flake_show[2] != 0: logger.error("flake show returned non-zero exit code") logger.warning("falling back to full evaluation via nix flake check") diff --git a/flupdt/main.py b/flupdt/main.py index 151f4de..53e48cb 100755 --- a/flupdt/main.py +++ b/flupdt/main.py @@ -99,7 +99,7 @@ def build_or_eval(args: Namespace) -> None: """ flake_path = args.flake_path derivations, hydra_jobs = partition( - lambda s: s.startswith("hydraJobs"), get_derivations(flake_path) + lambda s: s.startswith("hydraJobs"), get_derivations(flake_path, args["allow-import-from-derivation"]) ) derivations, hydra_jobs = list(derivations), list(hydra_jobs) logger.info(f"derivations: {list(derivations)}") From 5b813d6fdcf77ac4cb096062bafda17a1077d5ee Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Mon, 26 May 2025 19:56:19 -0400 Subject: [PATCH 2/3] add determinate nix installer mirror --- .github/workflows/flake-health-checks.yml | 10 +++++++++- .github/workflows/flake-update.yml | 7 +++++++ .github/workflows/nix-fmt.yml | 10 +++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flake-health-checks.yml b/.github/workflows/flake-health-checks.yml index c0cea76..df2f328 100644 --- a/.github/workflows/flake-health-checks.yml +++ b/.github/workflows/flake-health-checks.yml @@ -13,7 +13,15 @@ jobs: matrix: os: [ubuntu-latest] steps: - - uses: DeterminateSystems/nix-installer-action@main + - name: Get Latest Determinate Nix Installer binary + id: latest-installer + uses: sigyl-actions/gitea-action-get-latest-release@main + with: + repository: ahuston-0/determinate-nix-mirror + - name: Install nix + uses: https://github.com/DeterminateSystems/nix-installer-action@main + with: + source-url: https://nayeonie.com/ahuston-0/determinate-nix-mirror/releases/download/${{ steps.latest-installer.outputs.release }}/nix-installer-x86_64-linux - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: diff --git a/.github/workflows/flake-update.yml b/.github/workflows/flake-update.yml index b50bb41..cee68bc 100644 --- a/.github/workflows/flake-update.yml +++ b/.github/workflows/flake-update.yml @@ -11,8 +11,15 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Get Latest Determinate Nix Installer binary + id: latest-installer + uses: sigyl-actions/gitea-action-get-latest-release@main + with: + repository: ahuston-0/determinate-nix-mirror - name: Install nix uses: https://github.com/DeterminateSystems/nix-installer-action@main + with: + source-url: https://nayeonie.com/ahuston-0/determinate-nix-mirror/releases/download/${{ steps.latest-installer.outputs.release }}/nix-installer-x86_64-linux - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: diff --git a/.github/workflows/nix-fmt.yml b/.github/workflows/nix-fmt.yml index f94cbea..783ecc0 100644 --- a/.github/workflows/nix-fmt.yml +++ b/.github/workflows/nix-fmt.yml @@ -10,7 +10,15 @@ jobs: name: "Perform Nix format checks" runs-on: ubuntu-latest steps: - - uses: DeterminateSystems/nix-installer-action@main + - name: Get Latest Determinate Nix Installer binary + id: latest-installer + uses: sigyl-actions/gitea-action-get-latest-release@main + with: + repository: ahuston-0/determinate-nix-mirror + - name: Install nix + uses: https://github.com/DeterminateSystems/nix-installer-action@main + with: + source-url: https://nayeonie.com/ahuston-0/determinate-nix-mirror/releases/download/${{ steps.latest-installer.outputs.release }}/nix-installer-x86_64-linux - name: Setup Attic cache uses: ryanccn/attic-action@v0 with: From a2b709a2f2fab1eca8e039fdeee20bb9d0ccdf4b Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Mon, 26 May 2025 20:00:14 -0400 Subject: [PATCH 3/3] get rid of attic push and flake build --- .github/workflows/flake-health-checks.yml | 22 ---------------------- .github/workflows/nix-fmt.yml | 3 --- 2 files changed, 25 deletions(-) diff --git a/.github/workflows/flake-health-checks.yml b/.github/workflows/flake-health-checks.yml index df2f328..46c27e8 100644 --- a/.github/workflows/flake-health-checks.yml +++ b/.github/workflows/flake-health-checks.yml @@ -31,25 +31,3 @@ jobs: skip-push: "true" - uses: actions/checkout@v4 - run: nix flake check --accept-flake-config - - run: nix ./utils/attic-push.bash - build-checks: - name: "Build nix outputs" - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - steps: - - uses: DeterminateSystems/nix-installer-action@main - - name: Setup Attic cache - uses: ryanccn/attic-action@v0 - with: - endpoint: ${{ secrets.ATTIC_ENDPOINT }} - cache: ${{ secrets.ATTIC_CACHE }} - token: ${{ secrets.ATTIC_TOKEN }} - skip-push: "true" - - uses: actions/checkout@v4 - - name: Build all outputs - run: nix run git+https://nayeonie.com/ahuston-0/flake-update-diff -- --build . - - name: Push to Attic - run: nix ./utils/attic-push.bash - continue-on-error: true diff --git a/.github/workflows/nix-fmt.yml b/.github/workflows/nix-fmt.yml index 783ecc0..bfbd886 100644 --- a/.github/workflows/nix-fmt.yml +++ b/.github/workflows/nix-fmt.yml @@ -28,6 +28,3 @@ jobs: skip-push: "true" - uses: actions/checkout@v4 - run: nix fmt -- --check . - - name: Push to Attic - run: nix ./utils/attic-push.bash - continue-on-error: true