mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
Add pkgs parameter to perSystem
This commit is contained in:
parent
cb99722a25
commit
1bd171ef6b
5 changed files with 33 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
|||
./modules/legacyPackages.nix
|
||||
./modules/nixosConfigurations.nix
|
||||
./modules/nixosModules.nix
|
||||
./modules/nixpkgs.nix
|
||||
./modules/overlay.nix
|
||||
./modules/packages.nix
|
||||
./modules/perSystem.nix
|
||||
|
|
|
@ -6,7 +6,6 @@ flakeModuleArgs@{ config, lib, inputs, ... }:
|
|||
];
|
||||
systems = [ "x86_64-linux" "aarch64-darwin" ];
|
||||
perSystem = system: { config, self', inputs', pkgs, ... }: {
|
||||
_module.args.pkgs = inputs'.nixpkgs.legacyPackages;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = [
|
||||
|
@ -17,6 +16,7 @@ flakeModuleArgs@{ config, lib, inputs, ... }:
|
|||
${config.pre-commit.installationScript}
|
||||
'';
|
||||
};
|
||||
|
||||
pre-commit = {
|
||||
inherit pkgs; # should make this default to the one it can get via follows
|
||||
settings = {
|
||||
|
|
26
modules/nixpkgs.nix
Normal file
26
modules/nixpkgs.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# Nixpkgs module. The only exception to the rule.
|
||||
#
|
||||
# Provides a `pkgs` argument in `perSystem`.
|
||||
#
|
||||
# Arguably, this shouldn't be in flake-modules-core, but in nixpkgs.
|
||||
# Nixpkgs could define its own module that does this, which would be
|
||||
# a more consistent UX, but for now this will do.
|
||||
#
|
||||
# The existence of this module does not mean that other flakes' logic
|
||||
# will be accepted into flake-modules-core, because it's against the
|
||||
# spirit of Flakes.
|
||||
#
|
||||
{
|
||||
config = {
|
||||
perSystem = _: { inputs', lib, ... }: {
|
||||
config = {
|
||||
_module.args.pkgs = lib.mkOptionDefault (
|
||||
builtins.seq
|
||||
(inputs'.nixpkgs or (throw "flake-modules-core: The flake does not have a `nixpkgs` input. Please add it, or set `perSystem._module.args.pkgs` yourself."))
|
||||
inputs'.nixpkgs.legacyPackages
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -19,12 +19,13 @@
|
|||
|
||||
];
|
||||
systems = [ "x86_64-linux" "aarch64-darwin" ];
|
||||
perSystem = system: { config, self', inputs', ... }: {
|
||||
perSystem = system: { config, self', inputs', pkgs, ... }: {
|
||||
# Per-system attributes can be defined here. The self' and inputs'
|
||||
# module parameters provide easy access to attributes of the same
|
||||
# system.
|
||||
|
||||
packages.hello = inputs'.nixpkgs.legacyPackages.hello;
|
||||
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
|
||||
packages.hello = pkgs.hello;
|
||||
};
|
||||
flake = {
|
||||
# The usual flake attributes can be defined here, including system-
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Definitions can be imported from a separate file like this one
|
||||
|
||||
{ self, ... }: {
|
||||
perSystem = system: { config, self', inputs', ... }: {
|
||||
perSystem = system: { config, self', inputs', pkgs, ... }: {
|
||||
# Definitions like this are entirely equivalent to the ones
|
||||
# you may have directly in flake.nix.
|
||||
packages.hello = inputs'.nixpkgs.legacyPackages.hello;
|
||||
packages.hello = pkgs.hello;
|
||||
};
|
||||
flake = {
|
||||
nixosModules.hello = { pkgs, ... }: {
|
||||
|
|
Loading…
Reference in a new issue