Skip to content

cup-docker{,-noserver}: init at 3.4.0#412710

Merged
pbsds merged 1 commit intoNixOS:masterfrom
kuflierl:add-cup-docker
Jul 9, 2025
Merged

cup-docker{,-noserver}: init at 3.4.0#412710
pbsds merged 1 commit intoNixOS:masterfrom
kuflierl:add-cup-docker

Conversation

@kuflierl
Copy link
Member

@kuflierl kuflierl commented May 31, 2025

Homepage: https://github.com/sergi0g/cup
Issue: #410427
Source: https://github.com/kuflierl/NUR/blob/168edac19787f2fe08e65a208cf4e914726411f0/pkgs/by-name/cu/cup-docker/package.nix
Description: a lightweight way to check for container image updates. written in Rust

Things done

  • Built on platform(s)
    • x86_64-linux
    • x86_64-linux -> aarch64-linux cross
    • x86_64-linux -> x86_64-darwin cross
    • x86_64-linux -> aarch64-darwin cross
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 31, 2025
@kuflierl
Copy link
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 412710


x86_64-linux

✅ 2 packages built:
  • cup-docker
  • cup-docker-noserver

@kuflierl kuflierl added the 6.topic: docker tools Open-source software for deploying and running of containerized applications label Jun 3, 2025
@github-actions github-actions bot removed the 6.topic: docker tools Open-source software for deploying and running of containerized applications label Jun 3, 2025
@kuflierl kuflierl changed the title cup-docker{,-noserver}: add package cup-docker{,-noserver}: init at 3.4.0 Jun 4, 2025
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5550

@kuflierl kuflierl added the 6.topic: docker tools Open-source software for deploying and running of containerized applications label Jun 21, 2025
@github-actions github-actions bot removed the 6.topic: docker tools Open-source software for deploying and running of containerized applications label Jun 22, 2025
@kuflierl
Copy link
Member Author

fix(cup-docker-noserver): remove dependency for the web component

@kuflierl kuflierl requested review from Aleksanaa and emilylange June 26, 2025 21:40
@kuflierl
Copy link
Member Author

kuflierl commented Jun 26, 2025

sorry to ping yall commiters, but this one went stale for like a month
@Aleksanaa @emilylange

@emilylange emilylange removed their request for review June 29, 2025 14:54
@kuflierl
Copy link
Member Author

kuflierl commented Jul 9, 2025

@pbsds second committer ping

@pbsbot
Copy link

pbsbot commented Jul 9, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 412710
Commit: c0d1b27c519b07db0dbd1b7a490b5612c300034f


x86_64-linux

✅ 2 packages built:
  • cup-docker
  • cup-docker-noserver

@pbsds
Copy link
Member

pbsds commented Jul 9, 2025

@pbsds
Copy link
Member

pbsds commented Jul 9, 2025

builds on darwin

@pbsds pbsds merged commit abb09fa into NixOS:master Jul 9, 2025
28 of 29 checks passed
Copy link
Member

@emilylange emilylange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbsds what made you merge this as is?

Comment on lines +69 to +71
++ lib.optional withServer [
"server"
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in

nix-repl> :p cup-docker.buildFeatures                                
[
  "cli"
  [ "server" ]
]

when it should have been either

    ++ lib.optionals withServer [
      "server"
    ];

or

    ++ lib.optional withServer "server";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a genuine oversight, the issue is likely masked by builtins.toString. I'll make a fixup PR

Copy link
Member Author

@kuflierl kuflierl Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, probably made a typo. Thanks for noticing

};

