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

Get system from pkgs.stdenv.hostPlatform... #37

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

phaer
Copy link
Contributor

@phaer phaer commented Feb 21, 2024

...instead of config.nixpkgs.

Without this, I encountered the following error while evaluating a host that includes typhons nixOS module.

error: Neither nixpkgs.system nor any other option in nixpkgs.* is meant to be read by modules and configurations.
Use pkgs.stdenv.hostPlatform instead.

...instead of config.nixpkgs.

error: Neither nixpkgs.system nor any other option in nixpkgs.* is meant
to be read by modules and configurations.
Use pkgs.stdenv.hostPlatform instead.
@pnmadelaine
Copy link
Member

what version of nixpkgs are you using? 🤔

@phaer
Copy link
Contributor Author

phaer commented Feb 21, 2024

nixos-unstable, resolved to NixOS/nixpkgs@b98a4e1 at last lock.

@pnmadelaine
Copy link
Member

I don't understand how we have not yet run into this error, either in the NixOS test or when deploying etna.typhon-ci.org (which is coincidently down for unrelated reasons).

The situation is pretty clear when reading the error message which was introduced in NixOS/nixpkgs@acd969a, so this looks like a necessary patch.

Still, I would really like to understand how on earth I am unable to reproduce the error!

@phaer
Copy link
Contributor Author

phaer commented Feb 21, 2024

Running a bit short on time atm, but my first guess would be that it could be related to how lib.nixosSystem gets called?

@phaer
Copy link
Contributor Author

phaer commented Feb 21, 2024

@pnmadelaine So, it should be reproducible if you call lib.nixosSystem without a system argument, but set nixpkgs.hostPlatform.

Reproducer

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    typhon.url = "github:typhon-ci/typhon";
  };

  outputs = { self, nixpkgs, typhon }: {
    nixosConfigurations.example = nixpkgs.lib.nixosSystem {
      modules = [
        typhon.nixosModules.default
        ({modulesPath, ...}: {
          imports = [
            "${modulesPath}/profiles/minimal.nix"
          ];
          config = {
            boot.isContainer = true;
            nixpkgs.hostPlatform = "x86_64-linux";

            services.typhon.enable = true;
            services.typhon.hashedPasswordFile = "/dev/null";
          };
        })
      ];
    };
  };
}

@pnmadelaine
Copy link
Member

it could be related to how lib.nixosSystem gets called?

Right, I always call lib.nixosSystem with the system argument, which seems to avoid the error as it overrides config.nixpkgs.system. I suppose @W95Psp is doing the same in the configuration for Etna… I guess we should stop doing that? 🤔 Feels weird since it sounds a lot more straightforward than setting the system via a module like you do in your example…

Anyway thank you for the patch! I will merge it as soon as our CI is back online 😄

@phaer
Copy link
Contributor Author

phaer commented Feb 21, 2024

Feels weird since it sounds a lot more straightforward than setting the system via a module like you do in your example…

My motivation for doing so, is that I can use the same lib.nixosSystem call for all hosts and just pass a set of modules into it. My host-specific configuration is just another module, where one of them defines the host platform (i have both, x86_64-linux and aarch64-linux machines in .#nixosConfigurations.

@pnmadelaine pnmadelaine merged commit 28d7491 into typhon-ci:main Feb 22, 2024
4 checks passed
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.

2 participants