Skip to content

Fix issue #5: Refactor default.nix into modular files - #14

Open
MattiasKockum wants to merge 6 commits into
cloud-gouv:mainfrom
MattiasKockum:refactor/split-default-nix
Open

Fix issue #5: Refactor default.nix into modular files#14
MattiasKockum wants to merge 6 commits into
cloud-gouv:mainfrom
MattiasKockum:refactor/split-default-nix

Conversation

@MattiasKockum

@MattiasKockum MattiasKockum commented Apr 22, 2026

Copy link
Copy Markdown

Fixes #5

What changed?

  • Split default.nix into:
    installers/default.nix
    installers/netboot.nix
    installers/usb.nix
    registry/default.nix
    dev/ci.nix
    dev/default.nix
    dev/shell.nix
    lib/default-system.nix
  • Improved readability and maintainability

Motivation

This refactor prepares the ground for working on features without cluttering default.nix.

How to test?

  • nix-instantiate -A usb-installer produces the same hash. Same goes for 'toplevelRegistry'.
  • nix-instantiate -A net-installer produces the same error before and after (that could lead to the oppening of a separate issue)
  • nix-instantiate -A shell produces a different hash but this is because ci uses src = ../. so any change in the code base actually changes the hash here.

Comment thread dev/shell.nix
Comment thread lib/default-system.nix Outdated

# Default system closure
# This is the system that gets installed by default automatically without any user customization.
{ securix, defaultEdition }:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make it take {, ...} so that we do not have to worry about how many args we pass to it.

@rlahfa-dinum rlahfa-dinum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, can you add shell.nix at the top-level and ensure that each subfiles have { , ... } to avoid strict argument passing errors?

@MattiasKockum

Copy link
Copy Markdown
Author

Got it! Fixed that missing ellipsis (and checked the other modules had it already)
Regarding shell.nix, I'm not sure of what you're asking. Before the refactor, you had two different shells defined in top-level default.nix and the other in netboot/default.nix. And each of them were pointed to by their corresponding shell.nix.
What I did with my rework was to move the shell from top-level default into its own dev/shell.nix. And this shell is still the same called by doing nix-shell at the top-level.
But I do realize that by that by doing this, I created a new file called shell.nix, that does not have the same function as /netboot/shell.nix.
So either we accept it as-is, or I can merge dev/shell.nix into dev/default.nix to avoid confusion, or I can rename dev/shell.nix with another, clearer, name.
What do you think?

@rlahfa-dinum

Copy link
Copy Markdown
Contributor

Got it! Fixed that missing ellipsis (and checked the other modules had it already) Regarding shell.nix, I'm not sure of what you're asking. Before the refactor, you had two different shells defined in top-level default.nix and the other in netboot/default.nix. And each of them were pointed to by their corresponding shell.nix. What I did with my rework was to move the shell from top-level default into its own dev/shell.nix. And this shell is still the same called by doing nix-shell at the top-level. But I do realize that by that by doing this, I created a new file called shell.nix, that does not have the same function as /netboot/shell.nix. So either we accept it as-is, or I can merge dev/shell.nix into dev/default.nix to avoid confusion, or I can rename dev/shell.nix with another, clearer, name. What do you think?

No, I meant that it should still be possible to enter into the development shell of the project by having a development shell at the root of the Git repository. You can keep the name as-is, but it would be good to have a top-level shell that forwards to dev/shell.nix (or it can be a dev/default.nix exposing a shell attribute, I don't mind either way).

@MattiasKockum

Copy link
Copy Markdown
Author

Ok so then the PR can merged since calling nix-shell at the top level uses ./shell.nix which looks into ./default.nix for a shell which is inherited from dev/shell.nix.
This is the part that does the plumbing in ./default.nix

  installers = import ./installers moduleArgs;
  registry = import ./registry moduleArgs;
  dev = import ./dev moduleArgs;
in
{
  inherit (installers) net-installer usb-installer;
  inherit (registry) terminals toplevelRegistry;
  inherit (dev) shell;
}

And ./dev/shell.nix contains the shell that was in default.nix before the refactor.

So calling nix-shell from top-level essentially works as well as it did before.

@rlahfa-dinum rlahfa-dinum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@rlahfa-dinum

Copy link
Copy Markdown
Contributor

It seems like to me that the CI paths might have not been fully adjusted, can you take a look?

@MattiasKockum

Copy link
Copy Markdown
Author

My understanding is that the CI path problem is preexisting to my PR (since the same issue can be found here : https://github.com/cloud-gouv/bureautix-example/actions/runs/27912405996/job/82591697240)
I think I can open separate issue and propose a fix by the end of the day.

@rlahfa-dinum

Copy link
Copy Markdown
Contributor

My understanding is that the CI path problem is preexisting to my PR (since the same issue can be found here : cloud-gouv/bureautix-example/actions/runs/27912405996/job/82591697240) I think I can open separate issue and propose a fix by the end of the day.

That's fair, can you use rebase instead of merge commits for the PR? Once you are done, we can merge, thanks.

Split USB and netboot installers into a new 'installers' directory.
Add myself as a contributor.
Move 'terminals' and 'toplevelRegistry' into a new 'registry' directory.
Move ci code and shell into 'dev' directory.
Move defaultSystem into 'lib' directory.
@MattiasKockum
MattiasKockum force-pushed the refactor/split-default-nix branch from dbd59c8 to ad27863 Compare August 11, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split default.nix in modules

2 participants