meta = {
description = "a lightweight way to check for container image updates. written in Rust";
Copy link
Member

@emilylange emilylange Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how we do meta.description.

From https://github.com/NixOS/nixpkgs/blob/9406167f19eb952905fc4bf73680f644503f5581/pkgs/README.md#meta-attributes:

  • meta.description must:
    • Be short, just one sentence.
    • Be capitalized.
    • Not start with the definite or an indefinite article.
    • Not start with the package name.
      • More generally, it should not refer to the package name.
    • Not end with a period (or any punctuation for that matter).
    • Provide factual information.
      • Avoid subjective language.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The must seems to have slipped from my memory, thanks. I'll address this in a fixup

tag = "v${version}";
hash = "sha256-ciH3t2L2eJhk1+JXTqEJSuHve8OuVod7AuQ3iFWmKRE=";
};
web = stdenvNoCC.mkDerivation (finalAttrs: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wherever you may or may not have copied this from, this is a bad FOD.

Builders like this are supposed to be multistaged. One FOD for downloading the files needed (node_modules) and then a regular input addressed derivation that depends on the FOD and other dependencies to build the actual thing.

Your approach here will inevitably break, but nobody will notice it because it's a FOD cached by cache.nixos.org.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let this slide since I remember frequently seeing this pattern with pnpm in the past. I even grepped for similar patterns for bun in nixpkgs before merging this. Yes, just because it has been allowed before doesn't mean it should be allowed. This s is however from May and the it still did build on both linux and darwin.

I'll be more careful in enforcing multistage fods going forward. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually a very good reason for this. I had to add a per platform hash due to dependencies being a bit different on every platform (depending on the build platform) which had a tendency to break quite often. I have no way to practically determine the hash for every platform since i don't have a Darwin device at hand.

see the commit history in https://github.com/kuflierl/NUR/commits/main/pkgs/by-name/cu/cup-docker/package.nix especially kuflierl/NUR@813ef8e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for shining some light on this, @kuflierl.
And yet, this is one of the reasons why you shouldn't yolo your own builder, at least not in nixpkgs.

You should have waited for a proper bun builder, e.g. #414837, to land and become available in nixpkgs instead of adding this FOD to nixpkgs.
It would have literally been better if you had generated your own package-lock.json and used buildNpmPackage for this, especially for this very simple package.json.

Even going the route with per-platform-hashes would have been better. If you don't have access to a darwin machine, that's fine, most maintainers don't. You could have simply skipped darwin support and called it a day.

This FOD is still a bad FOD which should not have been merged.

I even grepped for similar patterns for bun in nixpkgs before merging this.

The existing bun FODs in nixpkgs are different and multistaged, as they should be.

Copy link
Member Author

@kuflierl kuflierl Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes this one so special is that bun acts a bit like a static site generator. IE no binaries. While sub-optimal i have determined that the output is highly reproducible.

I have worked with pnpm packages in the past and do understand how that system works. I just don't want to roll my own custom solution when there is already a pr that is working on a general solution.

This really is just a temporary solution till the bun dep-getter is added.

You should have waited for a proper bun builder

We do have a lot of bun packages. I see no reason why i should wait for a pr that isn't even merge ready and could slug around for months to come.

outputHashMode = "recursive";
});
in
rustPlatform.buildRustPackage {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combination of one derivation using finalAttrs while the other isn't is confusing.

Why make web slightly more override if you won't be able to populate your overrides to the derivation that matters, rustPlatform.buildRustPackage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed use of rec, let-in and finalAttrs derivations is not IMO a blocker. (finalAttrs: rec { ... } would be however.). I'll migrate it however to finalAttrs in my fixup. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair

Comment on lines +35 to +36
substituteInPlace node_modules/.bin/{vite,tsc} \
--replace-fail "/usr/bin/env node" "${nodejs-slim_latest}/bin/node"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be necessary if done with a proper builder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, which one? I'm not familiar with bun and I'd love to learn, is there a existing builder that applies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bun building is a bit broken in nixpkgs

Comment on lines +80 to +83
extraArgs = [
"--subpackage"
"web"
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be able to update your web FOD.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm used to seeing the passthru.web + nix-update --subpackage web pattern, and from my knowledge of the nix-update code I am under the impression that this works?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this and it works

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I stand by this. This will not update your web FOD. nix-update is not able to update arbitrary outputHash in FODs like this. It's literally not implemented. See Mic92/nix-update#163. This isn't npmDeps/npmDepsHash.

Consider the following example updating this package from 3.2.3 to 3.4.0 (the version from this init PR):

diff --git a/pkgs/by-name/cu/cup-docker/package.nix b/pkgs/by-name/cu/cup-docker/package.nix
index db44b6a69986..69c4cb8c730e 100644
--- a/pkgs/by-name/cu/cup-docker/package.nix
+++ b/pkgs/by-name/cu/cup-docker/package.nix
@@ -10,12 +10,12 @@
 }:
 let
   pname = "cup-docker";
-  version = "3.4.0";
+  version = "3.2.3";
   src = fetchFromGitHub {
     owner = "sergi0g";
     repo = "cup";
     tag = "v${version}";
-    hash = "sha256-ciH3t2L2eJhk1+JXTqEJSuHve8OuVod7AuQ3iFWmKRE=";
+    hash = "sha256-+z744Jeyh/1SGb3EeoI2bk3cfpkBIo2sczf2Ltv9JZ4=";
   };
   web = stdenvNoCC.mkDerivation (finalAttrs: {
     pname = "${pname}-web";
@@ -47,7 +47,7 @@ let
       cp -R ./dist $out
       runHook postInstall
     '';
-    outputHash = "sha256-Ac1PJYmTQv9XrmhmF1p77vdXh8252hz0CUKxJA+VQR4=";
+    outputHash = "sha256-Ks4mNhMraeFtHYuV10IslkOgapkePaGdG5zJz9d8g0I=";
     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
   });
@@ -59,7 +59,7 @@ rustPlatform.buildRustPackage {
     pname
     ;
 
-  cargoHash = "sha256-L9zugOwlPwpdtjV87dT1PH7FAMJYHYFuvfyOfPe5b2k=";
+  cargoHash = "sha256-xzQfyBRXf5hANW8qNyKPiGldi3a7MXqWA0bDBovJrVk=";
 
   buildNoDefaultFeatures = true;
   buildFeatures =
# nix-shell maintainers/scripts/update.nix --argstr package cup-docker
Going to be running update for following packages:
 - cup-docker-3.2.3

Press Enter key to continue...

Running update for:
Enqueuing group of 1 packages
 - cup-docker-3.2.3: UPDATING ...
 - cup-docker-3.2.3: DONE.

Packages updated!

which results in

diff --git a/pkgs/by-name/cu/cup-docker/package.nix b/pkgs/by-name/cu/cup-docker/package.nix
index 69c4cb8c730e..8d488957e3c6 100644
--- a/pkgs/by-name/cu/cup-docker/package.nix
+++ b/pkgs/by-name/cu/cup-docker/package.nix
@@ -10,12 +10,12 @@
 }:
 let
   pname = "cup-docker";
-  version = "3.2.3";
+  version = "3.4.0";
   src = fetchFromGitHub {
     owner = "sergi0g";
     repo = "cup";
     tag = "v${version}";
-    hash = "sha256-+z744Jeyh/1SGb3EeoI2bk3cfpkBIo2sczf2Ltv9JZ4=";
+    hash = "sha256-ciH3t2L2eJhk1+JXTqEJSuHve8OuVod7AuQ3iFWmKRE=";
   };
   web = stdenvNoCC.mkDerivation (finalAttrs: {
     pname = "${pname}-web";
@@ -59,7 +59,7 @@ rustPlatform.buildRustPackage {
     pname
     ;
 
-  cargoHash = "sha256-xzQfyBRXf5hANW8qNyKPiGldi3a7MXqWA0bDBovJrVk=";
+  cargoHash = "sha256-L9zugOwlPwpdtjV87dT1PH7FAMJYHYFuvfyOfPe5b2k=";
 
   buildNoDefaultFeatures = true;
   buildFeatures =

Note how outputHash did not change?

# nix-build -A cup-docker.web
this derivation will be built:
  /nix/store/whrcr4l5qlii1z45g36z4r6qzawg7vz2-cup-docker-web-3.4.0.drv
building '/nix/store/whrcr4l5qlii1z45g36z4r6qzawg7vz2-cup-docker-web-3.4.0.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/2b5i5i1gd4ypxrwidf25zxdkxca4ac58-source
source root is source/web
Running phase: patchPhase
[...]
patching script interpreter paths in /nix/store/g36fbnfxjbjih3vbqfwn02cp5dk6abpn-cup-docker-web-3.4.0
error: hash mismatch in fixed-output derivation '/nix/store/whrcr4l5qlii1z45g36z4r6qzawg7vz2-cup-docker-web-3.4.0.drv':
           likely URL: (unknown)
            specified: sha256-Ks4mNhMraeFtHYuV10IslkOgapkePaGdG5zJz9d8g0I=
                  got: sha256-Ac1PJYmTQv9XrmhmF1p77vdXh8252hz0CUKxJA+VQR4=
        expected path: /nix/store/g36fbnfxjbjih3vbqfwn02cp5dk6abpn-cup-docker-web-3.4.0
             got path: /nix/store/l1b9ngw1pq208mhg0a1p5xw6kgs1vmzv-cup-docker-web-3.4.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be regression on my side. I had that working at some point.

description = "a lightweight way to check for container image updates. written in Rust";
homepage = "https://cup.sergi0g.dev";
license = lib.licenses.agpl3Only;
platforms = lib.platforms.all;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustPlatform.buildRustPackage defaults to this value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the guidelines state that meta.platforms must be set, we don't however have guidelines preferring implicit over explicit. I don't expect users to know that buildRustPackage and some other builders set meta.platforms while mkDerivation does not.

@pbsds
Copy link
Member

pbsds commented Jul 10, 2025

@pbsds what made you merge this as is?

I likely weigh the cost of review cycles higher than others, and none of the small issues i located outweighed that cost. I'll be more rigorous of custom FODs going forward however 👍

@pbsds
Copy link
Member

pbsds commented Jul 10, 2025

@pbsds pbsds mentioned this pull request Jul 10, 2025
13 tasks
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants