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

How do I use disko command line? #58

Closed
guilhermehas opened this issue Nov 21, 2022 · 12 comments
Closed

How do I use disko command line? #58

guilhermehas opened this issue Nov 21, 2022 · 12 comments

Comments

@guilhermehas
Copy link

I am with files:

flake.nix

{
  inputs.disko.url = "github:nix-community/disko";
  inputs.disko.inputs.nixpkgs.follows = "nixpkgs";

  outputs = { self, nixpkgs, disko }: rec {
    # change `yourhostname` to your actual hostname
    nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
      # change to your system:
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        disko.nixosModules.disko
      ];
    };
    defaultPackage.x86_64-linux = nixosConfigurations.nixos.config.system.build.toplevel;
  };
}

configuration.nix

{
  pkgs,
  lib,
  ...
}:
{
  boot.loader.grub.devices = [ "/dev/sda" ];
  system.stateVersion = "22.05";
  # checkout the example folder for how to configure different diska layouts
  disko.devices = {
    disk.sda = {
      device = "/dev/sda";
      type = "disk";
      content = {
        type = "table";
        format = "gpt";
        partitions = [
          {
            type = "partition";
            name = "ESP";
            start = "1MiB";
            end = "100MiB";
            bootable = true;
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
            };
          }
          {
            name = "root";
            type = "partition";
            start = "100MiB";
            end = "100%";
            part-type = "primary";
            bootable = true;
            content = {
              type = "filesystem";
              format = "ext4";
              mountpoint = "/";
            };
          }
        ];
      };
    };
  };
}

When I try to use disko -f #nixosConfiguration, I got an error:

error: syntax error, unexpected end of file

       at «string»:1:1:

            1|
             | ^
@Lassulus
Copy link
Collaborator

I have this repo here which I used for testing https://github.com/Lassulus/flakes-testing
basically you need to put your disko config additionally into diksoConfiguration.$hostname. then you can use the disko cli with -f $flakeurl#$hostame

@Lassulus
Copy link
Collaborator

If you have more questions, or ideas for a better interface I'm happy to help :)

@guilhermehas
Copy link
Author

If I run:

disko --flake github:Lassulus/flakes-testing#fnord

it works.

But if I try to run:

 git clone git@github.com:Lassulus/flakes-testing.git
 cd flakes-testing
 disko --flake .#fnord

It does not work with error:

error: syntax error, unexpected '.'

      at «string»:1:1:

           1| .
            | ^

@zarelit
Copy link
Contributor

zarelit commented Nov 22, 2022

@guilhermehas I'm using "." with dry-run to work locally and inspect the script. nix-build wants a full URI so you can work around this by using something like disko -m create --dry-run --flake "path:$(pwd)#fnord" or better make nix resolve it beforehand: nix flake metadata --extra-experimental-features "nix-command flakes" --json -- "." | jq -r .url

@guilhermehas
Copy link
Author

Thanks for the suggestion. It worked.

@Lassulus
Copy link
Collaborator

I basically copied the flake eval code from nixos-install. if "." is something we want to support I can add that

@zarelit
Copy link
Contributor

zarelit commented Nov 23, 2022

@Lassulus I think it would be useful to support, especially when the flake is private and you just move the directory of the repo around instead of letting nix fetch it. The path: workaround would accidentally bring in the store secrets that are in the .gitignore so it would be nice to have nix itself "resolve" the flake URI, but it will bring jq in the closure
TBF the above command is copied from nixos-shell 😁

@Lassulus
Copy link
Collaborator

can you add a new issue? I will implement it probably next week. maybe this week if I can find some time

@guilhermehas
Copy link
Author

guilhermehas commented Nov 24, 2022

@guilhermehas I'm using "." with dry-run to work locally and inspect the script. nix-build wants a full URI so you can work around this by using something like disko -m create --dry-run --flake "path:$(pwd)#fnord" or better make nix resolve it beforehand: nix flake metadata --extra-experimental-features "nix-command flakes" --json -- "." | jq -r .url

This command is not working anymore:

disko -m create --dry-run --flake "path:$(pwd)#fnord"

I received the error:

error: evaluation aborted with the following error message: 'fnord does not exist'

I don't know if I am doing anything different or if the code is now broken.

@Lassulus
Copy link
Collaborator

do you have my flakes-testing repo cloned? I moved stuff around a bit to test a new way to declare the partiton script. otherwise, I don't think I changed any of the flakes logic in disko in the last couple of days, but I could be mistaken

@guilhermehas
Copy link
Author

guilhermehas commented Nov 24, 2022

do you have my flakes-testing repo cloned? I moved stuff around a bit to test a new way to declare the partiton script. otherwise, I don't think I changed any of the flakes logic in disko in the last couple of days, but I could be mistaken

Your new commit is broken in flakes-testing.
It is now working in an old version of it.

@onny
Copy link

onny commented May 19, 2023

do you have my flakes-testing repo cloned? I moved stuff around a bit to test a new way to declare the partiton script. otherwise, I don't think I changed any of the flakes logic in disko in the last couple of days, but I could be mistaken

Your new commit is broken in flakes-testing. It is now working in an old version of it.

Can you give an example? Currently I'm unable to get it working :( For me it doesn't seem to work

sudo nix run github:nix-community/disko -- --mode zap_create_mount --dry-run --flake github:Lassulus/flakes-testing#f
nord
error: evaluation aborted with the following error message: 'fnord does not exist'
(use '--show-trace' to show detailed location information)

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

4 participants