by default, nix flake new does not produce artifacts that work on mac
➜ test_nix nix flake new hello
wrote: /Users/davidwong/Desktop/test_nix/hello/flake.nix
➜ test_nix ls
hello
➜ test_nix cd hello
➜ hello l
total 8
drwxr-xr-x 3 davidwong staff 96B Aug 7 13:40 .
drwxr-xr-x 3 davidwong staff 96B Aug 7 13:40 ..
-rw-r--r-- 1 davidwong staff 229B Aug 7 13:40 flake.nix
➜ hello cat flake.nix
{
description = "A very basic flake";
outputs = { self, nixpkgs }: {
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
};
}
➜ hello nix develop
warning: creating lock file '/Users/davidwong/Desktop/test_nix/hello/flake.lock'
error: flake 'path:/Users/davidwong/Desktop/test_nix/hello' does not provide attribute 'devShells.x86_64-darwin.default', 'devShell.x86_64-darwin', 'packages.x86_64-darwin.default' or 'defaultPackage.x86_64-darwin'
That's quite silly indeed :thinking:
Can you duplicate this on https://github.com/NixOS/templates ?
I'm not sure what the right path would be between having a more system-generic template (but that would mean either more boilerplate or depending on an external thing like flake-utils or having a more complex template) or having a smarter templating engine that could du stuff like substituting the current system at instantiation time
That's what I recommend in nixbyexample, but I'm surprised you need to reach out for a third dep to do this
I can reproduce this with the "Getting Started" guide for dream2nix on Mac OS, using the inline version of the flake.nix file:
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
outputs = inp:
inp.dream2nix.lib.makeFlakeOutputs {
systems = ["x86_64-darwin"];
config.projectRoot = ./.;
source = ./.;
projects = ./projects.toml;
};
}
But the exact same error happens in a Nix Docker container, which is of course system: x86_64-linux.
This error is also mentioned in this issue: nix-community/dream2nix#464