Allow overriding configuration from outside #14

Merged
jakehamilton merged 1 commit from aleksi/foundation:receive-config into main 2025-10-18 15:35:17 +00:00
Contributor

Use case: downstream users may want to override the GNU mirror URL,
as the main ftp.gnu.org repository has caused slow downloads. Now it is possible to
perform e.g.

((import ./default.nix).extend {
  modules = [{ config.aux.mirrors.gnu = "https://www.nic.funet.fi/pub/gnu/ftp.gnu.org/pub/gnu/"; }];
}).config.exports.resolved.packages
Use case: downstream users may want to override the GNU mirror URL, as the main ftp.gnu.org repository has caused slow downloads. Now it is possible to perform e.g. ```nix ((import ./default.nix).extend { modules = [{ config.aux.mirrors.gnu = "https://www.nic.funet.fi/pub/gnu/ftp.gnu.org/pub/gnu/"; }]; }).config.exports.resolved.packages ```
aleksi added 1 commit 2025-10-03 16:38:25 +00:00
Use case: downstream users may want to override the GNU mirror URL,
as the main FTP has caused slow downloads. Now it is possible to
perform e.g.

  (import ./default.nix) {
   config.aux.mirrors.gnu = "https://www.nic.funet.fi/pub/gnu/ftp.gnu.org/pub/gnu/";
  }
aleksi changed title from Allow overriding configuration from outside to WIP: Allow overriding configuration from outside 2025-10-03 17:15:15 +00:00
aleksi force-pushed receive-config from e2be002d7c to c728bc74f0 2025-10-03 18:18:12 +00:00 Compare
aleksi force-pushed receive-config from c728bc74f0 to 8cdaee81c8 2025-10-03 18:20:27 +00:00 Compare
aleksi changed title from WIP: Allow overriding configuration from outside to Allow overriding configuration from outside 2025-10-03 18:20:42 +00:00
Author
Contributor

Incorporates #13. Otherwise builtins.mapAttrs in src/exports/default.nix will cause eager evaluation of packages (including fetching) with the default mirror regardless

Incorporates #13. Otherwise `builtins.mapAttrs` in `src/exports/default.nix` will cause eager evaluation of packages (including fetching) with the default mirror regardless
Member

I think it would be best to just include your commit and avoid mixing PRs. We'll just have to wait until #13 for mirror overrides to work properly, making foundation extensible still has value in tiself in my opinion.

I cherry-picked it locally and it looks good to me, so I'd approve id if it was just your changes :)

I think it would be best to just include your commit and avoid mixing PRs. We'll just have to wait until #13 for mirror overrides to work properly, making foundation extensible still has value in tiself in my opinion. I cherry-picked it locally and it looks good to me, so I'd approve id if it was just your changes :)
aleksi force-pushed receive-config from 8cdaee81c8 to 24507466fe 2025-10-03 19:29:46 +00:00 Compare
Author
Contributor

Yes, that's a good idea. I've rebased the branch

Yes, that's a good idea. I've rebased the branch
Member

I wonder if it's worth wrapping the extend function we expose to call extend and then return the resolved package set, so that consumers using extend don't need to access config.export.resolved.packages on the result. It seems like that's the only thing we export publicly here, so I don't see too much reason not to.

I wonder if it's worth wrapping the extend function we expose to call extend and then return the resolved package set, so that consumers using extend don't need to access `config.export.resolved.packages` on the result. It seems like that's the only thing we export publicly here, so I don't see too much reason not to.
aleksi force-pushed receive-config from 24507466fe to 25d6d22fe2 2025-10-04 05:55:54 +00:00 Compare
Author
Contributor

That seems better indeed. This new revision accesses the export automatically.

That seems better indeed. This new revision accesses the export automatically.
srxl approved these changes 2025-10-04 07:32:08 +00:00
srxl left a comment
Member

Nice, looks good to me!

Nice, looks good to me!
austreelis requested changes 2025-10-04 09:53:57 +00:00
Dismissed
default.nix Outdated
@ -13,2 +13,4 @@
in
result.config.exports.resolved.packages
// {
extend = overrides: (result.extend overrides).config.exports.resolved.packages;
Member

Because extend now returns the resolved packages, the extended foundation loses its extend attribute. I think this should be

{
  system ? builtins.currentSystem,
}:
let
  pins = import ./npins;
  lib = import pins.lib;

  modules = import ./src;

  result = lib.modules.run {
    modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ];
  };

  export = result:
    result.config.exports.resolved.packages // { extend = extend result; };

  extend = result: overrides: export (result.extend overrides);
in
export result

to allow doing ((import <foundation> {}). extend { /*...*/ }). extend { /*...*/ } as many times as we want. A bit more complex but I didn't see an obviously better way :)

Edit: corrected my suggestion, it was wrong (now it's good :3)

Because `extend` now returns the resolved packages, the extended foundation loses its `extend` attribute. I think this should be ```nix { system ? builtins.currentSystem, }: let pins = import ./npins; lib = import pins.lib; modules = import ./src; result = lib.modules.run { modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ]; }; export = result: result.config.exports.resolved.packages // { extend = extend result; }; extend = result: overrides: export (result.extend overrides); in export result ``` to allow doing `((import <foundation> {}). extend { /*...*/ }). extend { /*...*/ }` as many times as we want. A bit more complex but I didn't see an obviously better way :) Edit: corrected my suggestion, it was wrong (now it's good :3)
aleksi force-pushed receive-config from 25d6d22fe2 to 3bf00f6552 2025-10-04 10:27:57 +00:00 Compare
Author
Contributor

Completely missed that one! I've made another revision for this 👍

Completely missed that one! I've made another revision for this :+1:
austreelis approved these changes 2025-10-04 10:32:09 +00:00
Member

Looks good, thanks :D

Looks good, thanks :D
requested review from srxl 2025-10-04 16:02:49 +00:00
jakehamilton approved these changes 2025-10-04 20:21:54 +00:00
aleksi force-pushed receive-config from 3bf00f6552 to 0ec06286d7 2025-10-05 09:23:18 +00:00 Compare
aleksi force-pushed receive-config from 0ec06286d7 to e646661c32 2025-10-07 13:55:48 +00:00 Compare
Author
Contributor

I've replicated the change into flake.nix as well.

I've replicated the change into flake.nix as well.
jakehamilton merged commit 7505679c24 into main 2025-10-18 15:35:17 +00:00
jakehamilton deleted branch receive-config 2025-10-18 15:35:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: auxolotl/foundation#14
No description provided.