Compare commits

...

3 commits

Author SHA1 Message Date
b67847e7eb fix: Correctly resolve packages from preferences.packages.version (#33)
Before this, a value that does not correspond to an attribute under a
package alias' `versions` would make it default to the latest as defined
by `lib.packages.getLatest`, which isn't a silver bullt: it choose
"bash5.2.15-bootstrap" for instance instead of stage1-passthrough (and I
don;t think we have an easy fix for that).

Given values like `"1.2.3"` makes little sense in
`config.preferences.packages.version` (because it's a package-set-wide
preference), this means it was hardly ever useful.

before:

```console
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "latest";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "stable";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
```

after:

```console
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "latest";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-stage1-passthrough"
❯ nix eval -f tidepool --apply 't:
  t.extend {modules = [{config.preferences.packages.version = "stable";}];}
  |> (t: t.config.lib.packages.resolve t.config.packages.foundation.bash)
  |> (p: p.version)'
"5.2.15-bootstrap"
```

Co-authored-by: austreelis <git@swhaele.net>
Reviewed-on: auxolotl/labs#33
Reviewed-by: Ruby Iris Juric <ruby+auxolotl@srxl.me>
Co-authored-by: Austreelis <austreelis@noreply.git.auxolotl.org>
Co-committed-by: Austreelis <austreelis@noreply.git.auxolotl.org>
2025-10-04 00:40:05 +00:00
45ac7bc494 npins/source.json version bumps (#29)
Untested, but should fix #28?

Reviewed-on: auxolotl/labs#29
Reviewed-by: Ruby Iris Juric <ruby+auxolotl@srxl.me>
Co-authored-by: Steve Dee <steved424@gmail.com>
Co-committed-by: Steve Dee <steved424@gmail.com>
2025-10-03 14:40:57 +00:00
8ffc63ae42 fix: package license causing hydra eval fails (#30)
Difference in license attrset schema between lib and tidepool caused eval fails, as in [here](https://hydra.aux-cache.dev/jobset/aux/tidepool#tabs-errors).

This PR changes tidepool's scheme to align it with lib:
```console
❯ nix eval -f tidepool packages.foundation.bash.latest.meta.license --json | jq
{
  "free": true,
  "fullName": "GNU General Public License v3.0 or later",
  "name": "gpl3Plus",
  "redistributable": true,
  "spdxId": "GPL-3.0-or-later",
  "url": "https://spdx.org/licenses/GPL-3.0-or-later.html"
}
```

I kinda liked the previous schema of tidepool, but it's a lower impact fix than bumping lib's major, and I think we want to think more about licenses in lib (e.g. it would probably make sense to move tidepool's license type there to avoid dupplicating the code for the default behavior).

Co-authored-by: austreelis <git@swhaele.net>
Reviewed-on: auxolotl/labs#30
Reviewed-by: vlinkz <vlinkz@snowflakeos.org>
Co-authored-by: Austreelis <austreelis@noreply.git.auxolotl.org>
Co-committed-by: Austreelis <austreelis@noreply.git.auxolotl.org>
2025-10-03 05:15:39 +00:00
4 changed files with 34 additions and 20 deletions

View file

@ -8,9 +8,9 @@
},
"branch": "main",
"submodules": false,
"revision": "ec6ba877756d3b898c75bdf8f75faff671fb3dbb",
"revision": "f39cac8caec87b3d93bd2f941bcf8768dc46d912",
"url": null,
"hash": "sha256-wCnUEFuFu1YKo2iE/kZeEpg3G8sCWeijuHXHTctKpJQ="
"hash": "sha256-LgdIew95Y3PBTTj8vV70gbWIyMPf3Fl30cM2WPWylNk="
},
"lib": {
"type": "Git",

View file

@ -243,11 +243,22 @@ in
in
outputs;
WELL_KNOWN_ALIASES = [
# NOTE: When adding a version alias here, update lib.types.alias and lib.types.platforms' alias sub-option
"stable"
"latest"
];
resolve =
alias:
if alias ? versions then
alias.versions.${config.preferences.packages.version}
or (alias.versions.${lib.packages.getLatest alias})
let
prefered = config.preferences.packages.version;
isWellKnown = builtins.elem prefered lib.packages.WELL_KNOWN_ALIASES;
in
if isWellKnown && alias ? ${prefered} then
alias.${prefered}
else if alias ? versions then
alias.versions.${prefered} or (alias.versions.${lib.packages.getLatest alias})
else
alias;

View file

@ -13,19 +13,18 @@ in
{ config }:
{
options = {
name = {
full = lib.options.create {
description = "The full name of the license.";
type = lib.types.string;
};
short = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
};
name = lib.options.create {
description = "The short name of the license.";
type = lib.types.string;
};
spdx = lib.options.create {
fullName = lib.options.create {
description = "The full name of the license.";
type = lib.types.string;
};
spdxId = lib.options.create {
description = "The SPDX identifier for the license.";
type = lib.types.nullish lib.types.string;
default.value = null;
@ -33,7 +32,11 @@ in
url = lib.options.create {
description = "The URL for the license.";
type = lib.types.nullish lib.types.string;
type = lib.types.string;
default = {
text = "spdx.org entry, if `spdxId` is set, `null` otherwise";
value = if config.spdxId == null then null else "https://spdx.org/licenses/${config.spdxId}.html";
};
};
free = lib.options.create {
@ -304,6 +307,7 @@ in
type = lib.types.artifact;
default.value = null;
};
# NOTE: When adding a version alias here, update lib.packages.WELL_KNOWN_ALIASES
versions = lib.options.create {
description = "Available versions of the artifact.";
type = lib.types.attrs.of lib.types.artifact;
@ -398,6 +402,8 @@ in
if config.versions == { } then null else config.versions.${lib.packages.getLatest config};
};
# NOTE: When adding a version alias here, update lib.packages.WELL_KNOWN_ALIASES
versions = lib.options.create {
description = "Available versions of the package.";
type = lib.types.attrs.of lib.types.package;

View file

@ -37,10 +37,7 @@ in
preferences.packages = {
version = lib.options.create {
description = "The preferred package version when using aliases.";
type = lib.types.enum [
"latest"
"stable"
];
type = lib.types.enum lib.packages.WELL_KNOWN_ALIASES;
default.value = "latest";
};