nix icon indicating copy to clipboard operation
nix copied to clipboard

by default, nix flake new does not produce artifacts that work on mac

Open mimoo opened this issue 3 years ago • 2 comments

➜  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'

mimoo avatar Aug 07 '22 12:08 mimoo

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

thufschmitt avatar Aug 09 '22 07:08 thufschmitt

That's what I recommend in nixbyexample, but I'm surprised you need to reach out for a third dep to do this

mimoo avatar Aug 09 '22 09:08 mimoo

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

nhooey avatar Feb 14 '23 17:02 nhooey