Code Monkey home page Code Monkey logo

Comments (6)

SomeoneSerge avatar SomeoneSerge commented on June 11, 2024 1

@shadowrylander I'm not sure, I think nixos-rebuild assumes it can distinguish machines by their hostnames, each associated with single system. Either way it's not related to flake-utils. Possibly https://discourse.nixos.org/ or https://github.com/NixOS/nix/issues would be more appropriate

from flake-utils.

SomeoneSerge avatar SomeoneSerge commented on June 11, 2024

@shadowrylander In advance: pardon me if I misunderstood or oversimplified your problem, I just skimmed through.


Flakes support a dedicated output type for nixos configurations. The wiki page demonstrates the interface:

{ self, ... }@inputs:
{
# ...
  packages."<system>"."<packagename>" = /* ... */;
  nixosConfigurations."<hostname>" = /* ... */ ;
# ...
}

You seem to be putting your nixosSystem into flake's packages output.:

      packages = flake-utils.lib.flattenTree {
        nixosConfigurations = let /* ... */  in nixosSystem /* ... */;
      };

If nixosConfigurations are per-hostname and not per-system, you probably don't even need flake-utils's eachSystem here.

if you want your flake to also provide some packages you probably can merge the output of flake-utils with an attrset that has just nixosConfigurations. That's a slippery slope though, since you're not supposed to be performing computations in your flake.nix

{
  # ...
  outputs = inputs@{ self, nixpkgs, flake-utils, ... }: (
    with flake-utils.lib; eachSystem allSystems (system: let
      pkgs = (import nixpkgs {}).legacyPackages.${system};
    in rec {
      packages = flake-utils.lib.flattenTree {
      /* whatever */
     }
      defaultPackage = packages./* ... */;
    })
  ) // {
    nixosConfigurations.siluam = nixosSystem { /* ... */ };
  };
}

On the side note, for the apps you'd probably need to find the script that applies nixos configuration. An example with home-manager (found somewhere on reddit): https://github.com/newkozlukov/dotfiles/blob/14ad265db18b58ee18198ccdb2612ac344d64676/flake.nix#L24

from flake-utils.

shadowrylander avatar shadowrylander commented on June 11, 2024

Fair enough! However, the packages thing was me trying to (unsuccessfully) build my NixOS configuration for all possible systems; would your method do that? Or do you think it's not possible at all?

from flake-utils.

SomeoneSerge avatar SomeoneSerge commented on June 11, 2024

Idk, you could take defaultSystems list (available in flake-utils) and apply genAttrs. The nixosSystem function has a system argument. As for where to put the output, I wouldn't know. That wouldn't be related to flake-utils

from flake-utils.

shadowrylander avatar shadowrylander commented on June 11, 2024

If I use genAttrs, I wouldn't be able to use the flake without specifying a build target / system configuration, such as by using #configuration, because without modifying the host name to reflect the system, the rebuild command wouldn't be able to automatically detect the correct configuration.

Sorry if this is confusing; basically, I'm worried that, instead of a configuration like hostname.system, similar to how packages are defined with an attribute per system, the configurations would end up like hostname_system, where the latter itself is the hostname of the machine.

from flake-utils.

shadowrylander avatar shadowrylander commented on June 11, 2024

Hmm... Which means the problem is with the usage of nixosConfigurations, not eachSystem... That's fair. Thanks for the help anyway; I think I know a way to build the systems dynamically!

from flake-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.