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

Can't incorporate "aarch64-sd-aarch64" image for existing system #126

Open
sokai opened this issue Aug 8, 2024 · 3 comments
Open

Can't incorporate "aarch64-sd-aarch64" image for existing system #126

sokai opened this issue Aug 8, 2024 · 3 comments

Comments

@sokai
Copy link

sokai commented Aug 8, 2024

Hey, today I tried to add a SD card image (nixos-generators) for an existing system (Raspberry Pi 3B+) to my snowfall-lib flake.

After creating the subfolders (systems/aarch64-sd-aarch64/system-name) I noticed that the normal nixosConfiguration for this system vanished, somehow, and so I couldn't use nixos-rebuild as usual (to remote x-compiling on x86_46 for aarch64 and deploy). But at the same state I could build the sd-aarch64Configurations (for this system).

FYI: I redacted some parts with […] (and changed the system name to system-name).

Before

[builder@x86_64:~]$ ls --tree -D systems/
systems
├── aarch64-linux
│  └── system-name
└── x86_64-linux
   └── […]

[builder@x86_64:~]$ nixos-rebuild build -v --option eval-cache false --use-remote-sudo --flake .#system-name --target-host system-name --use-substitutes
building the system configuration...
Building in flake mode.
$ nix --extra-experimental-features nix-command flakes build .#nixosConfigurations."system-name".config.system.build.toplevel -v --option eval-cache false --out-link /tmp/nixos-rebuild.IZmHN4/result
these 10 derivations will be built:
[…]

[builder@x86_64:~]$ nix flake show --all-systems --impure .
path:[…]
├───darwinModules: unknown
├───homeModules: unknown
├───lib: unknown
├───nixosConfigurations
│   ├───system-name: NixOS configuration
│   └───[…]
├───nixosModules
│   └───[…]
├───overlays
│   └───default: Nixpkgs overlay
├───pkgs: unknown
├───sd-aarch64Configurations: unknown
├───snowfall: unknown
└───templates

[builder@x86_64:~]$ nix -v build .#sd-aarch64Configurations.system-name
error: flake 'path:[…]' does not provide attribute 'packages.x86_64-linux.sd-aarch64Configurations.system-name', 'legacyPackages.x86_64-linux.sd-aarch64Configurations.system-name' or 'sd-aarch64Configurations.system-name'

Here everything is fine (and the last error is okay, because there still is no SD card image, it's just for illustration).

After

[builder@x86_64:~]$ ls --tree -D systems/
systems
├── aarch64-linux
│  └── system-name
├── aarch64-sd-aarch64
│  └── system-name
└── x86_64-linux
   └── […]

$ nix -v build .#sd-aarch64Configurations.system-name
these 6 derivations will be built:
[…]

[builder@x86_64:~]$ nix flake show --all-systems --impure .
path:[…]
├───darwinModules: unknown
├───homeModules: unknown
├───lib: unknown
├───nixosConfigurations
│   └───[…]
├───nixosModules
│   └───[…]
├───overlays
│   └───default: Nixpkgs overlay
├───pkgs: unknown
├───sd-aarch64Configurations: unknown
├───snowfall: unknown
└───templates

[builder@x86_64:~]$ nixos-rebuild build -v --option eval-cache false --use-remote-sudo --flake .#system-name --target-host system-name --use-substitutes
building the system configuration...
Building in flake mode.
$ nix --extra-experimental-features nix-command flakes build .#nixosConfigurations."system-name".config.system.build.toplevel -v --option eval-cache false --out-link /tmp/nixos-rebuild.7dFwHL/result
error: flake 'path:[…]' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."system-name".config.system.build.toplevel', 'legacyPackages.x86_64-linux.nixosConfigurations."system-name".config.system.build.toplevel' or 'nixosConfigurations."system-name".config.system.build.toplevel'

As you can see here, the new SD image is building, but at nix flake show the nixosConfigurations > system-name is missing (and I get the error at nixos-rebuild).

May someone have a look? (I don't know if my relative simple flake is the problem, or if it's a problem with snowflake.)

Thanks a lot in advance and KR

BTW/FYI: At the end I currently have the goal to switch my running RPi3 system to disko. ATM it runs fine and I can nixos-rebuild, but I don't know how to deploy. So a SD image seemed a possible step, also if I wanna have this functionality in any case/later on …

@tbaumann
Copy link

tbaumann commented Sep 4, 2024

I thought I was clever and thought I'd do the same.

› find systems/
systems/
systems/x86_64-linux
systems/aarch64-linux
systems/aarch64-linux/router
systems/aarch64-linux/router/nas
systems/aarch64-linux/router/hardware.nix
systems/aarch64-linux/router/default.nix
systems/aarch64-linux/nas
systems/aarch64-linux/nas/hardware.nix
systems/aarch64-linux/nas/default.nix
systems/aarch64-sd-aarch64
systems/aarch64-sd-aarch64/nas
systems/aarch64-sd-aarch64/nas/default.nix

systems/aarch64-sd-aarch64/nas/default.nix

{pkgs, ...}: {
  imports = [../../aarch64-linux/nas];
}

but

› flake show --all-systems
info  Showing flake .#
path:/home/tilli/git/snowfall/my-project?lastModified=1725462957&narHash=sha256-A2PHYlPP17b%2BSQeLjvQu0I7zRwxXqxuS9Qnw9wPfHN4%3D
├───darwinModules: unknown
├───homeConfigurations: unknown
├───homeModules: unknown
├───lib: unknown
├───nixosConfigurations
│   └───router: NixOS configuration
├───nixosModules
│   └───snowfall: NixOS module
├───overlays
│   └───default: Nixpkgs overlay
├───pkgs: unknown
├───sd-aarch64Configurations: unknown
├───snowfall: unknown
└───templates

it works if I giver it different names

› mv systems/aarch64-sd-aarch64/nas systems/aarch64-sd-aarch64/nas-sd

git/snowfall/my-project 
› flake show --all-systems
info  Showing flake .#
path:/home/tilli/git/snowfall/my-project?lastModified=1725463315&narHash=sha256-SHP174%2BJESwACrns/hK9lKn8GKIk19WqwDrT7FAqyJY%3D
├───darwinModules: unknown
├───homeConfigurations: unknown
├───homeModules: unknown
├───lib: unknown
├───nixosConfigurations
│   ├───nas: NixOS configuration
│   └───router: NixOS configuration
├───nixosModules
│   └───snowfall: NixOS module
├───overlays
│   └───default: Nixpkgs overlay
├───pkgs: unknown
├───sd-aarch64Configurations: unknown
├───snowfall: unknown
└───templates

git/snowfall/my-project 
› nix build .#sd-aarch64Configurations.nas-sd  --log-format internal-json -v --show-trace  &| nom --json
[...]

@tbaumann
Copy link

tbaumann commented Sep 4, 2024

I use nixos-generators without extra abstractions. Works well.

      systems.hosts.nas.modules = with inputs; [
        nixos-generators.nixosModules.all-formats
      ];

nix build '.#nixosConfigurations.nas.config.formats.sd-aarch64'

@jakehamilton
Copy link
Member

I believe this is a shortcoming of flake-utils-plus. The hosts we provide can be set to output to different places, but going in they must be given as a single flat attribute set. This means that names cannot be reused for two different hosts.

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

3 participants