Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable nix installer #40

Open
wants to merge 11 commits into
base: calamares
Choose a base branch
from

Conversation

FriedrichAltheide
Copy link
Contributor

@FriedrichAltheide FriedrichAltheide commented Jul 4, 2024

calamares-nixos-extensions does not currently allow you to easily create a custom installer with a customized configuration.nix.
This PR adds the idea of snippets (#15), where many of the previously defined variables containing config parts are moved into individual snippet files.
All default snippets are in the defaultConfigs/snippets directory. If you want to create a custom installer, simply place a copy of the snippet - with your changes - in the new `customConfigs/snippets' folder.
It will then be used instead of the ones defined in this repository.

As well as snippets, modules can be defined by copying them into the customConfigs/modules folder. Note that if the module is also to be imported, the imports.snippet must be customised using the method above.

Try this PR together with https://github.com/FriedrichAltheide/nixpkgs/commits/calamares-nixos-extensions-custom-installer/

@FriedrichAltheide
Copy link
Contributor Author

@vlinkz Would you be so kind, and give me a hint, if it is worth the time to rebase this PR-draft/if the idea of the PR is even wanted?

@FriedrichAltheide
Copy link
Contributor Author

@vlinkz ping

@vlinkz
Copy link
Member

vlinkz commented Sep 9, 2024

Yeah definitely seems like a good idea. I'll try to take a deeper look tomorrow or later this week

@FriedrichAltheide
Copy link
Contributor Author

The code has just been rebased and has not yet been tested again

@FriedrichAltheide FriedrichAltheide force-pushed the customizable-settings branch 2 times, most recently from 08b81a2 to 7311feb Compare September 10, 2024 08:58
@FriedrichAltheide FriedrichAltheide marked this pull request as ready for review September 10, 2024 09:35
@FriedrichAltheide FriedrichAltheide force-pushed the customizable-settings branch 2 times, most recently from 12d61df to ebd4312 Compare September 11, 2024 11:50
@FriedrichAltheide
Copy link
Contributor Author

An initial draft of a corresponding NixOS module can be found here: https://github.com/FriedrichAltheide/nixpkgs/commits/calamares-nixos-extensions-custom-installer/

@FriedrichAltheide
Copy link
Contributor Author

Is there any initial feedback yet?

@FriedrichAltheide
Copy link
Contributor Author

@vlinkz ping

Copy link

@muellerbernd muellerbernd left a comment

Choose a reason for hiding this comment

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

I like these changes and they make the code much cleaner. Tested the provided flake example for a custom calamares ISO with additional changes for my needs and it worked like expected. Would be nice if this PR gets merged.

modules/nixos/main.py Show resolved Hide resolved
@daniel-xoul-ai
Copy link

Just played around with this PR. Sorry if this is the wrong forum / inappropriate (newbie to NixOS), but is there a way to override/disable certain snippets? In my case, I want to disable showing the "user" creation step in Calamares, but it's not clear if this PR provides a way to do it.

Also huge fan of the example-custom-iso, really helped get me up to speed.

@FriedrichAltheide
Copy link
Contributor Author

@daniel-xoul-ai have a look at the unfree snippet in example-custom-iso/custom-calamares/default.nix
There you can see that you can overwrite an snippet with an empty one: unfree = '''';

@FriedrichAltheide
Copy link
Contributor Author

@vlinkz any updates?

@@ -805,6 +533,12 @@ def run():

# Write the configuration.nix file
libcalamares.utils.host_env_process_output(["cp", "/dev/stdin", config], None, cfg)
# Format configuration file
libcalamares.utils.host_env_process_output(["nixfmt", config], None)
Copy link
Member

Choose a reason for hiding this comment

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

Right now nixfmt is not in the build ISO so installation fails

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you applied my proposed module changes before building the iso? https://github.com/FriedrichAltheide/nixpkgs/commits/calamares-nixos-extensions-custom-installer/

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we can’t just ensure the templates we ship are formatted so that the resulting config will be without an explicit formatting step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be possible to format the default snippets in a way that the default configuration would look nicely. Yet, this PR intends to add an easy way to build custom installers based on the default calamares installer (e.g, some default settings like proxy, SSO, or CA settings). Hence, it would be nice to format the generated configuration.nix, ensuring that it is formatted nicely for new users.

libcalamares.utils.host_env_process_output(["nixfmt", config], None)

# Copy modules
copyModules(root_mount_point, 'defaultConfigs/modules')
Copy link
Member

Choose a reason for hiding this comment

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

Right now this leaves an empty modules folder in a users /etc/nixos dir. Maybe we should remove modules/nixos/defaultConfigs/modules directory and add a check to copyModules to return if the directory doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the check, but have not tested the code again. The motivation was to either

  • add an minimal example module for new users there or,
  • simply leaving the folder, with an .gitkeep file, for the future

@FriedrichAltheide FriedrichAltheide force-pushed the customizable-settings branch 3 times, most recently from bc9d359 to 684a4fd Compare December 5, 2024 13:46
@FriedrichAltheide
Copy link
Contributor Author

@vlinkz @emilazy Do you have further comments / feedback?

FriedrichAltheide and others added 4 commits December 16, 2024 09:11
    - Move previous config snippets into snippet files, used as default snippets (getCustomOrDefaultSnippet)
    - If a custom snippet is found in customConfigSnippets, it is used instead
@muellerbernd thanks for spotting

Co-authored-by: Bernd Müller <[email protected]>
Fix this evaluation warning on the first rebuild after install:

  [test@nixos:~]$ sudo nixos-rebuild build
  building Nix...
  building the system configuration...
  evaluation warning: The option `services.xserver.displayManager.autoLogin' defined in `/etc/nixos/configuration.nix' has been renamed to `services.displayManager.autoLogin'.

Original commit id: 41f9b1b
Author: Bjørn Forsman <[email protected]>
Co-authored-by: Bjørn Forsman <[email protected]>
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.

5 participants