Closed ThanosYeah closed 5 months ago
also if you want to detect if the installation is nixos there will always exist a file called NIXOS like this: /etc/NIXOS and add a flake.nix for nixos users to use the nix develop command to get the latest zig version:{ description = "A flake for buzz developement";
inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; zig.url = "github:mitchellh/zig-overlay";
};
outputs = { self, nixpkgs, flake-utils, ... } @ inputs: let overlays = [
(final: prev: {
zigpkgs = inputs.zig.packages.${prev.system};
})
];
# Our supported systems are the same supported systems as the Zig binaries
systems = builtins.attrNames inputs.zig.packages;
in flake-utils.lib.eachSystem systems ( system: let pkgs = import nixpkgs {inherit overlays system;}; in rec { devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ zigpkgs.master ]; };
# For compatibility with older versions of the `nix` binary
devShell = self.devShells.${system}.default;
}
);
} note if it shows warning: Git tree '/home/debian/buzz' is dirty just make sure that they are commited (note there may be another file called flak.lock when you nix develop if you don't want just copy this for the flake.lock:{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1705133751,
"narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1702350026,
"narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9463103069725474698139ab10f17a9d125da859",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"zig": "zig"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1705191948,
"narHash": "sha256-YHs8/ES5/qg7g8Rnyqsav30cJc90eCGT13oK2abdJTo=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "db65404c8d0f21f8ee6ac442af1b43001c2ab486",
"type": "github"
},
"original": {
"owner": "mitchellh",
"repo": "zig-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
),so git add . to track them and then commit and if done correctly git diff-index HEAD
should be empty
It would probably be easier to run buzz itself like:
os.execute(["zig-out/bin/buzz --version]);
XD
OS: NixOS 24.05.20231201.91050ea (Uakari) x86_64 Kernel: 6.1.64 Shell: bash 5.2.15 zig version: 0.12.0-dev.2158+4f2009de1
Hello i wanted to run zig build test for the lsp branch(i know the version is not the:0.12.0-dev.2150+63de8a598 version,but it the error isn't because of it) but this test won't pass and i suspect it is because of a hard-coded path which on other distros is granted,in this case is /bin/ls but on the nixos side it's not the case. tests/024-os.buzz:22:22: [E67] Error: FileSystemError.FileNotFound 20 ╭─ 21 │ test "os.execute" { 22 │ assert(os.execute(["/bin/ls", "-l"]) == 0, message: "Could execute a command"); ┆ ┬─ ┆ ╰─ FileSystemError.FileNotFound 23 │ } 24 ╰─ ╰─┬─ in tests/024-os.buzz:21:6 error: while executing test 'test.Testing behavior', the following command exited with code 1 (expected exited with code 0): Things that i think could be done to addres the issue:
Add extra logic for nixos so it retrieves the path of the ls executable using
which
ortype -a ls
or other methods like iterating through the path until it finds it so it doesn't errorSkip some tests for Nix Os (Only for temporarely pls) or out of curiosity,why don't you do this:assert(os.execute(["ls", "-l"]) == 0, message: "Could execute a command"); it passed for me