So I’ve been trying to make my own nix package on my mac m1 for a Python project and thought it would be a good idea to start with something simple, GNU hello. I like to use flake so my flake.nix looks like this
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }: let
system = "aarch64-darwin";
pkgs = import nixpkgs {inherit system;};
in {
packages.${system} = {
hello = pkgs.stdenv.mkDerivation {
pname = "hello";
version = "2.12.1";
src = pkgs.fetchurl {
url = "https://mirror.freedif.org/GNU/hello/hello-2.12.1.tar.gz";
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
};
doCheck = true;
doInstallCheck = true;
};
default = self.packages.${system}.hello;
test = pkgs.hello;
};
};
but surprise, surprise! it doesn’t work and returned an error (running: nix build .#hello)
ld: symbol(s) not found for architecture arm64
clang-16: error: linker command failed with exit code 1
so I looked up the real nixpkgs.hello source. and also tried to build from nixpkgs (running: nix build .#test) it worked fine and I couldn’t grasp why that worked and mine does not. Can someone help me out?
Cheers!