diff --git a/.github/workflows/dependabot-nix-update.yml b/.github/workflows/dependabot-nix-update.yml index 4e594dfc2..3e80884b4 100644 --- a/.github/workflows/dependabot-nix-update.yml +++ b/.github/workflows/dependabot-nix-update.yml @@ -19,11 +19,8 @@ jobs: - name: Install Nix uses: DeterminateSystems/nix-installer-action@main - - name: Configure Cache - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Update Hash - run: nix run .#update-nix + - name: Update Nix Flake + run: nix flake update --extra-experimental-features 'nix-command flakes' - name: Set up Git Config run: | diff --git a/.husky/pre-commit b/.husky/pre-commit index 631b169fc..d1adb3823 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -11,15 +11,7 @@ if [ -x "$(/usr/bin/env which nix-shell 2>/dev/null)" ]; then nix-shell $0 exit $? else - nix flake update - # run ./nix-update.sh if package lock has changed and has no unstaged changes - if [ -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^(MM| M) package-lock.json')" ]; then - echo "package-lock.json has unstaged changes. Skipping update of nix dependencies." - elif [ ! -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^M package-lock.json')" ]; then - echo "package-lock.json has no changes. Skipping update of nix dependencies." - else - nix run .#nix-update-hashes || exit $? - fi + nix flake update --extra-experimental-features 'nix-command flakes' fi else echo "You do not appear to have nix installed. Skipping update of nix dependencies." diff --git a/flake.lock b/flake.lock index 4ef7d21fe..5222f3ca0 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/flake.nix b/flake.nix index 805ac7886..134afe7a2 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,6 @@ nixpkgs.lib.recursiveUpdate ( let - hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json); rVersion = let rev = self.sourceInfo.shortRev or self.sourceInfo.dirtyShortRev; @@ -49,12 +48,15 @@ }; src = ./.; - npmDepsHash = hashesFile.npmDepsHash; + npmDeps = pkgs.importNpmLock { npmRoot = ./.; }; + npmConfigHook = pkgs.importNpmLock.npmConfigHook; + npmBuildScript = "build:src"; makeCacheWritable = true; nativeBuildInputs = with pkgs; [ - python3 + (pkgs.python3.withPackages (ps: with ps; [ setuptools ])) ]; + installPhase = let revsFile = pkgs.writeText "spacebar-server-rev.json" ( @@ -92,35 +94,6 @@ passthru.tests = pkgs.testers.runNixOSTest (import ./nix/tests/test-bundle-starts.nix self); }; - - update-nix-hashes = pkgs.writeShellApplication { - name = "update-nix"; - runtimeInputs = with pkgs; [ - prefetch-npm-deps - nix - jq - ]; - text = '' - rm -rf node_modules - ${pkgs.nodejs_24}/bin/npm install --save --no-audit --no-fund --prefer-offline - DEPS_HASH=$(prefetch-npm-deps package-lock.json) - TMPFILE=$(mktemp) - jq '.npmDepsHash = "'"$DEPS_HASH"'"' hashes.json > "$TMPFILE" - mv -- "$TMPFILE" hashes.json - ''; - }; - - update-nix-flake = pkgs.writeShellApplication { - name = "update-nix"; - runtimeInputs = with pkgs; [ - prefetch-npm-deps - nix - jq - ]; - text = '' - nix flake update --extra-experimental-features 'nix-command flakes' - ''; - }; }; containers.docker = pkgs.dockerTools.buildLayeredImage { @@ -162,4 +135,4 @@ inherit self nixpkgs flake-utils; } ); -} \ No newline at end of file +} diff --git a/hashes.json b/hashes.json deleted file mode 100644 index 8a91aeae8..000000000 --- a/hashes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "npmDepsHash": "sha256-0SsHcwTnb17YAsbCIpZXZ/HEzcFBWMTQdIE4yySKXFE=" -}