Can a single-file definition use _module.args any more gracefully than this? #83
-
Somewhat spurred by skimming #82 which I think will address the most common reason I'd want to do the following anyway. Looking at this through the lens the current default flake template, is this the main way to use {
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, flake-parts, nixpkgs, rust-overlay, ... }:
flake-parts.lib.mkFlake { inherit self; } {
imports = [
(_: {
perSystem = { system, ... }: {
config._module.args.pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
};
})
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { pkgs, ... }: {
# Available only from overlay
packages.rust = pkgs.rust-bin.stable.latest.default;
};
};
} Is this approach morally any different, or otherwise advantageous, over a normal |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think your choice to define Even nicer would be to implement #82 is intended for overlay publishing; not overlay consumption. |
Beta Was this translation helpful? Give feedback.
I think your choice to define
pkgs
in a separate module illustrates the difference quite well. You wouldn't be able to accesspkgs
in other modules if it was in a let binding. (Other modules being in other files as well; defining anonymous modules in the same file is not something to encourage, partly because the file name may be lost in error messages)Even nicer would be to implement
#82 is intended for overlay publishing; not overlay consumption.