Hi all. I’m a bit of a noob, hoping for some help.
I’m maintaining a flake.nix
for a project. So far, there has been a nixpkgs entry for everything that I need, so I’ve been merrily populating my devshell with packages and hopping back and forth between nixos and macos + nix with abandon.
Today I tried to add chronoctl
(a cli utility for chronosphere) in the devshell for my project, but I was stopped by the fact that it is not in nixpkgs, so now I need to figure out how to hack it myself.
Here’s a simplified version of my flake.nix
{
inputs = {
flake-utils = {
url = "github:numtide/flake-utils";
};
chronoctl = {
type = "file";
url = "https://storage.googleapis.com/chronosphere-release/latest/chronoctl-linux-amd64";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
default = self.packages.${system}.hello;
};
devShells.default = pkgs.mkShell {
packages = [
# chronoctl... something ???
];
};
});
}
This is certainly wrong. Primarily because it fails with an error:
error: 'outputs' at /nix/store/xpps3iqjshxqjp2m5z4l9h0mxv8i8drs-source/flake.nix:16:13 called with unexpected argument 'chronoctl'
at «string»:45:21:
44|
45| outputs = flake.outputs (inputs // { self = result; });
| ^
46|
I have also tried it like this:
chronoctl = {
url = "file+https://storage.googleapis.com/chronosphere-release/latest/chronoctl-linux-amd64";
flake = false;
};
…but then I get a different error:
error: file:// URL 'file+https://storage.googleapis.com/chronosphere-release/latest/chronoctl-linux-amd64' has unexpected authority 'storage.googleapis.com'
Input reference trouble aside, prehaps the bigger conceptual problem is that users on darwin, or users on ARM, will have the linux-amd64 version of chronoctl
as an input, which won’t work for them.
Presumably I need to write something that maps the $system parameter of eachDefaultSystem
to the appropriate download URL (and instructs nix to chmod +x
it).
One way to do this would be to add a package for chronoctl to nixpkgs, but I kind of want to hack it to a working state locally before I publish anything. How can I do that?
I thought of having a folder in my repo which is a separate flake that handles the download, chmod, and makes a package. I would then reference that directory as an input from the flake at the root of the repo. But I’ve never seen this done so I’m reluctant to walk that path without at least a from somebody who knows nix better than I do.