From fcbc3ec8995523a1b4b65a74c25b1b33627dde6f Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 6 Sep 2023 14:40:00 +0200 Subject: [PATCH] clan-cli: use dependency flake instead of registry --- pkgs/clan-cli/clan_cli/dirs.py | 10 +++++++--- pkgs/clan-cli/clan_cli/nix.py | 11 ++++++----- pkgs/clan-cli/default.nix | 22 ++++++++++------------ pkgs/clan-cli/deps-flake.nix | 9 +++++++++ pkgs/clan-cli/shell.nix | 8 ++++---- pkgs/clan-cli/tests/test_ssh_cli.py | 12 ++---------- 6 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 pkgs/clan-cli/deps-flake.nix diff --git a/pkgs/clan-cli/clan_cli/dirs.py b/pkgs/clan-cli/clan_cli/dirs.py index 316448a2..2ac14e8c 100644 --- a/pkgs/clan-cli/clan_cli/dirs.py +++ b/pkgs/clan-cli/clan_cli/dirs.py @@ -1,3 +1,4 @@ +import json import os import sys from pathlib import Path @@ -30,12 +31,15 @@ def module_root() -> Path: return Path(__file__).parent -def flake_registry() -> Path: - return module_root() / "nixpkgs" / "flake-registry.json" +def deps_flake() -> Path: + return module_root() / "deps_flake" def nixpkgs() -> Path: - return (module_root() / "nixpkgs" / "path").resolve() + # load the flake.lock json file from the deps_flake and return nodes.nixpkgs.path + with open(deps_flake() / "flake.lock") as f: + flake_lock = json.load(f) + return Path(flake_lock["nodes"]["nixpkgs"]["locked"]["path"]) def unfree_nixpkgs() -> Path: diff --git a/pkgs/clan-cli/clan_cli/nix.py b/pkgs/clan-cli/clan_cli/nix.py index 6f866225..a46e627f 100644 --- a/pkgs/clan-cli/clan_cli/nix.py +++ b/pkgs/clan-cli/clan_cli/nix.py @@ -1,7 +1,7 @@ import os import tempfile -from .dirs import flake_registry, unfree_nixpkgs +from .dirs import nixpkgs, unfree_nixpkgs def nix_eval(flags: list[str]) -> list[str]: @@ -13,8 +13,9 @@ def nix_eval(flags: list[str]) -> list[str]: "--show-trace", "--extra-experimental-features", "nix-command flakes", - "--flake-registry", - str(flake_registry()), + "--override-input", + "nixpkgs", + str(nixpkgs()), # --store is required to prevent this error: # error: cannot unlink '/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh': Operation not permitted "--store", @@ -41,8 +42,8 @@ def nix_shell(packages: list[str], cmd: list[str]) -> list[str]: "shell", "--extra-experimental-features", "nix-command flakes", - "--flake-registry", - str(flake_registry()), + "--inputs-from", + ".#", ] + wrapped_packages + ["-c"] diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index 6ff778dd..890a2452 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -49,19 +49,17 @@ let cp -r ${./.} $out chmod -R +w $out rm $out/clan_cli/config/jsonschema - ln -sTf ${nixpkgs} $out/clan_cli/nixpkgs + cp -r ${depsFlake} $out/clan_cli/deps_flake cp -r ${../../lib/jsonschema} $out/clan_cli/config/jsonschema ln -s ${ui-assets} $out/clan_cli/webui/assets ''; - nixpkgs = runCommand "nixpkgs" { } '' - mkdir -p $out/unfree - cat > $out/unfree/default.nix < $out/flake-registry.json <