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

General question about using disko when boostraping a system (flakes) #24

Closed
Baitinq opened this issue Aug 24, 2022 · 5 comments
Closed
Assignees

Comments

@Baitinq
Copy link
Contributor

Baitinq commented Aug 24, 2022

Hi, I had a general question about the usage of disko.

Currently, I am using disko in the inputs of my nixos configuration flake (https://github.com/baitinq/nixos-config) (example config in hosts/luna/disks.nix). It appears to work wonderfully, correctly creating the tsp-create/mount scripts on my system.

My question is the following, how would I use this when bootstrapping my nixos system on a new install? (which would be when it is really needed and useful).

I havent seen any flake related documentation on this, and I realise this might be a more personal nix problem with how my configuration is set up, but is there any way to just build a certain part of my configuration with flakes without having a new output created?

Thank you so much.

@Mic92
Copy link
Member

Mic92 commented Aug 25, 2022

I am not 100% sure I get your intention but you can build parts of your nixos system like this:

$ nix repl
Welcome to Nix 2.10.3. Type :? for he
nix-repl> :lf github:Mic92/dotfiles
nix-repl> :b nixosConfigurations.<PRESS_TAB> ...
nix-repl> :b nixosConfigurations.turingmachine.config.system.build.vm

# same as
$ nix build github:Mic92/dotfiles#nixosConfigurations.turingmachine.config.system.build.vm

This assumes that whatever is part of your nixos system is also exposed as an option.
If you want to build tsp-create from your nixos configuration you might need to expose it through a nixos module option:

{
  options.myoption = mkOption {                
     type = types.str;                                     
     default = tsp-create;
  };                                                      
}
$ nix build github:Mic92/dotfiles#nixosConfigurations.turingmachine.config.myoption

However it seems far easier to just expose it through a packages flake output and than just use.

nix run github:Mic92/dotfiles#tsp-create

Notice that when you use pkgs.callPackage you can reuse your partitioning script in both your nixos configuration and in packages.

I am going to close this issue, since it is not disko related. But you can continue to ask questions.

@Mic92 Mic92 closed this as completed Aug 25, 2022
@Baitinq
Copy link
Contributor Author

Baitinq commented Aug 25, 2022

Thank you so much for your help, I'll definitely try your suggestion when I get access to my pc.

However it seems far easier to just expose it through a packages flake output and than just use.

Definitely, the problem is that I have three hosts and I wouldnt want to have to expose three different new outputs for each of their disko configurations. Do you know of any way to abstract this?

@Baitinq
Copy link
Contributor Author

Baitinq commented Aug 25, 2022

@Mic92 Right now Im trying to follow your option recommendation. This is it (currently a WIP) in case anyone wants to take a look in the future for documentation purposes. (Baitinq/nixos-config#2)

@Baitinq
Copy link
Contributor Author

Baitinq commented Aug 25, 2022

@Mic92 Im done with my implementation, maybe we should consider adding some documentation on how this would be achieved? @Lassulus (As it seems like it would be one of the main use cases for disko) For reference (https://github.com/Baitinq/nixos-config/blob/master/hosts/luna/disks.nix) (nix run .#nixosConfigurations.luna.config.disko-create) (nix run .#nixosConfigurations.luna.config.disko-mount)

@Mic92
Copy link
Member

Mic92 commented Aug 26, 2022

Yeah, looks a nice example.

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

No branches or pull requests

2 participants